comparison PDAUG_TSVtoFASTA/PDAUG_TSVtoFASTA.py @ 0:e59674e3a391 draft

"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
author jay
date Fri, 20 Nov 2020 19:47:44 +0000
parents
children 017c42b567ac
comparison
equal deleted inserted replaced
-1:000000000000 0:e59674e3a391
1 import os
2 import argparse
3
4
5 def TSVtoFASTA(InFile, Method, Positive, Negative, OutFile):
6
7 if Method == 'WithClassLabel':
8
9 f = open(InFile)
10 lines = f.readlines()
11
12 of1 = open(Positive,'w')
13 of2 = open(Negative,'w')
14
15 n = 0
16 m = 0
17
18 for line in lines:
19
20 if '1' in line.split('\t')[1].strip('\n'):
21 n= n+1
22 of1.write('>peptide_'+str(n)+'\n')
23 of1.write(line.split('\t')[0]+'\n')
24
25 if '0' in line.split('\t')[1].strip('\n'):
26 m= m+1
27 of2.write('>peptide_'+str(m)+'\n')
28 of2.write(line.split('\t')[0]+'\n')
29
30 elif Method == 'NoClassLabel':
31
32 f = open(InFile)
33 lines = f.readlines()
34 of1 = open(OutFile,'w')
35
36 for i, line in enumerate(lines[1:]):
37 of1.write('>peptide_'+str(i)+'\n')
38 of1.write(line.split('\t')[0]+'\n')
39
40 else:
41 pass
42
43 if __name__=="__main__":
44
45 import argparse
46
47 parser = argparse.ArgumentParser()
48
49 parser.add_argument("-I", "--InFile", required=True, default=None, help=".fasta or .tsv")
50 parser.add_argument("-P", "--Postvs", required=False, default='Positive.fasta', help="Path to target tsv file")
51 parser.add_argument("-N", "--Negtvs", required=False, default='Negative.fasta', help="Path to target tsv file")
52 parser.add_argument("-O", "--OutFile", required=False, default='OutFile.fasta', help="Path to target tsv file")
53 parser.add_argument("-M", "--Method", required=True, default=None, help="Path to target tsv file")
54 args = parser.parse_args()
55
56 TSVtoFASTA(args.InFile, args.Method, args.Postvs, args.Negtvs, args.OutFile)
57