Mercurial > repos > jowong > spotyping
diff spotyping_postprocess.py @ 0:7412632c7b0e draft
planemo upload
author | jowong |
---|---|
date | Tue, 13 Nov 2018 10:46:18 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spotyping_postprocess.py Tue Nov 13 10:46:18 2018 -0500 @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import sys +import argparse as ap +import re +parser = ap.ArgumentParser(prog='spotyping_postprocess', conflict_handler='resolve', + description="Postprocess galaxy spotyping output") + +input = parser.add_argument_group('Input', '') +input.add_argument('-s', '--sample', nargs='+', required=True, help="Sample names") +input.add_argument('-f', '--file', nargs='+', required=True, help="File of spotyping in galaxy convention") +if len(sys.argv) == 0: + parser.print_usage() + sys.exit(1) + +args = parser.parse_args() + + +sample_dict={} + + +with open('spotyping_postprocess_output.txt', 'w') as output: + index = 0 + for path in args.file: + with open(path) as f: + for line in f: + #sample_dict[re.sub(".*/","",line.rstrip())] = args.sample[path_index] + sample = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', args.sample[index].rstrip().lstrip()) + output.write(re.sub(".*.dat", sample, line)) + index += 1 +