Mercurial > repos > refinery-platform > qualimap2_bamqc
annotate qualimap_bamqc.py @ 5:f18b4224ff36 draft
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit d3e3edd55f03bf4f5337c2eac874d5579007eec2
author | refinery-platform |
---|---|
date | Mon, 30 Jul 2018 12:12:18 -0400 |
parents | a6d048668f7f |
children | a2438e0f1bbf |
rev | line source |
---|---|
0
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
1 #!/usr/bin/env python |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
2 from __future__ import print_function |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
3 import argparse |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
4 import os |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
5 from subprocess import check_call, CalledProcessError |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
6 import shutil |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
7 import sys |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
8 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
9 QUALIMAP_OUPUT_DIR = "qualimap_results" |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
10 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
11 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
12 def qualimap_bamqc(bam_filename, jv_mem_size): |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
13 qualimap_command = [ |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
14 "qualimap", "bamqc", |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
15 "-bam " + bam_filename, |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
16 "-outdir " + QUALIMAP_OUPUT_DIR, |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
17 "--java-mem-size=" + jv_mem_size |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
18 ] |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
19 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
20 try: |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
21 check_call(qualimap_command) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
22 except CalledProcessError: |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
23 print("Error running the qualimap bamqc", file=sys.stderr) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
24 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
25 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
26 def main(): |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
27 parser = argparse.ArgumentParser( |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
28 description="Generate Bam Quality Statistics" |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
29 ) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
30 parser.add_argument('--input_file') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
31 parser.add_argument('--out_dir') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
32 parser.add_argument('--out_results') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
33 parser.add_argument('--out_zip') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
34 parser.add_argument('--java_mem_size') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
35 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
36 args = parser.parse_args() |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
37 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
38 qualimap_bamqc(args.input_file, args.java_mem_size) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
39 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
40 shutil.make_archive( |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
41 'raw_data_qualimapReport', |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
42 'zip', |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
43 os.path.join(QUALIMAP_OUPUT_DIR, 'raw_data_qualimapReport') |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
44 ) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
45 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
46 shutil.move("raw_data_qualimapReport.zip", args.out_zip) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
47 shutil.move( |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
48 os.path.join(QUALIMAP_OUPUT_DIR, "genome_results.txt"), |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
49 args.out_results |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
50 ) |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
51 |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
52 if __name__ == "__main__": |
a6d048668f7f
planemo upload for repository https://github.com/refinery-platform/qualimap2 commit 88b5467f336ac3b6b5d3a6e824273a183e5184b6
refinery-platform
parents:
diff
changeset
|
53 main() |