Mercurial > repos > peterjc > mira4_assembler
annotate tools/mira4_0/mira4.py @ 39:bbf14bb9607b draft default tip
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
author | peterjc |
---|---|
date | Mon, 03 Jun 2019 13:29:00 -0400 |
parents | cee8f9005e43 |
children |
rev | line source |
---|---|
25 | 1 #!/usr/bin/env python |
38
cee8f9005e43
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 206259620376b322fc8ed99a6efdd3712f38764b
peterjc
parents:
35
diff
changeset
|
2 """A simple wrapper script to call MIRA and collect its output.""" |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
3 |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
4 from __future__ import print_function |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
5 |
25 | 6 import os |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
7 import shutil |
25 | 8 import subprocess |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
9 import sys |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
10 import tempfile |
25 | 11 import time |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
12 |
25 | 13 from optparse import OptionParser |
14 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
15 # Do we need any PYTHONPATH magic? |
25 | 16 from mira4_make_bam import make_bam |
17 | |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
18 WRAPPER_VER = "0.0.11" # Keep in sync with the XML file |
25 | 19 |
20 | |
21 def get_version(mira_binary): | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
22 """Run MIRA to find its version number.""" |
25 | 23 # At the commend line I would use: mira -v | head -n 1 |
24 # however there is some pipe error when doing that here. | |
25 cmd = [mira_binary, "-v"] | |
26 try: | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
27 child = subprocess.Popen( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
28 cmd, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
29 universal_newlines=True, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
30 stdout=subprocess.PIPE, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
31 stderr=subprocess.STDOUT, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
32 ) |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
33 except Exception as err: |
25 | 34 sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) |
35 sys.exit(1) | |
36 ver, tmp = child.communicate() | |
37 del child | |
38 return ver.split("\n", 1)[0].strip() | |
39 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
40 |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
41 # Parse Command Line |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
42 usage = ( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
43 """Galaxy MIRA4 wrapper script v%s - use as follows: |
25 | 44 |
45 $ python mira4.py ... | |
46 | |
47 This will run the MIRA binary and collect its output files as directed. | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
48 """ |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
49 % WRAPPER_VER |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
50 ) |
25 | 51 parser = OptionParser(usage=usage) |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
52 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
53 "-m", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
54 "--manifest", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
55 dest="manifest", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
56 default=None, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
57 metavar="FILE", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
58 help="MIRA manifest filename", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
59 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
60 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
61 "--maf", dest="maf", default="-", metavar="FILE", help="MIRA MAF output filename" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
62 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
63 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
64 "--bam", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
65 dest="bam", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
66 default="-", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
67 metavar="FILE", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
68 help="Unpadded BAM output filename", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
69 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
70 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
71 "--fasta", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
72 dest="fasta", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
73 default="-", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
74 metavar="FILE", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
75 help="Unpadded FASTA output filename", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
76 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
77 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
78 "--log", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
79 dest="log", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
80 default="-", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
81 metavar="FILE", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
82 help="MIRA logging output filename", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
83 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
84 parser.add_option( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
85 "-v", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
86 "--version", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
87 dest="version", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
88 default=False, |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
89 action="store_true", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
90 help="Show version and quit", |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
91 ) |
25 | 92 options, args = parser.parse_args() |
93 manifest = options.manifest | |
94 out_maf = options.maf | |
95 out_bam = options.bam | |
96 out_fasta = options.fasta | |
97 out_log = options.log | |
98 | |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
99 if "MIRA4" in os.environ: |
25 | 100 mira_path = os.environ["MIRA4"] |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
101 mira_binary = os.path.join(mira_path, "mira") |
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
102 if not os.path.isfile(mira_binary): |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
103 sys.exit( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
104 "Missing mira under $MIRA4, %r\nFolder contained: %s" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
105 % (mira_binary, ", ".join(os.listdir(mira_path))) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
106 ) |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
107 mira_convert = os.path.join(mira_path, "miraconvert") |
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
108 if not os.path.isfile(mira_convert): |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
109 sys.exit( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
110 "Missing miraconvert under $MIRA4, %r\nFolder contained: %s" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
111 % (mira_convert, ", ".join(os.listdir(mira_path))) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
112 ) |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
113 else: |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
114 sys.stderr.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
115 "DEBUG: Since $MIRA4 is not set, assuming mira binaries are on $PATH.\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
116 ) |
35
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
117 mira_path = None |
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
118 mira_binary = "mira" |
259891fce7fd
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit e4c56df75150c82d3e9c4ac487c4209108e52412
peterjc
parents:
34
diff
changeset
|
119 mira_convert = "miraconvert" |
25 | 120 |
121 mira_ver = get_version(mira_binary) | |
122 if not mira_ver.strip().startswith("4.0"): | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
123 sys.exit("This wrapper is for MIRA V4.0, not:\n%s\n%s" % (mira_ver, mira_binary)) |
25 | 124 mira_convert_ver = get_version(mira_convert) |
125 if not mira_convert_ver.strip().startswith("4.0"): | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
126 sys.exit("This wrapper is for MIRA V4.0, not:\n%s\n%s" % (mira_ver, mira_convert)) |
25 | 127 if options.version: |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
128 print("%s, MIRA wrapper version %s" % (mira_ver, WRAPPER_VER)) |
25 | 129 if mira_ver != mira_convert_ver: |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
130 print("WARNING: miraconvert %s" % mira_convert_ver) |
25 | 131 sys.exit(0) |
132 | |
133 if not manifest: | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
134 sys.exit("Manifest is required") |
25 | 135 elif not os.path.isfile(manifest): |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
136 sys.exit("Missing input MIRA manifest file: %r" % manifest) |
25 | 137 |
138 | |
139 try: | |
140 threads = int(os.environ.get("GALAXY_SLOTS", "1")) | |
141 except ValueError: | |
142 threads = 1 | |
143 assert 1 <= threads, threads | |
144 | |
145 | |
146 def override_temp(manifest): | |
147 """Override ``-DI:trt=/tmp`` in manifest with environment variable. | |
148 | |
149 Currently MIRA 4 does not allow envronment variables like ``$TMP`` | |
150 inside the manifest, which is a problem if you need to override | |
151 the default at run time. | |
152 | |
153 The tool XML will ``/tmp`` and we replace that here with | |
154 ``tempfile.gettempdir()`` which will respect $TMPDIR, $TEMP, $TMP | |
155 as explained in the Python standard library documentation: | |
156 http://docs.python.org/2/library/tempfile.html#tempfile.tempdir | |
157 | |
158 By default MIRA 4 would write its temporary files within the output | |
159 folder, which is a problem if that is a network drive. | |
160 """ | |
161 handle = open(manifest, "r") | |
162 text = handle.read() | |
163 handle.close() | |
164 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
165 # At time of writing, this is at the end of a file, |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
166 # but could be followed by a space in future... |
25 | 167 text = text.replace("-DI:trt=/tmp", "-DI:trt=" + tempfile.gettempdir()) |
168 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
169 # Want to try to ensure this gets written to disk before MIRA attempts |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
170 # to open it - any networked file system may impose a delay... |
25 | 171 handle = open(manifest, "w") |
172 handle.write(text) | |
173 handle.flush() | |
174 os.fsync(handle.fileno()) | |
175 handle.close() | |
176 | |
177 | |
178 def log_manifest(manifest): | |
179 """Write the manifest file to stderr.""" | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
180 sys.stderr.write("\n%s\nManifest file\n%s\n" % ("=" * 60, "=" * 60)) |
25 | 181 with open(manifest) as h: |
182 for line in h: | |
183 sys.stderr.write(line) | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
184 sys.stderr.write("\n%s\nEnd of manifest\n%s\n" % ("=" * 60, "=" * 60)) |
25 | 185 |
186 | |
187 def collect_output(temp, name, handle): | |
38
cee8f9005e43
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 206259620376b322fc8ed99a6efdd3712f38764b
peterjc
parents:
35
diff
changeset
|
188 """Move files to the output filenames (global variables).""" |
25 | 189 f = "%s/%s_assembly/%s_d_results" % (temp, name, name) |
190 if not os.path.isdir(f): | |
191 log_manifest(manifest) | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
192 sys.exit("Missing output folder") |
25 | 193 if not os.listdir(f): |
194 log_manifest(manifest) | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
195 sys.exit("Empty output folder") |
25 | 196 missing = [] |
197 | |
198 old_maf = "%s/%s_out.maf" % (f, name) | |
199 if not os.path.isfile(old_maf): | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
200 # Triggered extractLargeContigs.sh? |
25 | 201 old_maf = "%s/%s_LargeContigs_out.maf" % (f, name) |
202 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
203 # De novo or single strain mapping, |
25 | 204 old_fasta = "%s/%s_out.unpadded.fasta" % (f, name) |
205 ref_fasta = "%s/%s_out.padded.fasta" % (f, name) | |
206 if not os.path.isfile(old_fasta): | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
207 # Mapping (StrainX versus reference) or de novo |
25 | 208 old_fasta = "%s/%s_out_StrainX.unpadded.fasta" % (f, name) |
209 ref_fasta = "%s/%s_out_StrainX.padded.fasta" % (f, name) | |
210 if not os.path.isfile(old_fasta): | |
211 old_fasta = "%s/%s_out_ReferenceStrain.unpadded.fasta" % (f, name) | |
212 ref_fasta = "%s/%s_out_ReferenceStrain.padded.fasta" % (f, name) | |
213 | |
214 missing = False | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
215 for old, new in [(old_maf, out_maf), (old_fasta, out_fasta)]: |
25 | 216 if not os.path.isfile(old): |
217 missing = True | |
218 elif not new or new == "-": | |
219 handle.write("Ignoring %s\n" % old) | |
220 else: | |
221 handle.write("Capturing %s\n" % old) | |
222 shutil.move(old, new) | |
223 if missing: | |
224 log_manifest(manifest) | |
225 sys.stderr.write("Contents of %r:\n" % f) | |
226 for filename in sorted(os.listdir(f)): | |
227 sys.stderr.write("%s\n" % filename) | |
228 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
229 # For mapping mode, probably most people would expect a BAM file |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
230 # using the reference FASTA file... |
25 | 231 if out_bam and out_bam != "-": |
232 if out_maf and out_maf != "-": | |
233 msg = make_bam(mira_convert, out_maf, ref_fasta, out_bam, handle) | |
234 else: | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
235 # Not collecting the MAF file, use original location |
25 | 236 msg = make_bam(mira_convert, old_maf, ref_fasta, out_bam, handle) |
237 if msg: | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
238 sys.exit(msg) |
25 | 239 |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
240 |
25 | 241 def clean_up(temp, name): |
38
cee8f9005e43
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 206259620376b322fc8ed99a6efdd3712f38764b
peterjc
parents:
35
diff
changeset
|
242 """Remove temp files.""" |
25 | 243 folder = "%s/%s_assembly" % (temp, name) |
244 if os.path.isdir(folder): | |
245 shutil.rmtree(folder) | |
246 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
247 |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
248 # TODO - Run MIRA in /tmp or a configurable directory? |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
249 # Currently Galaxy puts us somewhere safe like: |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
250 # /opt/galaxy-dist/database/job_working_directory/846/ |
25 | 251 temp = "." |
252 | |
253 name = "MIRA" | |
254 | |
255 override_temp(manifest) | |
256 | |
257 start_time = time.time() | |
258 cmd_list = [mira_binary, "-t", str(threads), manifest] | |
259 cmd = " ".join(cmd_list) | |
260 | |
261 assert os.path.isdir(temp) | |
262 d = "%s_assembly" % name | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
263 # This can fail on my development machine if stale folders exist |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
264 # under Galaxy's .../database/job_working_directory/ tree: |
25 | 265 assert not os.path.isdir(d), "Path %r already exists:\n%s" % (d, os.path.abspath(d)) |
266 try: | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
267 # Check path access |
25 | 268 os.mkdir(d) |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
269 except Exception as err: |
25 | 270 log_manifest(manifest) |
271 sys.stderr.write("Error making directory %s\n%s" % (d, err)) | |
272 sys.exit(1) | |
273 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
274 # print(os.path.abspath(".")) |
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
275 # print(cmd) |
25 | 276 |
277 if out_log and out_log != "-": | |
278 handle = open(out_log, "w") | |
279 else: | |
280 handle = open(os.devnull, "w") | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
281 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
282 "======================== MIRA manifest (instructions) ========================\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
283 ) |
25 | 284 m = open(manifest, "rU") |
285 for line in m: | |
286 handle.write(line) | |
287 m.close() | |
288 del m | |
289 handle.write("\n") | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
290 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
291 "============================ Starting MIRA now ===============================\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
292 ) |
25 | 293 handle.flush() |
294 try: | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
295 # Run MIRA |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
296 child = subprocess.Popen(cmd_list, stdout=handle, stderr=subprocess.STDOUT) |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
297 except Exception as err: |
25 | 298 log_manifest(manifest) |
299 sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err)) | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
300 # TODO - call clean up? |
25 | 301 handle.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err)) |
302 handle.close() | |
303 sys.exit(1) | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
304 # Use .communicate as can get deadlocks with .wait(), |
25 | 305 stdout, stderr = child.communicate() |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
306 assert not stdout and not stderr # Should be empty as sent to handle |
25 | 307 run_time = time.time() - start_time |
308 return_code = child.returncode | |
309 handle.write("\n") | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
310 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
311 "============================ MIRA has finished ===============================\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
312 ) |
25 | 313 handle.write("MIRA took %0.2f hours\n" % (run_time / 3600.0)) |
314 if return_code: | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
315 print("MIRA took %0.2f hours" % (run_time / 3600.0)) |
25 | 316 handle.write("Return error code %i from command:\n" % return_code) |
317 handle.write(cmd + "\n") | |
318 handle.close() | |
319 clean_up(temp, name) | |
320 log_manifest(manifest) | |
31
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
321 sys.stderr.write("Return error code %i from command:\n" % return_code) |
fd95aaef8818
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit bc3d484c5cd68ddcf456db2fff489d584aa2034c
peterjc
parents:
25
diff
changeset
|
322 sys.stderr.write(cmd + "\n") |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
323 sys.exit(return_code) |
25 | 324 handle.flush() |
325 | |
326 if os.path.isfile("MIRA_assembly/MIRA_d_results/ec.log"): | |
327 handle.write("\n") | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
328 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
329 "====================== Extract Large Contigs failed ==========================\n" # noqa: E501 |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
330 ) |
25 | 331 e = open("MIRA_assembly/MIRA_d_results/ec.log", "rU") |
332 for line in e: | |
333 handle.write(line) | |
334 e.close() | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
335 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
336 "============================ (end of ec.log) =================================\n" # noqa: E501 |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
337 ) |
25 | 338 handle.flush() |
339 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
340 # print("Collecting output...") |
25 | 341 start_time = time.time() |
342 collect_output(temp, name, handle) | |
343 collect_time = time.time() - start_time | |
39
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
344 handle.write( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
345 "MIRA took %0.2f hours; collecting output %0.2f minutes\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
346 % (run_time / 3600.0, collect_time / 60.0) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
347 ) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
348 print( |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
349 "MIRA took %0.2f hours; collecting output %0.2f minutes\n" |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
350 % (run_time / 3600.0, collect_time / 60.0) |
bbf14bb9607b
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
peterjc
parents:
38
diff
changeset
|
351 ) |
25 | 352 |
353 if os.path.isfile("MIRA_assembly/MIRA_d_results/ec.log"): | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
354 # Treat as an error, but doing this AFTER collect_output |
25 | 355 sys.stderr.write("Extract Large Contigs failed\n") |
356 handle.write("Extract Large Contigs failed\n") | |
357 handle.close() | |
358 sys.exit(1) | |
359 | |
32
56b421d59805
planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira4_0 commit fd979d17340cde155de176604744831d9597c6b6
peterjc
parents:
31
diff
changeset
|
360 # print "Cleaning up..." |
25 | 361 clean_up(temp, name) |
362 | |
363 handle.write("\nDone\n") | |
364 handle.close() | |
365 print("Done") |