Mercurial > repos > bgruening > bismark
annotate bismark_wrapper.py @ 22:8c191acde702 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 3005cec91ca52f9d28aa2fe0bd4190555abafc35
author | bgruening |
---|---|
date | Tue, 01 Aug 2023 11:42:10 +0000 |
parents | 120b7b35e442 |
children |
rev | line source |
---|---|
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
2 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
3 import argparse |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
4 import fileinput |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
5 import logging |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
6 import math |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
7 import os |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
8 import shutil |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
9 import subprocess |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
10 import sys |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
11 import tempfile |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
12 from glob import glob |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
13 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
14 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
15 def stop_err(logger, msg): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
16 logger.critical(msg) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
17 sys.exit(1) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
18 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
19 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
20 def log_subprocess_output(logger, pipe): |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
21 for line in iter(pipe.readline, b""): |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
22 logger.debug(line.decode().rstrip()) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
23 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
24 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
25 def __main__(): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
26 # Parse Command Line |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
27 parser = argparse.ArgumentParser( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
28 description="Wrapper for the bismark bisulfite mapper." |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
29 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
30 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
31 "-p", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
32 "--num-threads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
33 dest="num_threads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
34 type=int, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
35 default=4, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
36 help="Use this many threads to align reads. The default is 4.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
37 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
38 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
39 # input options |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
40 parser.add_argument("--own-file", dest="own_file", help="") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
41 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
42 "-D", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
43 "--indexes-path", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
44 dest="index_path", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
45 help="Indexes directory; location of .ebwt and .fa files.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
46 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
47 parser.add_argument("-O", "--output", dest="output") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
48 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
49 parser.add_argument("--output-report-file", dest="output_report_file") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
50 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
51 "--suppress-header", dest="suppress_header", action="store_true" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
52 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
53 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
54 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
55 "--mate-paired", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
56 dest="mate_paired", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
57 action="store_true", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
58 help="Reads are mate-paired", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
59 default=False, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
60 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
61 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
62 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
63 "-1", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
64 "--mate1", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
65 dest="mate1", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
66 help="The forward reads file in Sanger FASTQ or FASTA format.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
67 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
68 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
69 "-2", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
70 "--mate2", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
71 dest="mate2", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
72 help="The reverse reads file in Sanger FASTQ or FASTA format.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
73 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
74 parser.add_argument("--sort-bam", dest="sort_bam", action="store_true") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
75 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
76 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
77 "--output-unmapped-reads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
78 dest="output_unmapped_reads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
79 help="Additional output file with unmapped reads (single-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
80 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
81 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
82 "--output-unmapped-reads-l", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
83 dest="output_unmapped_reads_l", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
84 help="File name for unmapped reads (left, paired-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
85 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
86 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
87 "--output-unmapped-reads-r", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
88 dest="output_unmapped_reads_r", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
89 help="File name for unmapped reads (right, paired-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
90 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
91 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
92 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
93 "--output-suppressed-reads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
94 dest="output_suppressed_reads", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
95 help="Additional output file with suppressed reads (single-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
96 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
97 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
98 "--output-suppressed-reads-l", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
99 dest="output_suppressed_reads_l", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
100 help="File name for suppressed reads (left, paired-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
101 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
102 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
103 "--output-suppressed-reads-r", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
104 dest="output_suppressed_reads_r", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
105 help="File name for suppressed reads (right, paired-end).", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
106 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
107 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
108 "--stdout", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
109 dest="output_stdout", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
110 help="File name for the standard output of bismark.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
111 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
112 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
113 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
114 "--single-paired", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
115 dest="single_paired", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
116 help="The single-end reads file in Sanger FASTQ or FASTA format.", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
117 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
118 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
119 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
120 "--fastq", action="store_true", help="Query filetype is in FASTQ format" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
121 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
122 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
123 "--fasta", action="store_true", help="Query filetype is in FASTA format" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
124 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
125 parser.add_argument("--phred64-quals", dest="phred64", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
126 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
127 "--non_directional", dest="non_directional", action="store_true" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
128 ) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
129 parser.add_argument("--pbat", dest="pbat", action="store_true") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
130 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
131 parser.add_argument("--skip-reads", dest="skip_reads", type=int) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
132 parser.add_argument("--score-min", dest="score_min", type=str) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
133 parser.add_argument("--qupto", type=int) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
134 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
135 # paired end options |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
136 parser.add_argument("-I", "--minins", dest="min_insert") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
137 parser.add_argument("-X", "--maxins", dest="max_insert") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
138 parser.add_argument("--no-mixed", dest="no_mixed", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
139 parser.add_argument("--no-discordant", dest="no_discordant", action="store_true") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
140 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
141 # parse general options |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
142 # default 20 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
143 parser.add_argument("--seed-len", dest="seed_len", type=int) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
144 # default 15 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
145 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
146 "--seed-extention-attempts", dest="seed_extention_attempts", type=int |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
147 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
148 # default 0 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
149 parser.add_argument("--seed-mismatches", dest="seed_mismatches", type=int) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
150 # default 2 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
151 parser.add_argument("--max-reseed", dest="max_reseed", type=int) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
152 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
153 """ |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
154 The number of megabytes of memory a given thread is given to store path |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
155 descriptors in --best mode. Best-first search must keep track of many paths |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
156 at once to ensure it is always extending the path with the lowest cumulative |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
157 cost. Bowtie tries to minimize the memory impact of the descriptors, but |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
158 they can still grow very large in some cases. If you receive an error message |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
159 saying that chunk memory has been exhausted in --best mode, try adjusting |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
160 this parameter up to dedicate more memory to the descriptors. Default: 512. |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
161 """ |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
162 parser.add_argument("--chunkmbs", type=int, default=512) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
163 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
164 args = parser.parse_args() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
165 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
166 logger = logging.getLogger("bismark_wrapper") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
167 logger.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
168 ch = logging.StreamHandler(sys.stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
169 if args.output_stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
170 ch.setLevel(logging.WARNING) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
171 handler = logging.FileHandler(args.output_stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
172 handler.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
173 logger.addHandler(handler) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
174 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
175 ch.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
176 logger.addHandler(ch) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
177 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
178 # Create bismark index if necessary. |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
179 index_dir = "" |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
180 tmp_index_dir = None |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
181 if args.own_file: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
182 logger.info( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
183 "Create a temporary index with the offered files from the user. " |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
184 "Utilizing the script: bismark_genome_preparation" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
185 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
186 tmp_index_dir = tempfile.mkdtemp() |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
187 index_path = os.path.join( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
188 tmp_index_dir, ".".join(os.path.split(args.own_file)[1].split(".")[:-1]) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
189 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
190 try: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
191 # Create a hard link pointing to args.own_file named 'index_path'.fa. |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
192 os.symlink(args.own_file, index_path + ".fa") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
193 except Exception as e: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
194 if os.path.exists(tmp_index_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
195 shutil.rmtree(tmp_index_dir) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
196 stop_err(logger, "Error in linking the reference database!\n%s" % e) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
197 # bismark_genome_preparation needs the complete path to the folder in which the database is stored |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
198 cmd_index = ["bismark_genome_preparation", "--bowtie2", tmp_index_dir] |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
199 try: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
200 logger.info("Generating index with: '%s'", " ".join(cmd_index)) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
201 process = subprocess.Popen( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
202 cmd_index, stdout=subprocess.PIPE, stderr=subprocess.STDOUT |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
203 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
204 with process.stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
205 log_subprocess_output(logger, process.stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
206 exitcode = process.wait() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
207 if exitcode != 0: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
208 raise Exception(process.stderr) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
209 except Exception as e: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
210 if os.path.exists(tmp_index_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
211 shutil.rmtree(tmp_index_dir) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
212 stop_err(logger, "Error indexing reference sequence!\n%s" % e) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
213 index_dir = tmp_index_dir |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
214 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
215 # bowtie path is the path to the index directory and the first path of the index file name |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
216 index_dir = os.path.dirname(args.index_path) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
217 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
218 # Build bismark command |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
219 tmp_bismark_dir = tempfile.mkdtemp() |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
220 output_dir = os.path.join(tmp_bismark_dir, "results") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
221 cmd = [ |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
222 "bismark", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
223 "--bam", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
224 "--temp_dir", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
225 tmp_bismark_dir, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
226 "-o", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
227 output_dir, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
228 "--quiet", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
229 ] |
17
aa9bf0f29a9f
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit d85012b50faac3234496bb51e2a29c2d8c113bde"
bgruening
parents:
16
diff
changeset
|
230 if not args.pbat: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
231 cmd.append("--gzip") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
232 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
233 if args.fasta: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
234 # the query input files (specified as mate1,mate2 or singles) are FastA |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
235 cmd.append("--fasta") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
236 elif args.fastq: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
237 cmd.append("--fastq") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
238 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
239 # alignment options |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
240 if args.num_threads > 2: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
241 # divide num_threads by 2 here since bismark will spawn 2 jobs with -p threads each |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
242 cmd.extend(["-p", str(int(math.floor(args.num_threads / 2)))]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
243 if args.seed_mismatches: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
244 cmd.extend(["-N", str(args.seed_mismatches)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
245 if args.seed_len: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
246 cmd.extend(["-L", str(args.seed_len)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
247 if args.seed_extention_attempts: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
248 cmd.extend(["-D", str(args.seed_extention_attempts)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
249 if args.max_reseed: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
250 cmd.extend(["-R", str(args.max_reseed)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
251 if args.no_discordant: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
252 cmd.append("--no-discordant") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
253 if args.no_mixed: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
254 cmd.append("--no-mixed") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
255 if args.skip_reads: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
256 cmd.extend(["--skip", str(args.skip_reads)]) |
16
a4504327c890
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit ce4520063ab4d016dd5c5680c0f03eae849b150c"
bgruening
parents:
10
diff
changeset
|
257 if args.score_min: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
258 cmd.extend(["--score_min", str(args.score_min)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
259 if args.qupto: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
260 cmd.extend(["--upto", "args.qupto"]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
261 if args.phred64: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
262 cmd.append("--phred64-quals") |
10
7bffcb6fc81d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 23685f742f0b5cd5de871c285d247d560485b11b
bgruening
parents:
8
diff
changeset
|
263 if args.non_directional: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
264 cmd.append("--non_directional") |
17
aa9bf0f29a9f
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit d85012b50faac3234496bb51e2a29c2d8c113bde"
bgruening
parents:
16
diff
changeset
|
265 if args.pbat: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
266 cmd.append("--pbat") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
267 if args.suppress_header: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
268 cmd.append("--sam-no-hd") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
269 if args.output_unmapped_reads or ( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
270 args.output_unmapped_reads_l and args.output_unmapped_reads_r |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
271 ): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
272 cmd.append("--un") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
273 if args.output_suppressed_reads or ( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
274 args.output_suppressed_reads_l and args.output_suppressed_reads_r |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
275 ): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
276 cmd.append("--ambiguous") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
277 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
278 cmd.append(index_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
279 # Set up the reads |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
280 if args.mate_paired: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
281 # paired-end reads library |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
282 cmd.extend( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
283 [ |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
284 "-1", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
285 args.mate1, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
286 "-2", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
287 args.mate2, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
288 "-I", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
289 str(args.min_insert), |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
290 "-X", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
291 str(args.max_insert), |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
292 ] |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
293 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
294 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
295 # single paired reads library |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
296 cmd.append(args.single_paired) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
297 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
298 # Run |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
299 try: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
300 logger.info("Running bismark with: '%s'", " ".join(cmd)) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
301 process = subprocess.Popen( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
302 args=cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
303 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
304 with process.stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
305 log_subprocess_output(logger, process.stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
306 exitcode = process.wait() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
307 if exitcode != 0: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
308 raise Exception(process.stderr) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
309 except Exception as e: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
310 stop_err(logger, "Error in running bismark!\n%s" % e) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
311 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
312 # collect and copy output files |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
313 if args.output_report_file: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
314 output_report_file = open(args.output_report_file, "w+") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
315 for line in fileinput.input(glob(os.path.join(output_dir, "*report.txt"))): |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
316 output_report_file.write(line) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
317 output_report_file.close() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
318 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
319 if args.output_suppressed_reads: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
320 if glob(os.path.join(output_dir, "*ambiguous_reads.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
321 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
322 glob(os.path.join(output_dir, "*ambiguous_reads.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
323 args.output_suppressed_reads, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
324 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
325 if args.output_suppressed_reads_l: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
326 if glob(os.path.join(output_dir, "*ambiguous_reads_1.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
327 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
328 glob(os.path.join(output_dir, "*ambiguous_reads_1.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
329 args.output_suppressed_reads_l, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
330 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
331 if args.output_suppressed_reads_r: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
332 if glob(os.path.join(output_dir, "*ambiguous_reads_2.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
333 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
334 glob(os.path.join(output_dir, "*ambiguous_reads_2.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
335 args.output_suppressed_reads_r, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
336 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
337 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
338 if args.output_unmapped_reads: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
339 if glob(os.path.join(output_dir, "*unmapped_reads.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
340 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
341 glob(os.path.join(output_dir, "*unmapped_reads.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
342 args.output_unmapped_reads, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
343 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
344 if args.output_unmapped_reads_l: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
345 if glob(os.path.join(output_dir, "*unmapped_reads_1.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
346 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
347 glob(os.path.join(output_dir, "*unmapped_reads_1.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
348 args.output_unmapped_reads_l, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
349 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
350 if args.output_unmapped_reads_r: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
351 if glob(os.path.join(output_dir, "*unmapped_reads_2.*")): |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
352 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
353 glob(os.path.join(output_dir, "*unmapped_reads_2.*"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
354 args.output_unmapped_reads_r, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
355 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
356 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
357 try: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
358 # merge all bam files |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
359 tmp_res = tempfile.NamedTemporaryFile(dir=output_dir).name |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
360 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
361 bam_files = glob(os.path.join(output_dir, "*.bam")) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
362 if len(bam_files) > 1: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
363 cmd = [ |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
364 "samtools", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
365 "merge", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
366 "-@", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
367 str(args.num_threads), |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
368 "-f", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
369 tmp_res |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
370 ] |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
371 [cmd.append(x) for x in bam_files] |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
372 logger.info("Merging bams with: '%s'", cmd) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
373 process = subprocess.Popen( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
374 args=cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
375 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
376 with process.stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
377 log_subprocess_output(logger, process.stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
378 exitcode = process.wait() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
379 if exitcode != 0: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
380 raise Exception(process.stderr) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
381 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
382 tmp_res = bam_files[0] |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
383 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
384 bam_path = "%s" % tmp_res |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
385 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
386 if os.path.exists(bam_path): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
387 if args.sort_bam: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
388 cmd = [ |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
389 "samtools", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
390 "sort", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
391 "-@", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
392 str(args.num_threads), |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
393 bam_path, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
394 "sorted_bam", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
395 ] |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
396 logger.info("Sorting bam with: '%s'", cmd) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
397 process = subprocess.Popen( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
398 args=cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
399 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
400 with process.stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
401 log_subprocess_output(logger, process.stdout) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
402 exitcode = process.wait() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
403 if exitcode != 0: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
404 raise Exception(process.stderr) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
405 shutil.move("sorted_bam.bam", args.output) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
406 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
407 shutil.move(bam_path, args.output) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
408 else: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
409 stop_err(logger, "BAM file no found:\n%s" % bam_path) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
410 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
411 except Exception as e: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
412 stop_err(logger, "Error in merging bam files!\n%s" % e) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
413 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
414 # Clean up temp dirs |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
415 if tmp_index_dir and os.path.exists(tmp_index_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
416 shutil.rmtree(tmp_index_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
417 if os.path.exists(tmp_bismark_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
418 shutil.rmtree(tmp_bismark_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
419 if os.path.exists(output_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
420 shutil.rmtree(output_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
421 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
422 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
423 if __name__ == "__main__": |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
18
diff
changeset
|
424 __main__() |