5
|
1 #!/usr/bin/env python
|
|
2 # -*- coding: utf-8 -*-
|
|
3 import sys
|
|
4
|
|
5 def parse_dist(in_file):
|
|
6 result = []
|
|
7 distribution = {}
|
|
8 name = []
|
|
9 f = open(in_file)
|
|
10 flag = 0
|
|
11 for aline in f.readlines():
|
|
12 line = aline.strip()
|
|
13 dis = line.strip()
|
|
14 dist = dis.split('\t')
|
|
15 if len(dist) > 0:
|
|
16 if len(dist) == 1:
|
|
17 if dist[0].strip().find('coverage')==-1:
|
|
18 if flag == 0:
|
|
19 name.append(line)
|
|
20 flag = 1
|
|
21 t_name = line
|
|
22 else:
|
|
23 distribution[t_name] = 'null'
|
|
24 name.append(line)
|
|
25 flag = 1
|
|
26 t_name = line
|
|
27 else:
|
|
28 distri = []
|
|
29 for i in range(0, len(dist)):
|
|
30 distri.append(dist[i].strip())
|
|
31 distribution[t_name] = distri
|
|
32 flag = 0
|
|
33 result.append(name)
|
|
34 result.append(distribution)
|
|
35 f.close()
|
|
36 return result
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44
|
|
45
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|