Mercurial > repos > sanbi-uwc > qualimap2
annotate qualimap_bamqc.py @ 0:d87d6c0c27f5 draft
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
author | sanbi-uwc |
---|---|
date | Wed, 30 Mar 2016 03:19:15 -0400 |
parents | |
children | a19abfa30ca7 |
rev | line source |
---|---|
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
2 from __future__ import print_function |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
3 import argparse |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
4 from subprocess import check_call, CalledProcessError |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
5 import shlex |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
6 import sys |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
7 import logging |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
8 log = logging.getLogger( __name__ ) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
9 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
10 def qualimap_bamqc( bam_filename, genomecov_file, out_dir, pdf_file, jv_mem_size): |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
11 #qualimap bamqc -bam R.bam.sorted_dedup.bam_realigned.bam -oc ./test.genomecov -outdir ./Kaust_kxdr/variants/qualimap/bamqc_report --outfile test.pdf --java-mem-size=16G |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
12 cmdline_str = "qualimap bamqc -bam {} -oc {} -outdir {} --outfile {} --java-mem-size={}".format( bam_filename, |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
13 genomecov_file, |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
14 out_dir, |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
15 pdf_file, |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
16 jv_mem_size) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
17 cmdline = newSplit(cmdline_str) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
18 try: |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
19 check_call(cmdline) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
20 except CalledProcessError: |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
21 print("Error running the qualimap bamqc", file=sys.stderr) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
22 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
23 def newSplit(value): |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
24 lex = shlex.shlex(value) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
25 lex.quotes = '"' |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
26 lex.whitespace_split = True |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
27 lex.commenters = '' |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
28 return list(lex) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
29 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
30 def main(): |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
31 parser = argparse.ArgumentParser(description="Generate Bam Quality Statistics") |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
32 parser.add_argument('--input_file') |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
33 parser.add_argument('--out_genome_file', default="bam_stats.genomecov") |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
34 parser.add_argument('--out_dir', default="/tmp/bamstats") |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
35 parser.add_argument('--out_pdf_file', default="bam_stats.pdf") |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
36 parser.add_argument('--java_mem_size', default="8G" ) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
37 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
38 args = parser.parse_args() |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
39 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
40 qualimap_bamqc(args.input_file, args.out_genome_file, args.out_dir, args.out_pdf_file, args.java_mem_size) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
41 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
42 if __name__ == "__main__": main() |