changeset 6:3e7eca1f5d04 draft

MIRA wrapper v0.0.5 with <version_command> support and check for MIRA V3.4
author peterjc
date Fri, 01 Feb 2013 10:34:21 -0500
parents 216bf640baaf
children 4d3f94dfb857
files tools/sr_assembly/mira.py tools/sr_assembly/mira.txt tools/sr_assembly/mira.xml
diffstat 3 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/sr_assembly/mira.py	Wed May 09 12:40:06 2012 -0400
+++ b/tools/sr_assembly/mira.py	Fri Feb 01 10:34:21 2013 -0500
@@ -7,10 +7,38 @@
 import shutil
 import time
 
+WRAPPER_VER = "0.0.5" #Keep in sync with the XML file
+
 def stop_err(msg, err=1):
     sys.stderr.write(msg+"\n")
     sys.exit(err)
 
+
+def get_version():
+    """Run MIRA to find its version number"""
+    # At the commend line I would use: mira -v | head -n 1
+    # however there is some pipe error when doing that here.
+    try:
+        child = subprocess.Popen(["mira", "-v"],
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.STDOUT)
+    except Exception, err:
+        sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err))
+        sys.exit(1)
+    ver, tmp = child.communicate()
+    del child
+    return ver.split("\n", 1)[0]
+
+
+mira_ver = get_version()
+if "V3.4." not in mira_ver:
+    stop_err("This wrapper is for MIRA V3.4, not %s" % mira_ver)
+if "-v" in sys.argv:
+    print "MIRA wrapper version %s," % WRAPPER_VER
+    print mira_ver
+    sys.exit(0)
+
+
 def collect_output(temp, name):
     n3 = (temp, name, name, name)
     f = "%s/%s_assembly/%s_d_results" % (temp, name, name)
--- a/tools/sr_assembly/mira.txt	Wed May 09 12:40:06 2012 -0400
+++ b/tools/sr_assembly/mira.txt	Fri Feb 01 10:34:21 2013 -0500
@@ -41,6 +41,9 @@
        - The contig summary file (TCS file) was removed in MIRA 3.4
        - Report all missing output files (not just first missing one)
 v0.0.4 - Fix problem with backbone arguments inroduced in v0.0.3
+v0.0.5 - Implement the <version_command> tag to record the wrapper
+         version and the MIRA version being used.
+       - Check using MIRA 3.4 (later versions have a different API)
 
 
 Developers
--- a/tools/sr_assembly/mira.xml	Wed May 09 12:40:06 2012 -0400
+++ b/tools/sr_assembly/mira.xml	Fri Feb 01 10:34:21 2013 -0500
@@ -1,5 +1,6 @@
-<tool id="mira_assembler" name="Assemble with MIRA" version="0.0.4">
+<tool id="mira_assembler" name="Assemble with MIRA" version="0.0.5">
     <description>Takes Sanger, Roche, Illumina, and Ion Torrent data</description>
+	<version_command interpreter="python">mira.py -v</version_command>
 	<command interpreter="python">mira.py mira $out_fasta $out_qual $out_ace $out_caf $out_wig $out_log
 ##Give the wrapper script list of output filenames, then the mira command...
 mira --job=$job_method,$job_type,$job_quality