changeset 2:71afa65f444a draft default tip

v0.0.5 Internal changes to command line handling
author peterjc
date Tue, 16 May 2017 09:24:18 -0400
parents 8945bad80f4a
children
files tools/samtools_idxstats/README.rst tools/samtools_idxstats/samtools_idxstats.py tools/samtools_idxstats/samtools_idxstats.xml tools/samtools_idxstats/tool_dependencies.xml
diffstat 4 files changed, 24 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/tools/samtools_idxstats/README.rst	Wed May 13 10:35:50 2015 -0400
+++ b/tools/samtools_idxstats/README.rst	Tue May 16 09:24:18 2017 -0400
@@ -54,6 +54,8 @@
 v0.0.3  - Embed samtools citation in tool XML.
 v0.0.4  - Reorder XML elements (internal change only).
         - Planemo for Tool Shed upload (``.shed.yml``, internal change only).
+v0.0.5  - Use ``<command detect_errors="aggressive">`` (internal change only).
+        - Single quote command line arguments (internal change only).
 ======= ======================================================================
 
 
@@ -68,17 +70,17 @@
 Planemo commands (which requires you have set your Tool Shed access details in
 ``~/.planemo.yml`` and that you have access rights on the Tool Shed)::
 
-    $ planemo shed_upload --shed_target testtoolshed --check_diff ~/repositories/pico_galaxy/tools/samtools_idxstats/
+    $ planemo shed_update -t testtoolshed --check_diff tools/samtools_idxstats/
     ...
 
 or::
 
-    $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/samtools_idxstats/
+    $ planemo shed_update -t toolshed --check_diff tools/samtools_idxstats/
     ...
 
 To just build and check the tar ball, use::
 
-    $ planemo shed_upload --tar_only  ~/repositories/pico_galaxy/tools/samtools_idxstats/
+    $ planemo shed_upload --tar_only tools/samtools_idxstats/
     ...
     $ tar -tzf shed_upload.tar.gz 
     test-data/ex1.bam
--- a/tools/samtools_idxstats/samtools_idxstats.py	Wed May 13 10:35:50 2015 -0400
+++ b/tools/samtools_idxstats/samtools_idxstats.py	Tue May 16 09:24:18 2017 -0400
@@ -10,35 +10,30 @@
 runs "samtools idxstats" and captures the output to the desired
 tabular file.
 """
-import sys
+
 import os
-import subprocess
+import sys
 import tempfile
 
 if "-v" in sys.argv or "--version" in sys.argv:
-    #Galaxy seems to invert the order of the two lines
+    # Galaxy seems to invert the order of the two lines
     print "(Galaxy wrapper v0.0.2)"
     cmd = "samtools 2>&1 | grep -i ^Version"
     sys.exit(os.system(cmd))
 
-def sys_exit(msg, error_level=1):
-   """Print error message to stdout and quit with given error level."""
-   sys.stderr.write("%s\n" % msg)
-   sys.exit(error_level)
-
 if len(sys.argv) != 4:
-   sys_exit("Require three arguments: BAM, BAI, tabular filenames")
+    sys.exit("Require three arguments: BAM, BAI, tabular filenames")
 
 bam_filename, bai_filename, tabular_filename = sys.argv[1:]
 
 if not os.path.isfile(bam_filename):
-    sys_exit("Input BAM file not found: %s" % bam_filename)
+    sys.exit("Input BAM file not found: %s" % bam_filename)
 if not os.path.isfile(bai_filename):
     if bai_filename == "None":
-        sys_exit("Error: Galaxy did not index your BAM file")
-    sys_exit("Input BAI file not found: %s" % bai_filename)
+        sys.exit("Error: Galaxy did not index your BAM file")
+    sys.exit("Input BAI file not found: %s" % bai_filename)
 
-#Assign sensible names with real extensions, and setup symlinks:
+# Assign sensible names with real extensions, and setup symlinks:
 tmp_dir = tempfile.mkdtemp()
 bam_file = os.path.join(tmp_dir, "temp.bam")
 bai_file = os.path.join(tmp_dir, "temp.bam.bai")
@@ -48,14 +43,14 @@
 assert os.path.isfile(bai_file), bai_file
 assert os.path.isfile(bam_file + ".bai"), bam_file
 
-#Run samtools idxstats:
+# Run samtools idxstats:
 cmd = 'samtools idxstats "%s" > "%s"' % (bam_file, tabular_filename)
 return_code = os.system(cmd)
 
-#Remove the temp symlinks:
+# Remove the temp symlinks:
 os.remove(bam_file)
 os.remove(bai_file)
 os.rmdir(tmp_dir)
 
 if return_code:
-    sys_exit("Return code %i from command:\n%s" % (return_code, cmd))
+    sys.exit("Return code %i from command:\n%s" % (return_code, cmd))
--- a/tools/samtools_idxstats/samtools_idxstats.xml	Wed May 13 10:35:50 2015 -0400
+++ b/tools/samtools_idxstats/samtools_idxstats.xml	Tue May 16 09:24:18 2017 -0400
@@ -1,16 +1,14 @@
-<tool id="samtools_idxstats" name="BAM mapping statistics" version="0.0.4">
+<tool id="samtools_idxstats" name="BAM mapping statistics" version="0.0.5">
     <description>samtools idxstats</description>
     <requirements>
-        <requirement type="binary">samtools</requirement>
         <requirement type="package" version="0.1.19">samtools</requirement>
     </requirements>
-    <stdio>
-        <!-- Assume anything other than zero is an error -->
-        <exit_code range="1:" />
-        <exit_code range=":-1" />
-    </stdio>
-    <version_command interpreter="python">samtools_idxstats.py --version</version_command>
-    <command interpreter="python">samtools_idxstats.py "$input_bam" "${input_bam.metadata.bam_index}" "$out_tabular"</command>
+    <version_command>
+python $__tool_directory__/samtools_idxstats.py --version
+    </version_command>
+    <command  detect_errors="aggressive">
+python $__tool_directory__/samtools_idxstats.py '$input_bam' '${input_bam.metadata.bam_index}' '$out_tabular'
+    </command>
     <inputs>
         <param name="input_bam" type="data" format="bam" label="Input BAM file" />
     </inputs>
--- a/tools/samtools_idxstats/tool_dependencies.xml	Wed May 13 10:35:50 2015 -0400
+++ b/tools/samtools_idxstats/tool_dependencies.xml	Tue May 16 09:24:18 2017 -0400
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="samtools" version="0.1.19">
-        <repository changeset_revision="96aab723499f" name="package_samtools_0_1_19" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="c9bd782f5342" name="package_samtools_0_1_19" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>