-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSSMAnalyser.py
executable file
·41 lines (35 loc) · 1.13 KB
/
PSSMAnalyser.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
#!/usr/bin/env python3.5
"""
a script to present PSSMs in a human readable way
"""
def parse_pssm(file_name):
f = open(file_name, 'r')
cont = f.read().split('\n')
result = {}
aas = ['A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V']
for l in cont:
s = l.split()
if s == []:
continue
try:
num = int(s[0])-1
except:
continue
result[num+1] = {}
result[num+1]['type'] = s[1]
for i, sc in enumerate(s[2:22]):
result[num+1][aas[i]] = int(sc)
f.close()
return result
def main(args):
pssm = parse_pssm(args['pssm_file'])
for k, v in pssm.items():
print('pos %i %s: %s' % (k, v['type'], ', '.join([a+'='+str(b) for a, b in v.items() if a != 'type'
and b >= args['grade']])))
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-pssm_file')
parser.add_argument('-grade', default=0, type=int)
args = vars(parser.parse_args())
main(args)