Mercurial > repos > sanbi-uwc > novo_sort
diff novo_sort.py @ 0:9b131be2b326 draft
planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
author | sanbi-uwc |
---|---|
date | Fri, 11 Mar 2016 02:35:09 -0500 |
parents | |
children | 9c51aca51902 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/novo_sort.py Fri Mar 11 02:35:09 2016 -0500 @@ -0,0 +1,32 @@ +#!/usr/bin/env python +from __future__ import print_function +import argparse +from subprocess import check_call, CalledProcessError +import shlex +import sys +import logging +log = logging.getLogger( __name__ ) + +def novo_sort( bam_filename ): + cmdline_str = "novosort -c 8 -m 8G -s -f {}".format( bam_filename ) + cmdline = newSplit(cmdline_str) + try: + check_call(cmdline) + except CalledProcessError: + print("Error running the nova-sort", file=sys.stderr) + +def newSplit(value): + lex = shlex.shlex(value) + lex.quotes = '"' + lex.whitespace_split = True + lex.commenters = '' + return list(lex) + +def main(): + parser = argparse.ArgumentParser(description="Re-sorting aligned files by read position") + parser.add_argument('--bam_filename') + args = parser.parse_args() + + novo_sort(args.bam_filename) + +if __name__ == "__main__": main()