annotate predict/parse_dis_pac.py @ 119:7bb98e9296e9 draft default tip

Uploaded
author tyty
date Tue, 14 Apr 2015 14:18:40 -0400
parents a292aaf51735
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a292aaf51735 Uploaded
tyty
parents:
diff changeset
1 #parse reactivity file into a dictionary
a292aaf51735 Uploaded
tyty
parents:
diff changeset
2
a292aaf51735 Uploaded
tyty
parents:
diff changeset
3 import sys
a292aaf51735 Uploaded
tyty
parents:
diff changeset
4
a292aaf51735 Uploaded
tyty
parents:
diff changeset
5 def parse_dist(in_file):
a292aaf51735 Uploaded
tyty
parents:
diff changeset
6 result = []
a292aaf51735 Uploaded
tyty
parents:
diff changeset
7 distribution = {}
a292aaf51735 Uploaded
tyty
parents:
diff changeset
8 name = []
a292aaf51735 Uploaded
tyty
parents:
diff changeset
9 f = open(in_file)
a292aaf51735 Uploaded
tyty
parents:
diff changeset
10 for aline in f.readlines():
a292aaf51735 Uploaded
tyty
parents:
diff changeset
11 line = aline.strip()
a292aaf51735 Uploaded
tyty
parents:
diff changeset
12 dis = line.strip()
a292aaf51735 Uploaded
tyty
parents:
diff changeset
13 dist = dis.split('\t') #split the line and the reactivites or reads are in a list
a292aaf51735 Uploaded
tyty
parents:
diff changeset
14 if len(dist) > 0:
a292aaf51735 Uploaded
tyty
parents:
diff changeset
15 if len(dist) == 1:
a292aaf51735 Uploaded
tyty
parents:
diff changeset
16 if dist[0].strip().find('coverage')==-1:
a292aaf51735 Uploaded
tyty
parents:
diff changeset
17 name.append(line) #add the name in the name list
a292aaf51735 Uploaded
tyty
parents:
diff changeset
18 flag = 1
a292aaf51735 Uploaded
tyty
parents:
diff changeset
19 t_name = line
a292aaf51735 Uploaded
tyty
parents:
diff changeset
20 else:
a292aaf51735 Uploaded
tyty
parents:
diff changeset
21 distri = []
a292aaf51735 Uploaded
tyty
parents:
diff changeset
22 for i in range(0, len(dist)):
a292aaf51735 Uploaded
tyty
parents:
diff changeset
23 distri.append(dist[i].strip())
a292aaf51735 Uploaded
tyty
parents:
diff changeset
24 distribution[t_name] = distri #add the list of reactivities into a dictionary
a292aaf51735 Uploaded
tyty
parents:
diff changeset
25 result.append(name)
a292aaf51735 Uploaded
tyty
parents:
diff changeset
26 result.append(distribution) #Output the dictionary
a292aaf51735 Uploaded
tyty
parents:
diff changeset
27 f.close()
a292aaf51735 Uploaded
tyty
parents:
diff changeset
28 return result
a292aaf51735 Uploaded
tyty
parents:
diff changeset
29
a292aaf51735 Uploaded
tyty
parents:
diff changeset
30
a292aaf51735 Uploaded
tyty
parents:
diff changeset
31
a292aaf51735 Uploaded
tyty
parents:
diff changeset
32
a292aaf51735 Uploaded
tyty
parents:
diff changeset
33
a292aaf51735 Uploaded
tyty
parents:
diff changeset
34
a292aaf51735 Uploaded
tyty
parents:
diff changeset
35
a292aaf51735 Uploaded
tyty
parents:
diff changeset
36
a292aaf51735 Uploaded
tyty
parents:
diff changeset
37
a292aaf51735 Uploaded
tyty
parents:
diff changeset
38
a292aaf51735 Uploaded
tyty
parents:
diff changeset
39
a292aaf51735 Uploaded
tyty
parents:
diff changeset
40
a292aaf51735 Uploaded
tyty
parents:
diff changeset
41
a292aaf51735 Uploaded
tyty
parents:
diff changeset
42
a292aaf51735 Uploaded
tyty
parents:
diff changeset
43