# HG changeset patch # User jowong # Date 1540129026 14400 # Node ID 492848eff35db4c81447b36df50582f07ca5617b # Parent 231b21337c432d2cde9d4cbf6c473b7cfb70f3c2 planemo upload commit 4c49b8443e44f12121afe9786a92133a7a487c7b-dirty diff -r 231b21337c43 -r 492848eff35d add_sample_name_as_first_line.py --- 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()