Mercurial > repos > sanbi-uwc > novo_align
annotate novo_align.py @ 35:93eac6448bbd draft default tip
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit bb41321bf6e040faabb024b029df45169cdbca7f
author | sanbi-uwc |
---|---|
date | Thu, 31 May 2018 05:37:02 -0400 |
parents | fc134b9ac951 |
children |
rev | line source |
---|---|
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
2 from __future__ import print_function |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
3 import argparse |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
4 import shlex |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
5 import os |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
6 import sys |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
7 import logging |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
8 log = logging.getLogger( __name__ ) |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
9 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
10 |
32
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
11 def novo_align(out_file, out_stats, index_filename, fwd_file, rev_file ): |
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
12 param = r'@RG\tID:RG\tSM:$i\tPL:ILLUMINA' |
32
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
13 cmdline_str = "novoalign -c 8 -k -d {} -f {} {} -i PE 250, 100 -o SAM '{}' 2> {} > {}".format( |
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
14 index_filename, |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
15 fwd_file, |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
16 rev_file, |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
17 param, |
32
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
18 out_stats, |
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
19 out_file) |
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
20 try: |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
21 os.system(cmdline_str) |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
22 except: |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
23 print("Error running the nova-align", file=sys.stderr) |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
24 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
25 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
26 def newSplit(value): |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
27 lex = shlex.shlex(value) |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
28 lex.quotes = '"' |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
29 lex.whitespace_split = True |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
30 lex.commenters = '' |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
31 return list(lex) |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
32 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
33 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
34 def main(): |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
35 parser = argparse.ArgumentParser(description="Generate a BAM file from the Novo Align tool") |
32
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
36 parser.add_argument('out_file') |
33
fc134b9ac951
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit a5e4ca4a66eb4e315ca564238e27e03936eea6fa
sanbi-uwc
parents:
32
diff
changeset
|
37 parser.add_argument('--out_stats') |
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
38 parser.add_argument('--index_filename') |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
39 parser.add_argument('--forward_filename') |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
40 parser.add_argument('--reverse_filename') |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
41 args = parser.parse_args() |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
42 |
32
c6e99afd59a8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/tools/novo_align commit 928e9337a1e33476053e38f1c07247b2306d3209
sanbi-uwc
parents:
31
diff
changeset
|
43 novo_align(args.out_file, args.out_stats, args.index_filename, args.forward_filename, args.reverse_filename) |
22
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
44 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
45 |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
46 if __name__ == "__main__": |
482aef16b6f5
planemo upload for repository https://github.com/zipho/novo_align commit 3aa343058f631ac4117c9bc86989dc449f84135f
sanbi-uwc
parents:
diff
changeset
|
47 main() |