annotate qualimap_bamqc.py @ 37:407b6a65c867 draft

planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
author scottx611x
date Fri, 27 Jul 2018 11:28:26 -0400
parents 0e6aeed62025
children 6b6e03e84a42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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: 31
diff 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: 10
diff 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
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
9
34
7e359370b5a2 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 33
diff changeset
10 def qualimap_bamqc(bam_filename, genomecov_file, out_dir, jv_mem_size):
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
11 qualimap_command = [
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
12 "qualimap", "bamqc",
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
13 "-bam " + bam_filename,
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
14 "-oc " + genomecov_file,
34
7e359370b5a2 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 33
diff changeset
15 "-outdir " + out_dir,
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
16 "--java-mem-size=" + jv_mem_size
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
17 ]
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 try:
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
20 check_call(qualimap_command)
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
21 except CalledProcessError:
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
22 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
23
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 def main():
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
26 parser = argparse.ArgumentParser(
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
27 description="Generate Bam Quality Statistics"
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
28 )
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
29 parser.add_argument('--input_file')
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
30 parser.add_argument('--out_genome_file')
34
7e359370b5a2 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 33
diff changeset
31 parser.add_argument('--out_dir')
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
32 parser.add_argument('--java_mem_size')
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
33
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
34 args = parser.parse_args()
10
4e5e0a116434 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 2
diff changeset
35
37
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
36 output_dir = os.path.dirname(args.out_genome_file)
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
37
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
38 qualimap_bamqc(
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
39 args.input_file,
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
40 args.out_genome_file,
34
7e359370b5a2 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 33
diff changeset
41 args.out_dir,
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
42 args.java_mem_size
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
43 )
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
44
37
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
45 print(os.listdir(output_dir))
35
a3e9c80894dd planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 34
diff changeset
46
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
47 shutil.make_archive(
37
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
48 'raw_data_qualimapReport',
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
49 'zip',
34
7e359370b5a2 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 33
diff changeset
50 args.out_dir + '/raw_data_qualimapReport'
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
51 )
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
52
37
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
53 [
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
54 shutil.move(os.path.join(output_dir, file_name), file_name)
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
55 for file_name in [
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
56 "genome_results.txt",
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
57 "qualimapReport.html",
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
58 "raw_data_qualimapReport.zip"
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
59 ]
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
60 ]
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
61
407b6a65c867 planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 36
diff changeset
62 print(os.listdir(output_dir))
23
cefa83db3ebf planemo upload for repository https://github.com/scottx611x/qualimap2 commit dc78b7c4b1780b316ca4aba2be247969ac1100ec-dirty
scottx611x
parents: 10
diff changeset
63
1
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
64 if __name__ == "__main__":
716e406ce6ea planemo upload for repository https://github.com/scottx611x/qualimap2 commit 2e9620ea29d3a146e8669ec0037932d9a2135c79-dirty
scottx611x
parents:
diff changeset
65 main()