Mercurial > repos > sanbi-uwc > novo_sort
comparison novo_sort.py @ 7:2f3d4c867e1d draft default tip
planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
author | sanbi-uwc |
---|---|
date | Mon, 09 Jan 2017 08:19:31 -0500 |
parents | e35fbd921b6b |
children |
comparison
equal
deleted
inserted
replaced
6:e35fbd921b6b | 7:2f3d4c867e1d |
---|---|
5 import shlex | 5 import shlex |
6 import sys | 6 import sys |
7 import logging | 7 import logging |
8 log = logging.getLogger( __name__ ) | 8 log = logging.getLogger( __name__ ) |
9 | 9 |
10 | |
10 def novo_sort( bam_filename, output_filename ): | 11 def novo_sort( bam_filename, output_filename ): |
11 cmdline_str = "novosort -c 8 -m 8G -s -f {} -o {}".format( bam_filename, output_filename ) | 12 cmdline_str = "novosort -c 8 -m 8G -s -f {} -o {}".format( bam_filename, output_filename ) |
12 cmdline = newSplit(cmdline_str) | 13 cmdline = newSplit(cmdline_str) |
13 try: | 14 try: |
14 check_call(cmdline) | 15 check_call(cmdline) |
15 except CalledProcessError: | 16 except CalledProcessError: |
16 print("Error running the nova-sort", file=sys.stderr) | 17 print("Error running the nova-sort", file=sys.stderr) |
17 | 18 |
19 | |
18 def newSplit(value): | 20 def newSplit(value): |
19 lex = shlex.shlex(value) | 21 lex = shlex.shlex(value) |
20 lex.quotes = '"' | 22 lex.quotes = '"' |
21 lex.whitespace_split = True | 23 lex.whitespace_split = True |
22 lex.commenters = '' | 24 lex.commenters = '' |
23 return list(lex) | 25 return list(lex) |
24 | 26 |
27 | |
25 def main(): | 28 def main(): |
26 parser = argparse.ArgumentParser(description="Re-sorting aligned files by read position") | 29 parser = argparse.ArgumentParser(description="Re-sorting aligned files by read position") |
27 parser.add_argument('output_filename') | 30 parser.add_argument('output_filename') |
28 parser.add_argument('--bam_filename') | 31 parser.add_argument('--bam_filename') |
29 args = parser.parse_args() | 32 args = parser.parse_args() |
30 | 33 |
31 novo_sort(args.bam_filename, args.output_filename) | 34 novo_sort(args.bam_filename, args.output_filename) |
32 | 35 |
33 if __name__ == "__main__": main() | 36 |
37 if __name__ == "__main__": | |
38 main() |