-
Notifications
You must be signed in to change notification settings - Fork 1
/
TOPCONS_funcs.py
executable file
·55 lines (49 loc) · 1.74 KB
/
TOPCONS_funcs.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python2.7
"""
TOPCONS related functions
"""
def parse_topcons_output(args):
with open(args['in_path']+args['topcons_file'], 'r') as fin:
cont = fin.read().split('\n')
result = {}
for i, l in enumerate(cont):
s = l.split()
try:
if s[1] == 'name:':
l_name = l
name = ''.join(s[2:])
except:
pass
try:
if s[0] in ['TOPCONS', 'OCTOPUS', 'Philius', 'PolyPhobius', 'SCAMPI', 'SPOCTOPUS']:
result[s[0].lower()] = cont[i+1]
except:
pass
# print name
# print result
# if args['special']:
# name_list = parse_assaf()
# for n in name_list:
# if n in l_name.lower():
# name = n
# break
if args['special']:
name = l_name.split('GN=')[1].split()[0]
with open(args['out_path']+name+'.spc', 'wr+') as fout:
fout.write('name %s\n' % name)
for k, v in result.items():
fout.write('%s %s\n' % (k, v))
def parse_assaf():
with open('/home/labs/fleishman/elazara/benchmark_paper_new/eSOL/Soluble/list.list', 'r') as cin:
return cin.read().lower().split('\n')
if __name__ == '__main__':
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('-name', type=str, help='job name')
parser.add_argument('-topcons_file', type=str, help='name of TOPCONS result file')
parser.add_argument('-in_path', type=str, default=os.getcwd()+'/', help='in path')
parser.add_argument('-out_path', type=str, default=os.getcwd()+'/', help='out path')
parser.add_argument('-special', type=bool)
args = vars(parser.parse_args())
parse_topcons_output(args)