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