changeset 2:02572789ef6c draft

v0.0.4 Internal changes to command line handling
author peterjc
date Tue, 16 May 2017 09:29:05 -0400
parents 01f8967ce1e0
children 588c6ce25867
files tools/samtools_depad/README.rst tools/samtools_depad/samtools_depad.py tools/samtools_depad/samtools_depad.xml tools/samtools_depad/tool_dependencies.xml
diffstat 4 files changed, 27 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/tools/samtools_depad/README.rst	Wed May 13 10:15:02 2015 -0400
+++ b/tools/samtools_depad/README.rst	Tue May 16 09:29:05 2017 -0400
@@ -1,14 +1,14 @@
 Galaxy wrapper for samtools depad
 =================================
 
-This wrapper is copyright 2014-2015 by Peter Cock, The James Hutton Institute
+This wrapper is copyright 2014-2017 by Peter Cock, The James Hutton Institute
 (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved.
 See the licence text below.
 
 This is a wrapper for part of the command line samtools suite, v0.1.19
 
 This wrapper is available from the Galaxy Tool Shed at:
-http://toolshed.g2.bx.psu.edu/view/peterjc/samtools_idxstats
+http://toolshed.g2.bx.psu.edu/view/peterjc/samtools_depad
 
 
 Automated Installation
@@ -54,6 +54,8 @@
         - Removed unused imports from Python wrapper script.
 v0.0.3  - Reorder XML elements (internal change only).
         - Planemo for Tool Shed upload (``.shed.yml``, internal change only).
+v0.0.4  - Use ``<command detect_errors="aggressive">`` (internal change only).
+        - Single quote command line arguments (internal change only).
 ======= ======================================================================
 
 
@@ -67,17 +69,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_depad/
+    $ planemo shed_update -t testtoolshed --check_diff tools/samtools_depad/
     ...
 
 or::
 
-    $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/pico_galaxy/tools/samtools_depad/
+    $ planemo shed_update -t toolshed --check_diff tools/samtools_depad/
     ...
 
 To just build and check the tar ball, use::
 
-    $ planemo shed_upload --tar_only  ~/repositories/pico_galaxy/tools/samtools_depad/
+    $ planemo shed_upload --tar_only tools/samtools_depad/
     ...
     $ tar -tzf shed_upload.tar.gz
     test-data/sam_spec_padded.bam
--- a/tools/samtools_depad/samtools_depad.py	Wed May 13 10:15:02 2015 -0400
+++ b/tools/samtools_depad/samtools_depad.py	Tue May 16 09:29:05 2017 -0400
@@ -9,38 +9,34 @@
 
 Runs "samtools depad" and captures the output to the desired BAM file.
 """
+
+import os
 import sys
-import os
 
 if "-v" in sys.argv or "--version" in sys.argv:
-    #Galaxy seems to invert the order of the two lines
-    print "(Galaxy wrapper v0.0.2)"
+    # Galaxy seems to invert the order of the two lines
+    print "(Galaxy wrapper v0.0.4)"
     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) != 5:
-    sys_exit("Require four arguments: padded FASTA, SAM/BAM file, format (SAM or BAM), output BAM filenames")
+    sys.exit("Require four arguments: padded FASTA, SAM/BAM file, format (SAM or BAM), output BAM filenames")
 
 padded_ref, bam_filename, input_format, output_filename = sys.argv[1:]
 
 if not os.path.isfile(padded_ref):
-    sys_exit("Input padded reference FASTA file not found: %s" % padded_ref)
+    sys.exit("Input padded reference FASTA file not found: %s" % padded_ref)
 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 input_format.lower() not in ["sam", "bam"]:
-    sys_exit("Input format should be SAM or BAM, not %r" % input_format)
+    sys.exit("Input format should be SAM or BAM, not %r" % input_format)
 
-#Run samtools depad:
+# Run samtools depad:
 if input_format.lower() == "sam":
-    cmd = "samtools depad -S -T %s %s > %s" % (padded_ref, bam_filename, output_filename)
+    cmd = "samtools depad -S -T '%s' '%s' > '%s'" % (padded_ref, bam_filename, output_filename)
 else:
-    cmd = "samtools depad -T %s %s > %s" % (padded_ref, bam_filename, output_filename)
+    cmd = "samtools depad -T '%s' '%s' > '%s'" % (padded_ref, bam_filename, output_filename)
 return_code = os.system(cmd)
 
 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_depad/samtools_depad.xml	Wed May 13 10:15:02 2015 -0400
+++ b/tools/samtools_depad/samtools_depad.xml	Tue May 16 09:29:05 2017 -0400
@@ -1,16 +1,14 @@
-<tool id="samtools_depad" name="Depad SAM/BAM file" version="0.0.3">
+<tool id="samtools_depad" name="Depad SAM/BAM file" version="0.0.4">
     <description>samtools depad</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_depad.py --version</version_command>
-    <command interpreter="python">samtools_depad.py "$padded_ref" "$input_bam" "$input_bam.ext" "$output_bam"</command>
+    <version_command>
+python $__tool_directory__/samtools_depad.py --version
+    </version_command>
+    <command  detect_errors="aggressive">
+python $__tool_directory__/samtools_depad.py '$padded_ref' '$input_bam' '$input_bam.ext' '$output_bam'
+    </command>
     <inputs>
         <param name="padded_ref" type="data" format="fasta" label="Padded FASTA file (with gap characters)" />
         <param name="input_bam" type="data" format="sam,bam" label="Input SAM or BAM file (mapped against the padded FASTA)" />
--- a/tools/samtools_depad/tool_dependencies.xml	Wed May 13 10:15:02 2015 -0400
+++ b/tools/samtools_depad/tool_dependencies.xml	Tue May 16 09:29:05 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>