changeset 0:2d303f2e09e0 draft

Uploaded v0.0.1, previously only on the Test Tool Shed
author peterjc
date Fri, 21 Nov 2014 06:37:20 -0500
parents
children 01f8967ce1e0
files test-data/sam_spec_padded.bam test-data/sam_spec_padded.depad.bam test-data/sam_spec_padded.fasta test-data/sam_spec_padded.sam tools/samtools_depad/README.rst tools/samtools_depad/samtools_depad.py tools/samtools_depad/samtools_depad.xml tools/samtools_depad/tool_dependencies.xml
diffstat 8 files changed, 227 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file test-data/sam_spec_padded.bam has changed
Binary file test-data/sam_spec_padded.depad.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sam_spec_padded.fasta	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,2 @@
+>ref
+AGCATGTTAGATAA--GATAGCTGTGCTAGTAGGCAGTCAGCGCCAT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sam_spec_padded.sam	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,10 @@
+@HD	VN:1.5	SO:coordinate
+@SQ	SN:ref	LN:47
+ref	516	ref	1	0	14M2D31M	*	0	0	AGCATGTTAGATAAGATAGCTGTGCTAGTAGGCAGTCAGCGCCAT	*
+r001	99	ref	7	30	14M1D3M	=	39	41	TTAGATAAAGGATACTG	*
+*	768	ref	8	30	1M	*	0	0	*	*	CT:Z:.;Warning;Note=Ref wrong?
+r002	0	ref	9	30	3S6M1D5M	*	0	0	AAAAGATAAGGATA	*	PT:Z:1;4;+;homopolymer
+r003	0	ref	9	30	5H6M	*	0	0	AGCTAA	*	NM:i:1
+r004	0	ref	18	30	6M14D5M	*	0	0	ATAGCTTCAGC	*
+r003	2064	ref	31	30	6H5M	*	0	0	TAGGC	*	NM:i:0
+r001	147	ref	39	30	9M	=	7	-41	CAGCGGCAT	*	NM:i:1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/samtools_depad/README.rst	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,102 @@
+Galaxy wrapper for samtools depad
+=================================
+
+This wrapper is copyright 2014 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
+
+
+Automated Installation
+======================
+
+This should be straightforward, Galaxy should automatically download and install
+samtools 0.1.19 if required.
+
+
+Manual Installation
+===================
+
+This expects samtools to be on the $PATH, and was tested using v0.1.19.
+
+To install the wrapper copy or move the following files under the Galaxy tools
+folder, e.g. in a ``tools/samtools_depad`` folder:
+
+* ``samtools_depad.xml`` (the Galaxy tool definition)
+* ``samtools_depad.py`` (the Python wrapper script)
+* ``README.rst`` (this file)
+
+You will also need to modify the ``tools_conf.xml`` file to tell Galaxy to offer
+the tool. Just add the line, perhaps under the NGS tools section::
+
+  <tool file="samtools_depad/samtools_depad.xml" />
+
+If you wish to run the unit tests, also add this to ``tools_conf.xml.sample``
+and move/copy the ``test-data`` files under Galaxy's ``test-data`` folder. Then::
+
+    $ ./run_functional_tests.sh -id samtools_depad
+
+That's it.
+
+
+History
+=======
+
+======= ======================================================================
+Version Changes
+------- ----------------------------------------------------------------------
+v0.0.1  - Initial public release
+======= ======================================================================
+
+
+Developers
+==========
+
+Development is on this GitHub repository:
+https://github.com/peterjc/pico_galaxy/tree/master/tools/samtools_depad
+
+For making the "Galaxy Tool Shed" http://toolshed.g2.bx.psu.edu/ tarball use
+the following command from the Galaxy root folder::
+
+    $ tar -czf samtools_depad.tar.gz tools/samtools_depad/README.rst tools/samtools_depad/samtools_depad.xml tools/samtools_depad/samtools_depad.py tools/samtools_depad/tool_dependencies.xml test-data/sam_spec_padded.fasta test-data/sam_spec_padded.sam test-data/sam_spec_padded.bam test-data/sam_spec_padded.depad.bam
+
+Check this worked::
+
+    $ tar -tzf samtools_depad.tar.gz
+    tools/samtools_depad/README.rst
+    tools/samtools_depad/samtools_depad.xml
+    tools/samtools_depad/samtools_depad.py
+    tools/samtools_depad/tool_dependencies.xml
+    test-data/sam_spec_padded.fasta
+    test-data/sam_spec_padded.sam
+    test-data/sam_spec_padded.bam
+    test-data/sam_spec_padded.depad.bam
+
+
+Licence (MIT)
+=============
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+NOTE: This is the licence for the Galaxy Wrapper only.
+samtools is available and licenced separately.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/samtools_depad/samtools_depad.py	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+"""Wrapper for "samtools depad" for use in Galaxy.
+
+This script takes exactly four command line arguments:
+ * Input padded reference FASTA file
+ * Input SAM/BAM filename
+ * Input format ("sam" or "bam")
+ * Output BAM filename
+
+Runs "samtools depad" and captures the output to the desired BAM file.
+"""
+import sys
+import os
+import subprocess
+import tempfile
+
+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.1)"
+    cmd = "samtools 2>&1 | grep -i ^Version"
+    sys.exit(os.system(cmd))
+
+def stop_err(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:
+   stop_err("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):
+    stop_err("Input padded reference FASTA file not found: %s" % padded_ref)
+if not os.path.isfile(bam_filename):
+    stop_err("Input BAM file not found: %s" % bam_filename)
+if input_format.lower() not in ["sam", "bam"]:
+    stop_err("Input format should be SAM or BAM, not %r" % input_format)
+
+#Run samtools depad:
+if input_format.lower() == "sam":
+    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)
+return_code = os.system(cmd)
+
+if return_code:
+    stop_err("Return code %i from command:\n%s" % (return_code, cmd))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/samtools_depad/samtools_depad.xml	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,59 @@
+<tool id="samtools_depad" name="Depad SAM/BAM file" version="0.0.1">
+    <description>samtools depad</description>
+    <requirements>
+        <requirement type="binary">samtools</requirement>
+        <requirement type="package" version="0.1.19">samtools</requirement>
+    </requirements>
+    <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>
+    <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)" />
+    </inputs>
+    <outputs>
+        <data name="output_bam" format="bam" label="$input_bam.name (depad)" />
+    </outputs>
+    <stdio>
+        <!-- Assume anything other than zero is an error -->
+        <exit_code range="1:" />
+        <exit_code range=":-1" />
+    </stdio>
+    <tests>
+        <test>
+            <param name="padded_ref" value="sam_spec_padded.fasta" ftype="fasta" />
+            <param name="input_bam" value="sam_spec_padded.bam" ftype="bam" />
+            <output name="output_bam" file="sam_spec_padded.depad.bam" ftype="bam" />
+        </test>
+        <test>
+            <param name="padded_ref" value="sam_spec_padded.fasta" ftype="fasta" />
+            <param name="input_bam" value="sam_spec_padded.sam" ftype="sam" />
+            <output name="output_bam" file="sam_spec_padded.depad.bam" ftype="bam" />
+        </test>
+    </tests>
+    <help>
+**What it does**
+
+This tool runs the ``samtools depad`` command in the SAMtools toolkit.
+
+Input is a *padded* FASTA file (with gaps represented by either ``*`` or ``-``
+characters) and a SAM or BAM file mapped against this *padded* FASTA file.
+
+The output is a new BAM file mapped against the *unpadded* FASTA file
+created by removing all gap characters from the sequence.
+
+**Citation**
+
+If you use this Galaxy tool in work leading to a scientific publication please
+cite:
+
+Heng Li et al (2009). The Sequence Alignment/Map format and SAMtools.
+Bioinformatics 25(16), 2078-9.
+http://dx.doi.org/10.1093/bioinformatics/btp352
+
+Peter J.A. Cock (2014), Galaxy wrapper for the samtools depad command
+http://toolshed.g2.bx.psu.edu/view/peterjc/samtools_depad
+
+This wrapper is available to install into other Galaxy Instances via the Galaxy
+Tool Shed at http://toolshed.g2.bx.psu.edu/view/peterjc/samtools_depad
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/samtools_depad/tool_dependencies.xml	Fri Nov 21 06:37:20 2014 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="samtools" version="0.1.19">
+        <repository changeset_revision="923adc89c666" name="package_samtools_0_1_19" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>