annotate tools/mira4/mira4.py @ 0:6a88b42ce6b9 draft

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