changeset 23:83a94a5038a7 draft

planemo upload for repository https://github.com/peterjc/galaxy_mira/tree/master/tools/mira3/ commit fd979d17340cde155de176604744831d9597c6b6
author peterjc
date Thu, 18 May 2017 13:35:41 -0400
parents a5a3460fafa6
children ad14a345f1b0
files tools/mira3/README.rst tools/mira3/mira.py tools/mira3/mira.xml tools/mira3/tool_dependencies.xml
diffstat 4 files changed, 38 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/tools/mira3/README.rst	Wed Feb 10 09:07:29 2016 -0500
+++ b/tools/mira3/README.rst	Thu May 18 13:35:41 2017 -0400
@@ -85,6 +85,9 @@
 v0.0.11 - Tool definition now embeds citation information.
         - Planemo for Tool Shed upload (``.shed.yml``, internal change only).
         - MIRA 3.4.1.1 dependency now declared via dedicated Tool Shed package.
+v0.0.12 - Python 3 compatible syntax (internal change only).
+        - Use ``<command detect_errors="aggressive">`` (internal change only).
+        - Single quote command line arguments (internal change only).
 ======= ======================================================================
 
 
--- a/tools/mira3/mira.py	Wed Feb 10 09:07:29 2016 -0500
+++ b/tools/mira3/mira.py	Thu May 18 13:35:41 2017 -0400
@@ -1,13 +1,16 @@
 #!/usr/bin/env python
 """A simple wrapper script to call MIRA and collect its output.
 """
+
+from __future__ import print_function
+
 import os
+import shutil
+import subprocess
 import sys
-import subprocess
-import shutil
 import time
 
-WRAPPER_VER = "0.0.5" #Keep in sync with the XML file
+WRAPPER_VER = "0.0.12"  # Keep in sync with the XML file
 
 
 def get_version():
@@ -19,7 +22,7 @@
         child = subprocess.Popen(cmd,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT)
-    except Exception, err:
+    except Exception as err:
         sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err))
         sys.exit(1)
     ver, tmp = child.communicate()
@@ -31,13 +34,12 @@
 if "V3.4." not in mira_ver:
     sys.exit("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
+    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)
     if not os.path.isdir(f):
         sys.exit("Missing output folder")
@@ -56,53 +58,55 @@
     if missing:
         sys.exit("Missing output files: %s" % ", ".join(missing))
 
+
 def clean_up(temp, name):
     folder = "%s/%s_assembly" % (temp, name)
     if os.path.isdir(folder):
         shutil.rmtree(folder)
 
-#TODO - Run MIRA in /tmp or a configurable directory?
-#Currently Galaxy puts us somewhere safe like:
-#/opt/galaxy-dist/database/job_working_directory/846/
+
+# TODO - Run MIRA in /tmp or a configurable directory?
+# Currently Galaxy puts us somewhere safe like:
+# /opt/galaxy-dist/database/job_working_directory/846/
 temp = "."
 name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8]
 
 start_time = time.time()
-cmd_list =sys.argv[8:]
+cmd_list = sys.argv[8:]
 cmd = " ".join(cmd_list)
 
 assert os.path.isdir(temp)
 d = "%s_assembly" % name
 assert not os.path.isdir(d), "Path %s already exists" % d
 try:
-    #Check path access
+    # Check path access
     os.mkdir(d)
-except Exception, err:
+except Exception as err:
     sys.stderr.write("Error making directory %s\n%s" % (d, err))
     sys.exit(1)
 
-#print os.path.abspath(".")
-#print cmd
+# print(os.path.abspath("."))
+# print(cmd)
 
 handle = open(out_log, "w")
 try:
-    #Run MIRA
+    # Run MIRA
     child = subprocess.Popen(cmd_list,
                              stdout=handle,
                              stderr=subprocess.STDOUT)
-except Exception, err:
+except Exception as err:
     sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err))
-    #TODO - call clean up?
+    # TODO - call clean up?
     handle.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err))
     handle.close()
     sys.exit(1)
-#Use .communicate as can get deadlocks with .wait(),
+# Use .communicate as can get deadlocks with .wait(),
 stdout, stderr = child.communicate()
-assert not stdout and not stderr #Should be empty as sent to handle
+assert not stdout and not stderr  # Should be empty as sent to handle
 run_time = time.time() - start_time
 return_code = child.returncode
 handle.write("\n\nMIRA took %0.2f minutes\n" % (run_time / 60.0))
-print "MIRA took %0.2f minutes" % (run_time / 60.0)
+print("MIRA took %0.2f minutes" % (run_time / 60.0))
 if return_code:
     handle.write("Return error code %i from command:\n" % return_code)
     handle.write(cmd + "\n")
@@ -113,10 +117,10 @@
     sys.exit(return_code)
 handle.close()
 
-#print "Collecting output..."
+# print "Collecting output..."
 collect_output(temp, name)
 
-#print "Cleaning up..."
+# print "Cleaning up..."
 clean_up(temp, name)
 
-print "Done"
+print("Done")
--- a/tools/mira3/mira.xml	Wed Feb 10 09:07:29 2016 -0500
+++ b/tools/mira3/mira.xml	Thu May 18 13:35:41 2017 -0400
@@ -1,11 +1,13 @@
-<tool id="mira_assembler" name="Assemble with MIRA v3.4" version="0.0.11">
+<tool id="mira_assembler" name="Assemble with MIRA v3.4" version="0.0.12">
     <description>Takes Sanger, Roche, Illumina, and Ion Torrent data</description>
     <requirements>
-        <requirement type="binary">mira</requirement>
         <requirement type="package" version="3.4.1.1">MIRA</requirement>
     </requirements>
-    <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
+    <version_command>
+python $__tool_directory__/mira.py -v
+    </version_command>
+    <command detect_errors="aggressive">
+python $__tool_directory__/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
 
--- a/tools/mira3/tool_dependencies.xml	Wed Feb 10 09:07:29 2016 -0500
+++ b/tools/mira3/tool_dependencies.xml	Thu May 18 13:35:41 2017 -0400
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="MIRA" version="3.4.1.1">
-        <repository changeset_revision="5424ac61b2d4" name="package_mira_3_4_1_1" owner="peterjc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="a50610140295" name="package_mira_3_4_1_1" owner="peterjc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>