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