-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathap_parse_pattern.py
More file actions
43 lines (37 loc) · 1.1 KB
/
ap_parse_pattern.py
File metadata and controls
43 lines (37 loc) · 1.1 KB
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
import sys
import os
import argparse
#sys.path.append('/Users/adawid/PROJECTS/own/IDP_LLPS/UBQL/code/pyprot')
#print("USAGE:\npython ap_parse_ss.py -f file.ss -c 2 -t PS")
def ss(filename):
typ=str(filename).split(".")[0]
seq=prefix=''
fraq=0.0
n='----'
with open(filename,'r') as f:
for nn,row in enumerate(f):
tokens=row.strip().split()
prefix=tokens[0]
seq=tokens[1]
fraq=round(float(tokens[2]),2)
if len(tokens) > 3:
n=str(round(float(tokens[3])/len(seq),2))
out=open(prefix+".pattern", 'a')
out.write(str(prefix).rjust(9)+" "+str(fraq).ljust(4, '0').rjust(4)+" "+n.ljust(4, '0').rjust(4)+str(typ).rjust(10)+" "+str(seq)+"\n")
out.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(
prog='wget',
description=""" """,
formatter_class=argparse.RawTextHelpFormatter,
epilog=''
)
parser.add_argument(
'-f', '--filename',
help='input ss file',
metavar='INPUT',
dest='inputs',
required=True
)
args = parser.parse_args()
ss(args.inputs)