-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.py
36 lines (32 loc) · 821 Bytes
/
result.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#parse result
#Clara Liu
#2017/7/6
from parameters import *
def parse_result(str,num):
counter = 0
result = {}
while counter < num:
gene_name = str[str.find('\n')+1:str.find(':')]
a1 = str.find('= ')
a2 = str.find('(')
b1 = str.find('= ',a2)
b2 = str.find(')',a2)
c1 = str.find('= ',b2)
c2 = str.find('(',b2)
d1 = str.find('= ',c2)
d2 = str.find(')',c2)
a = int(str[a1+1:a2])
b = int(str[b1+1:b2])
c = int(str[c1+1:c2])
d = int(str[d1+1:d2])
counter +=1
result[gene_name] = [a,b,c,d]
str = str[str.find('\n',1):]
return result
def print_dict(dict):
for item in dict:
print "%s %s %s %s %s" %(item,dict[item][0],dict[item][1],dict[item][2],dict[item][3])
with open(species+'/Second_result.txt','r') as myfile:
data = myfile.read()
dict = parse_result(data,21)
print_dict(dict)