Mercurial > repos > sanbi-uwc > qualimap2
annotate qualimap_bamqc.py @ 4:a19abfa30ca7 draft
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
author | sanbi-uwc |
---|---|
date | Tue, 05 Apr 2016 03:34:34 -0400 |
parents | d87d6c0c27f5 |
children | 465131fb4ce9 |
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 |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
8 |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
9 log = logging.getLogger(__name__) |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
10 |
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
11 |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
12 def qualimap_bamqc(bam_filename, genomecov_file, out_dir, jv_mem_size): |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
13 cmdline_str = "qualimap bamqc -bam {} -oc {} -outdir {} --outfile {} --java-mem-size={}".format(bam_filename, |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
14 genomecov_file, |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
15 out_dir, |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
16 jv_mem_size) |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
17 cmdline = new_split(cmdline_str) |
0
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 |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
23 |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
24 def new_split(value): |
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
25 lex = shlex.shlex(value) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
26 lex.quotes = '"' |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
27 lex.whitespace_split = True |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
28 lex.commenters = '' |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
29 return list(lex) |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
30 |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
31 |
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
32 def main(): |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
33 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
|
34 parser.add_argument('--input_file') |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
35 parser.add_argument('--out_genome_file', default="bam_stats.genomecov") |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
36 parser.add_argument('--out_dir', default="/tmp/bamstats") |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
37 parser.add_argument('--java_mem_size', default="8G") |
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
38 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
39 args = parser.parse_args() |
4
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
40 |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
41 qualimap_bamqc(args.input_file, args.out_genome_file, args.out_dir, args.java_mem_size) |
a19abfa30ca7
planemo upload for repository https://github.com/zipho/qualimap2 commit a84c585723c4499569d24c6cdaa7192113013159
sanbi-uwc
parents:
0
diff
changeset
|
42 |
0
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
43 |
d87d6c0c27f5
planemo upload for repository https://github.com/zipho/qualimap2 commit fb67f375d3ae592c62f73d647d8afa19b79037c0
sanbi-uwc
parents:
diff
changeset
|
44 if __name__ == "__main__": main() |