-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathap_parse_ss.py
More file actions
56 lines (53 loc) · 1.49 KB
/
ap_parse_ss.py
File metadata and controls
56 lines (53 loc) · 1.49 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
44
45
46
47
48
49
50
51
52
53
54
55
56
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, col=2, tool='SSSSSSSSS'):
prefix=str(filename).split(".")[0]
typ=str(filename).split(".")[1]
ss=''
with open(filename,'r') as f:
for nn,row in enumerate(f):
tokens=row.strip().split()
if len(tokens):
if not tokens[0].startswith("#"):
n=len(tokens)
if n == 6 or n == 11: #ss3 or ss8 format file
ss+=str(tokens[col])
dis=ss.count('C')/float(len(ss))
out=open(prefix+".SS", 'a')
out.write(str(prefix).rjust(10)+" "+typ+" "+str(round(dis,2)).rjust(4)+str(tool).rjust(10)+" "+str(ss)+"\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
)
parser.add_argument(
'-c', '--column',
help='parsed column',
metavar='COL',
type=int,
default='2',
dest='col',
)
parser.add_argument(
'-t', '--tool',
help='used tool',
metavar='TOOL',
type=str,
default='SS',
dest='tool',
)
args = parser.parse_args()
ss(args.inputs, args.col, args.tool)