changeset 1:492848eff35d draft

planemo upload commit 4c49b8443e44f12121afe9786a92133a7a487c7b-dirty
author jowong
date Sun, 21 Oct 2018 09:37:06 -0400
parents 231b21337c43
children 74a9f37e2bc9
files add_sample_name_as_first_line.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/add_sample_name_as_first_line.py	Thu Sep 27 17:05:18 2018 -0400
+++ b/add_sample_name_as_first_line.py	Sun Oct 21 09:37:06 2018 -0400
@@ -3,16 +3,21 @@
 import re
 
 def Parser():
-  the_parser = argparse.ArgumentParser(description="add sample name as first line of a tab file")
-  the_parser.add_argument('--input', required=True, action="store", type=str, help="input tab file")
-  the_parser.add_argument('--output', required=True,  action="store", type=str, help="output file")
-  the_parser.add_argument('--sample', required=True, action="store", type=str, help="sample name to add as the first line of input file")
+  the_parser = argparse.ArgumentParser(description="add label to first line of file")
+  the_parser.add_argument('--input', required=True, action="store", type=str, help="input file")
+  the_parser.add_argument('--output', required=True,  action="store", type=str, help="output file path")
+  the_parser.add_argument('--label', required=True, action="store", type=str, help="label to add in the first line")
   args = the_parser.parse_args()
   return args
 
 args=Parser()
+#input=open(args.input)
+#output=open(args.output, 'w')
 
-sample_name = re.sub('[_12]*.fastq.gz', '', args.sample.rstrip().lstrip())
+#print >> output, args.label
+#print >> output, input
+
+sample_name = re.sub('(_1.fastq.gz|_2.fastq.gz|.fastq.gz)', '', args.label.rstrip().lstrip())
 
 with open(args.input) as input:
 	with open(args.output, 'w') as output:
@@ -20,4 +25,5 @@
 		for line in input:
 			output.write(line)
 
-
+#input.close()
+#output.close()