Mercurial > repos > bgruening > bismark
annotate bismark_methylation_extractor.py @ 21:120b7b35e442 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
author | bgruening |
---|---|
date | Thu, 22 Apr 2021 17:05:46 +0000 |
parents | ff6ee551b153 |
children | 8c191acde702 |
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 logging |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
5 import math |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
6 import os |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
7 import re |
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 import zipfile |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
13 from glob import glob |
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 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
16 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
|
17 logger.critical(msg) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
18 sys.exit(1) |
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 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
21 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:
20
diff
changeset
|
22 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
|
23 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
|
24 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
25 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
26 def zipper(dir, zip_file): |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
27 output_files_regex = re.compile("^(Non_)?C[pH][GH]_.*") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
28 bedgraph_regex = re.compile(".*bedGraph.gz") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
29 zip = zipfile.ZipFile(zip_file, "w", compression=zipfile.ZIP_DEFLATED) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
30 root_len = len(os.path.abspath(dir)) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
31 for root, dirs, files in os.walk(dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
32 archive_root = os.path.abspath(root)[root_len:] |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
33 for f in files: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
34 if re.search(output_files_regex, f) or re.search(bedgraph_regex, f): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
35 fullpath = os.path.join(root, f) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
36 archive_name = os.path.join(archive_root, f) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
37 zip.write(fullpath, archive_name, zipfile.ZIP_DEFLATED) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
38 zip.close() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
39 return zip_file |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
40 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
41 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
42 def build_genome_dir(genome_file): |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
43 tmp_genome_dir = tempfile.mkdtemp(prefix="tmp") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
44 genome_path = os.path.join( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
45 tmp_genome_dir, ".".join(os.path.split(genome_file)[1].split(".")[:-1]) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
46 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
47 try: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
48 # Create a hard link pointing to genome_file named 'genome_path'.fa. |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
49 os.symlink(genome_file, genome_path + ".fa") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
50 except Exception as e: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
51 if os.path.exists(tmp_genome_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
52 shutil.rmtree(tmp_genome_dir) |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
53 stop_err("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
|
54 return tmp_genome_dir |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
55 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
56 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
57 def __main__(): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
58 # Parse Command Line |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
59 parser = argparse.ArgumentParser( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
60 description="Wrapper for the bismark methylation caller." |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
61 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
62 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
63 # input options |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
64 parser.add_argument("--infile", help="Input file in SAM or BAM format.") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
65 parser.add_argument("--single-end", dest="single_end", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
66 parser.add_argument("--paired-end", dest="paired_end", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
67 |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
68 parser.add_argument("--multicore", dest="multicore", type=int, default=1) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
69 parser.add_argument("--splitting_report", dest="splitting_report") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
70 parser.add_argument("--mbias_report", dest="mbias_report") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
71 parser.add_argument("--cytosine_report", dest="cytosine_report") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
72 parser.add_argument("--genome_file", dest="genome_file") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
73 parser.add_argument("--cx_context", action="store_true") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
74 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
75 parser.add_argument("--comprehensive", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
76 parser.add_argument("--merge-non-cpg", dest="merge_non_cpg", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
77 parser.add_argument("--no-overlap", dest="no_overlap", action="store_true") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
78 parser.add_argument("--compress", dest="compress") |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
79 parser.add_argument("--ignore", dest="ignore", type=int) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
80 parser.add_argument("--ignore_r2", dest="ignore_r2", type=int) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
81 parser.add_argument("--ignore_3prime", dest="ignore_3prime", type=int) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
82 parser.add_argument("--ignore_3prime_r2", dest="ignore_3prime_r2", type=int) |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
83 parser.add_argument( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
84 "--log_report", dest="log_report", metavar="log_filename", type=str |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
85 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
86 args = parser.parse_args() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
87 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
88 logger = logging.getLogger("bismark_methylation_extractor_wrapper") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
89 logger.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
90 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
|
91 if args.log_report: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
92 ch.setLevel(logging.WARNING) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
93 handler = logging.FileHandler(args.log_report) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
94 handler.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
95 logger.addHandler(handler) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
96 else: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
97 ch.setLevel(logging.DEBUG) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
98 logger.addHandler(ch) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
99 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
100 # Build methylation extractor command |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
101 output_dir = tempfile.mkdtemp() |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
102 cmd = ["bismark_methylation_extractor", "--no_header", "-o", output_dir] |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
103 # Set up all options |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
104 if args.multicore > 3: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
105 # divide multicore by 3 here since bismark will spawn ~3 jobs. |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
106 cmd.extend(["--multicore", str(int(math.floor(args.multicore / 3)))]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
107 if args.single_end: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
108 cmd.append("--single-end") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
109 else: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
110 cmd.append("--paired-end") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
111 if args.no_overlap: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
112 cmd.append("--no_overlap") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
113 if args.ignore: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
114 cmd.extend(["--ignore", str(args.ignore)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
115 if args.ignore_r2: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
116 cmd.extend(["--ignore_r2", str(args.ignore_r2)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
117 if args.ignore_3prime: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
118 cmd.extend(["--ignore_3prime", str(args.ignore_3prime)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
119 if args.ignore_3prime_r2: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
120 cmd.extend(["--ignore_3prime_r2", str(args.ignore_3prime_r2)]) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
121 if args.comprehensive: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
122 cmd.append("--comprehensive") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
123 if args.merge_non_cpg: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
124 cmd.append("--merge_non_CpG") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
125 if args.splitting_report: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
126 cmd.append("--report") |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
127 tmp_genome_dir = None |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
128 if args.cytosine_report: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
129 tmp_genome_dir = build_genome_dir(args.genome_file) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
130 if args.cx_context: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
131 cmd.extend( |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
132 [ |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
133 "--bedGraph", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
134 "--CX_context", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
135 "--cytosine_report", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
136 "--CX_context", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
137 "--genome_folder", |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
138 tmp_genome_dir, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
139 ] |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
140 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
141 else: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
142 cmd.extend( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
143 ["--bedGraph", "--cytosine_report", "--genome_folder", tmp_genome_dir] |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
144 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
145 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
146 cmd.append(args.infile) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
147 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
148 # Run |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
149 logger.info("Methylation extractor run with: '%s'", " ".join(cmd)) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
150 prev_dir = os.getcwd() |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
151 os.chdir( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
152 output_dir |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
153 ) # needed due to a bug in bismark where the coverage file cannot be found |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
154 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
155 with process.stdout: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
156 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
|
157 exitcode = process.wait() |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
158 if exitcode != 0: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
159 stop_err( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
160 logger, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
161 "Bismark methylation extractor error (also check the log file if any)!\n%s" |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
162 % process.stderr, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
163 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
164 logger.info("Finished methylation extractor.") |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
165 # 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
|
166 logger.debug("Zip output files to '%s'.", args.compress) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
167 os.chdir(prev_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
168 zipper(output_dir, args.compress) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
169 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
170 # cytosine report |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
171 if args.cytosine_report: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
172 logger.debug("Collecting cytosine report.") |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
173 if args.cx_context: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
174 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
175 glob(os.path.join(output_dir, "*CX_report.txt"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
176 args.cytosine_report, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
177 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
178 else: |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
179 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
180 glob(os.path.join(output_dir, "*CpG_report.txt"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
181 args.cytosine_report, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
182 ) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
183 # splitting report |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
184 if args.splitting_report: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
185 logger.debug("Collecting splitting report.") |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
186 shutil.move( |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
187 glob(os.path.join(output_dir, "*_splitting_report.txt"))[0], |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
188 args.splitting_report, |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
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 if args.mbias_report: |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
191 logger.debug("Collecting M-Bias file.") |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
192 shutil.move(glob(os.path.join(output_dir, "*M-bias.txt"))[0], args.mbias_report) |
8
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
193 |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
194 # Clean up temp dirs |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
195 logger.debug("Cleanup temp dirs.") |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
196 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
|
197 shutil.rmtree(output_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
198 if tmp_genome_dir and os.path.exists(tmp_genome_dir): |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
199 shutil.rmtree(tmp_genome_dir) |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
200 logger.info("Done.") |
9bfe38410155
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 51299fa62f0566a4a897b1c149db564631282fff
bgruening
parents:
diff
changeset
|
201 |
21
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
202 |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
203 if __name__ == "__main__": |
120b7b35e442
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit 8fdc76a99a9dcf34549898a208317607afd18798"
bgruening
parents:
20
diff
changeset
|
204 __main__() |