Mercurial > repos > sanbi-uwc > novo_align
annotate novo_align.py @ 6:3938f90c9d91 draft
planemo upload for repository https://github.com/zipho/novo_align commit 4a89d4d866533a93706ceb29077d2e9bda69aa9f
author | sanbi-uwc |
---|---|
date | Fri, 11 Mar 2016 02:32:25 -0500 |
parents | d51c5af7a8fe |
children | 9a6f14e2c8fd |
rev | line source |
---|---|
5
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
2 from __future__ import print_function |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
3 import argparse |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
4 import shlex |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
5 import os |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
6 import logging |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
7 log = logging.getLogger( __name__ ) |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
8 |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
9 def novo_align(output_filename, index_filename, fwd_file, rev_file ): |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
10 param = r'@RG\tID:RG\tSM:$i\tPL:ILLUMINA' |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
11 cmdline_str = "novoalign -c 8 -k -d {} -f {} {} -i PE 250, 100 -o SAM '{}' | samtools view -bS - > {}".format( |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
12 index_filename, |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
13 fwd_file, |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
14 rev_file, |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
15 param, |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
16 output_filename) |
6
3938f90c9d91
planemo upload for repository https://github.com/zipho/novo_align commit 4a89d4d866533a93706ceb29077d2e9bda69aa9f
sanbi-uwc
parents:
5
diff
changeset
|
17 try: |
3938f90c9d91
planemo upload for repository https://github.com/zipho/novo_align commit 4a89d4d866533a93706ceb29077d2e9bda69aa9f
sanbi-uwc
parents:
5
diff
changeset
|
18 os.system(cmdline_str) |
3938f90c9d91
planemo upload for repository https://github.com/zipho/novo_align commit 4a89d4d866533a93706ceb29077d2e9bda69aa9f
sanbi-uwc
parents:
5
diff
changeset
|
19 except: |
3938f90c9d91
planemo upload for repository https://github.com/zipho/novo_align commit 4a89d4d866533a93706ceb29077d2e9bda69aa9f
sanbi-uwc
parents:
5
diff
changeset
|
20 print("Error running the nova-align", file=sys.stderr) |
5
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
21 |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
22 def newSplit(value): |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
23 lex = shlex.shlex(value) |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
24 lex.quotes = '"' |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
25 lex.whitespace_split = True |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
26 lex.commenters = '' |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
27 return list(lex) |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
28 |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
29 def main(): |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
30 parser = argparse.ArgumentParser(description="Generate a BAM file from the Novo Align tool") |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
31 parser.add_argument('output_filename') |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
32 parser.add_argument('--index_filename') |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
33 parser.add_argument('--forward_filename') |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
34 parser.add_argument('--reverse_filename') |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
35 args = parser.parse_args() |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
36 |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
37 #a dirty way of referencing the file |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
38 index_file_path = args.index_filename + "/" + args.index_filename.split("/")[-1] |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
39 novo_align(args.output_filename, index_file_path, args.forward_filename, args.reverse_filename) |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
40 |
d51c5af7a8fe
planemo upload for repository https://github.com/zipho/novo_align commit c3aee79679931e7a609fea1dade8973c97fb0d21
sanbi-uwc
parents:
diff
changeset
|
41 if __name__ == "__main__": main() |