diff PDAUG_TSVtoFASTA/PDAUG_TSVtoFASTA.py @ 1:f85327600c11 draft

"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 3c91f421d26c8f42cf2671e47db735d2cf69dde8"
author jay
date Tue, 29 Dec 2020 04:11:02 +0000
parents 6c12ca9f5d88
children c9078a576efe
line wrap: on
line diff
--- a/PDAUG_TSVtoFASTA/PDAUG_TSVtoFASTA.py	Wed Oct 28 01:59:25 2020 +0000
+++ b/PDAUG_TSVtoFASTA/PDAUG_TSVtoFASTA.py	Tue Dec 29 04:11:02 2020 +0000
@@ -14,17 +14,23 @@
 
         n = 0
         m = 0
+        
+        l = []
+
+        for line in lines[1:]:
+            l.append(line.split('\t')[1].strip('\n').strip('\r'))
+        l = list(set(l))
 
         for line in lines:
 
-            if '1' in line.split('\t')[1].strip('\n'):
+            if l[0] in line.split('\t')[1].strip('\n').strip('\r'):
                 n= n+1
-                of1.write('>peptide_'+str(n)+'\n')
+                of1.write('>peptide_'+str(n)+'_'+str(l[0])+'\n')
                 of1.write(line.split('\t')[0]+'\n')
 
-            if '0' in line.split('\t')[1].strip('\n'):
+            if l[1] in line.split('\t')[1].strip('\n').strip('\r'):
                 m= m+1
-                of2.write('>peptide_'+str(m)+'\n')
+                of2.write('>peptide_'+str(m)+'_'+str(l[1])+'\n')
                 of2.write(line.split('\t')[0]+'\n')
 
     elif Method == 'NoClassLabel':
@@ -47,11 +53,10 @@
     parser = argparse.ArgumentParser()
 
     parser.add_argument("-I", "--InFile", required=True, default=None, help=".fasta or .tsv")
-    parser.add_argument("-P", "--Postvs", required=False, default='Positive.fasta', help="Path to target tsv file")
-    parser.add_argument("-N", "--Negtvs", required=False, default='Negative.fasta', help="Path to target tsv file")
+    parser.add_argument("-P", "--Postvs", required=False, default='FirstDataFile.fasta', help="Path to target tsv file")
+    parser.add_argument("-N", "--Negtvs", required=False, default='SecondDataFile.fasta', help="Path to target tsv file")
     parser.add_argument("-O", "--OutFile", required=False, default='OutFile.fasta', help="Path to target tsv file")
     parser.add_argument("-M", "--Method", required=True, default=None, help="Path to target tsv file")
     args = parser.parse_args()
 
-    TSVtoFASTA(args.InFile, args.Method, args.Postvs, args.Negtvs, args.OutFile)
-
+    TSVtoFASTA(args.InFile, args.Method, args.Postvs, args.Negtvs, args.OutFile)
\ No newline at end of file