annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
1 #!/usr/bin/env python
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
2 from __future__ import print_function
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
3 import argparse
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
4 from subprocess import check_call, CalledProcessError
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
5 import shlex
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
6 import sys
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
7 import logging
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
8 log = logging.getLogger( __name__ )
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
9
7
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
10
4
146641fe5ff6 planemo upload for repository https://github.com/zipho/novo_sort commit 0bb684bfc6b3f1f07105117dfd71285ce4ff7f4e
sanbi-uwc
parents: 3
diff changeset
11 def novo_sort( bam_filename, output_filename ):
6
e35fbd921b6b planemo upload for repository https://github.com/zipho/novo_sort commit 7cef20d7d397e9e8e1c64872c2f31417f31ed964
sanbi-uwc
parents: 5
diff changeset
12 cmdline_str = "novosort -c 8 -m 8G -s -f {} -o {}".format( bam_filename, output_filename )
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
13 cmdline = newSplit(cmdline_str)
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
14 try:
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
15 check_call(cmdline)
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
16 except CalledProcessError:
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
17 print("Error running the nova-sort", file=sys.stderr)
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
18
7
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
19
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
20 def newSplit(value):
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
21 lex = shlex.shlex(value)
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
22 lex.quotes = '"'
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
23 lex.whitespace_split = True
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
24 lex.commenters = ''
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
25 return list(lex)
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
26
7
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
27
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
28 def main():
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
29 parser = argparse.ArgumentParser(description="Re-sorting aligned files by read position")
3
9c51aca51902 planemo upload for repository https://github.com/zipho/novo_sort commit c490d694fa0be39bcd5048981cf4f08cd0821a50
sanbi-uwc
parents: 0
diff changeset
30 parser.add_argument('output_filename')
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
31 parser.add_argument('--bam_filename')
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
32 args = parser.parse_args()
7
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
33
5
6e11ef75c56c planemo upload for repository https://github.com/zipho/novo_sort commit 91b08bec675d4e76b371b0f01bc0729cd6fbacdc
sanbi-uwc
parents: 4
diff changeset
34 novo_sort(args.bam_filename, args.output_filename)
0
9b131be2b326 planemo upload for repository https://github.com/zipho/novo_sort commit fbf62dc6b9a1794b07b5189279096b7d4c03ea3b
sanbi-uwc
parents:
diff changeset
35
7
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
36
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
37 if __name__ == "__main__":
2f3d4c867e1d planemo upload for repository https://github.com/zipho/novo_sort commit 4db125fcd73327813d7bd511852bbe9ffc68a25c
sanbi-uwc
parents: 6
diff changeset
38 main()