annotate reactivity_cal/parse_dis_react.py @ 91:1866eeef792f draft

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