Mercurial > repos > jay > pdaug_sequence_based_peptide_generation
comparison PDAUG_TSVtoFASTA/PDAUG_TSVtoFASTA.py @ 0:93f7668caa55 draft
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit a9bd83f6a1afa6338cb6e4358b63ebff5bed155e"
author | jay |
---|---|
date | Wed, 28 Oct 2020 02:18:30 +0000 |
parents | |
children | d4075a2fc42b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:93f7668caa55 |
---|---|
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 |