annotate kwip_postprocess.py @ 2:352616f69941 draft default tip

planemo upload
author jowong
date Mon, 26 Nov 2018 03:05:20 -0500
parents 6c38443b46ac
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6c38443b46ac planemo upload
jowong
parents:
diff changeset
1 #!/usr/bin/env python
6c38443b46ac planemo upload
jowong
parents:
diff changeset
2
6c38443b46ac planemo upload
jowong
parents:
diff changeset
3 import sys
6c38443b46ac planemo upload
jowong
parents:
diff changeset
4 import argparse as ap
6c38443b46ac planemo upload
jowong
parents:
diff changeset
5 import re
6c38443b46ac planemo upload
jowong
parents:
diff changeset
6 parser = ap.ArgumentParser(prog='kwip_postprocess', conflict_handler='resolve',
6c38443b46ac planemo upload
jowong
parents:
diff changeset
7 description="Postprocess galaxy kWIP output")
6c38443b46ac planemo upload
jowong
parents:
diff changeset
8
6c38443b46ac planemo upload
jowong
parents:
diff changeset
9 input = parser.add_argument_group('Input', '')
6c38443b46ac planemo upload
jowong
parents:
diff changeset
10 input.add_argument('-i', '--input', nargs=1, required=True, help="kWIP galaxy OUTPUT")
6c38443b46ac planemo upload
jowong
parents:
diff changeset
11
6c38443b46ac planemo upload
jowong
parents:
diff changeset
12
6c38443b46ac planemo upload
jowong
parents:
diff changeset
13 if len(sys.argv) == 0:
6c38443b46ac planemo upload
jowong
parents:
diff changeset
14 parser.print_usage()
6c38443b46ac planemo upload
jowong
parents:
diff changeset
15 sys.exit(1)
6c38443b46ac planemo upload
jowong
parents:
diff changeset
16
6c38443b46ac planemo upload
jowong
parents:
diff changeset
17 args = parser.parse_args()
6c38443b46ac planemo upload
jowong
parents:
diff changeset
18
6c38443b46ac planemo upload
jowong
parents:
diff changeset
19
6c38443b46ac planemo upload
jowong
parents:
diff changeset
20 with open(args.input[0]) as kwip_output:
6c38443b46ac planemo upload
jowong
parents:
diff changeset
21 with open('kwip_postprocess_output.txt', 'w') as output:
6c38443b46ac planemo upload
jowong
parents:
diff changeset
22 for line in kwip_output:
6c38443b46ac planemo upload
jowong
parents:
diff changeset
23 new_line = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', line)
6c38443b46ac planemo upload
jowong
parents:
diff changeset
24 output.write(new_line)
6c38443b46ac planemo upload
jowong
parents:
diff changeset
25
6c38443b46ac planemo upload
jowong
parents:
diff changeset
26
6c38443b46ac planemo upload
jowong
parents:
diff changeset
27