-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsynsor_parse.py
More file actions
57 lines (42 loc) · 1.38 KB
/
synsor_parse.py
File metadata and controls
57 lines (42 loc) · 1.38 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
57
import argparse as ap
import os
import sys
import re
class SynsorParse(object):
VERSION = '1.0.0'
@staticmethod
def parse(infile, outfile):
if os.path.isfile(outfile):
print(outfile + ' already exists')
sys.exit()
f1 = open(outfile, 'w')
total = 0
not_syn = 0
with open(infile, 'r') as file:
for line in file:
if not line.startswith("seqId"):
total += 1
x = line.split('\t')
seqid = x[0]
prob = x[2]
pred_class = x[4]
if pred_class == "Not synthetic":
not_syn += 1
seqid = re.sub(r"\s+", "_", seqid)
f1.write(seqid + '\t')
f1.write(pred_class + '\t')
f1.write(prob + '\n')
f1.close()
print("Total : " + str(total))
print("Not syn: " + str(not_syn))
if __name__ == "__main__":
argument_parser = ap.ArgumentParser(prog='synsor_parse')
argument_parser.add_argument(dest='in_file',
type=str)
argument_parser.add_argument(dest='out_file', type=str)
args = argument_parser.parse_args()
in_file = args.in_file
out_file = args.out_file
SynsorParse.parse(
in_file,
out_file)