Mercurial > repos > jowong > spotyping
comparison spotyping_postprocess.py @ 0:7412632c7b0e draft
planemo upload
| author | jowong |
|---|---|
| date | Tue, 13 Nov 2018 10:46:18 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:7412632c7b0e |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import sys | |
| 4 import argparse as ap | |
| 5 import re | |
| 6 parser = ap.ArgumentParser(prog='spotyping_postprocess', conflict_handler='resolve', | |
| 7 description="Postprocess galaxy spotyping output") | |
| 8 | |
| 9 input = parser.add_argument_group('Input', '') | |
| 10 input.add_argument('-s', '--sample', nargs='+', required=True, help="Sample names") | |
| 11 input.add_argument('-f', '--file', nargs='+', required=True, help="File of spotyping in galaxy convention") | |
| 12 if len(sys.argv) == 0: | |
| 13 parser.print_usage() | |
| 14 sys.exit(1) | |
| 15 | |
| 16 args = parser.parse_args() | |
| 17 | |
| 18 | |
| 19 sample_dict={} | |
| 20 | |
| 21 | |
| 22 with open('spotyping_postprocess_output.txt', 'w') as output: | |
| 23 index = 0 | |
| 24 for path in args.file: | |
| 25 with open(path) as f: | |
| 26 for line in f: | |
| 27 #sample_dict[re.sub(".*/","",line.rstrip())] = args.sample[path_index] | |
| 28 sample = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', args.sample[index].rstrip().lstrip()) | |
| 29 output.write(re.sub(".*.dat", sample, line)) | |
| 30 index += 1 | |
| 31 |
