Mercurial > repos > peterjc > mummer
changeset 0:b0551f2a5986 draft
Uploaded v0.0.1, essentially a preview (previously only on the TestToolShed). No tests yet, no gnuplot or ps2pdf dependency yet.
author | peterjc |
---|---|
date | Mon, 27 Oct 2014 12:56:55 -0400 |
parents | |
children | b07aa90c95e6 |
files | tools/mummer/README.rst tools/mummer/mummer.py tools/mummer/mummer.xml tools/mummer/tool_dependencies.xml |
diffstat | 4 files changed, 264 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mummer/README.rst Mon Oct 27 12:56:55 2014 -0400 @@ -0,0 +1,106 @@ +Galaxy wrapper for EffectiveT3 v1.0.1 +===================================== + +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 the command suite MUMmer v3. + +S. Kurtz et al. (2004). +Versatile and open software for comparing large genomes. +Genome Biology (2004), 5:R12. +http://dx.doi.org/10.1186/gb-2004-5-2-r12 + +This wrapper is available to install into other Galaxy Instances via the Galaxy +Tool Shed at http://toolshed.g2.bx.psu.edu/view/peterjc/mummer + +Automated Installation +====================== + +This should be straightforward, Galaxy should automatically download and install +the MUMmer files. + +It also needs gnuplot, and ps2pdf. + + +Manual Installation +=================== + +This expects MUMmer binaries (at least ``mummer``, ``nucmer``, ``promer``, and +``mummerplot``) and the tools ``gnuplot`` and ``ps2pdf`` to be on the system +``$PATH``. + +To install the wrapper copy or move the following files under the Galaxy tools +folder, e.g. in a ``tools/mummer`` folder: + +* ``mummer.xml`` (the Galaxy tool definition) +* ``mummer.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:: + + <tool file="mummer/mummer.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 mummer_wrapper + +That's it. + + +History +======= + +======= ====================================================================== +Version Changes +------- ---------------------------------------------------------------------- +v0.0.1 - Initial public release +======= ====================================================================== + + +Developers +========== + +Development is on GitHub at: +https://github.com/peterjc/pico_galaxy/tree/master/tools/mummer + +For making the "Galaxy Tool Shed" http://toolshed.g2.bx.psu.edu/ tarball use +the following command from the Galaxy root folder:: + + $ tar -czf mummer.tar.gz tools/mummer/README.rst tools/mummer/mummer.xml tools/mummer/mummer.py tools/mummer/tool_dependencies.xml + +Check this worked:: + + $ tar -tzf mummer.tar.gz + tools/mummer/README.rst + tools/mummer/mummer.xml + tools/mummer/mummer.py + tools/mummer/tool_dependencies.xml + + +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. +MUMmer is available and licenced separately.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mummer/mummer.py Mon Oct 27 12:56:55 2014 -0400 @@ -0,0 +1,84 @@ +#!/usr/bin/env python +"""MUMmer wrapper calling nucmer/promer/mummerplot etc, + +Takes the following command line options, +1. FASTA filename of species A +2. FASTA filename of species B +3. Algorithm, nucmer or promer +4. PNG output filename +5. PDF output filename +""" + +import os +import sys +import tempfile +import shutil + +def stop_err( msg ): + sys.stderr.write("%s\n" % msg) + sys.exit(1) + +def run(cmd): + print(cmd) + return_code = os.system(cmd) + if return_code: + stop_err("Error %i from: %s" % (return_code, cmd)) + +if "-v" in sys.argv [1:]or "--version" in sys.argv[1:]: + print("MUMmer wrapper v0.0.1\n") + os.system("nucmer --version") + os.system("promer --version") + os.system("mummerplot --version") + sys.exit(0) + +#Parse Command Line +#TODO - optparse +try: + fasta_a, fasta_b, algorithm, png_out, pdf_out = sys.argv[1:] +except: + stop_err("Expect 5 arguments, got %i" % (len(sys.argv) - 1)) + + +valid_algo = ["mummer", "nucmer", "promer"] +if algorithm not in valid_algo: + stop_err("Invalid algorithm argument %r, should be: %s" % (algorithm, ", ".join(valid_algo))) + +base_path = tempfile.mkdtemp() +prefix = os.path.join(base_path, "ref_qry") +coords = prefix + ".mums" +#gnuplot = prefix + ".gp" +ps_image = prefix + ".ps" +png_image = prefix + ".png" + +if algorithm == "mummer": + #Add -mum as per example to find maximal unique matches between ref and query. + #Add the -b -c options to search both strands and report relative to forward strand + #which then matches the default dual-strand approach in nucmer and promer + cmd = '%s -mum -b -c "%s" "%s" > %s' % (algorithm, fasta_a, fasta_b, coords) +else: + coords = "out.delta" + cmd = '%s "%s" "%s"' % (algorithm, fasta_a, fasta_b) +run(cmd) + +# PNG +# === +cmd = 'mummerplot -R "%s" -Q "%s" --png --large --prefix=%s %s' % (fasta_a, fasta_b, prefix, coords) +run(cmd) +shutil.move(png_image, png_out) + +# PS --> PDF +# ========== +# Using --large, puts "set size 3,3" in the gnuplot - which seems to mess up. +# Problem here is the default bbox (BoundingBox) in the PS output is letter page size, +# and even if we override that, at least when view the PS output in Adobe Illustrator +# things don't seem to be lined up properly :( +# +# Using "set size 1,1" works better - which is what --small gives: +cmd = 'mummerplot -R "%s" -Q "%s" --postscript --small --prefix=%s %s' % (fasta_a, fasta_b, prefix, coords) +run(cmd) +cmd = 'ps2pdf -dEPSCrop "%s" "%s"' % (ps_image, pdf_out) +run(cmd) + +#Remove temp files... +os.remove(coords) # Might not be under the temp directory... +shutil.rmtree(base_path)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mummer/mummer.xml Mon Oct 27 12:56:55 2014 -0400 @@ -0,0 +1,68 @@ +<tool id="mumer_wrapper" name="MUMmer" version="0.0.1"> + <description>Draw dotplot with mummer/nucmer/promer/mummerplot</description> + <requirements> + <requirement type="binary">ps2pdf</requirement> + <requirement type="binary">nucmer</requirement> + <requirement type="binary">mummerplot</requirement> + <requirement type="package" version="3.23">mummer</requirement> + </requirements> + <version_command interpreter="python"> +mummer.py --version + </version_command> + <command interpreter="python"> +mummer.py "$fasta_a" "$fasta_b" $algorithm "$png_output" "$pdf_output" + </command> + <stdio> + <!-- Anything other than zero is an error --> + <exit_code range="1:" /> + <exit_code range=":-1" /> + </stdio> + <inputs> + <!-- Galaxy does not have sub-types for protein vs nucletide FASTA --> + <param name="fasta_a" type="data" format="fasta" + label="Species A" + description="Nucleotide FASTA file, e.g. contigs from genome assembly." /> + <param name="fasta_b" type="data" format="fasta" + label="Species B" + description="Nucleotide FASTA file, e.g. contigs from genome assembly." /> + <param name="algorithm" type="select" label="MUMmer search algorithm"> + <option value="mummer">mummer, efficiently locates maximal unique matches between two sequences</option> + <option value="nucmer">NUCmer (NUCleotide MUMmer), for closely related sequences</option> + <option value="promer">PROmer (PROtein MUMmer), using six frame translation of DNA input, for less similar sequences.</option> + </param> + <!-- defaults like mincluster vary, 65 for nucmer but 20 for promer --> + </inputs> + <outputs> + <data name="pdf_output" format="pdf" label="$algorithm.value PDF: $fasta_a.name vs $fasta_b.name" /> + <data name="png_output" format="png" label="$algorithm.value PNG: $fasta_a.name vs $fasta_b.name" /> + </outputs> + <requirements> + </requirements> + <tests> + </tests> + <help> +**What it does** + +Takes two FASTA files (*species A* and *species B*), compairs them using one +of the MUMmer 3 tools (``mummer``, ``nucmer``, or ``promer``), comparing both +strands, and then draws a dotplot using ``mummerplot``. + +The full MUMmer suite is more flexible and capable than this limited wrapper. + +**References** + +MUMmer manual: v3.22 http://mummer.sourceforge.net/manual/ + +MUMmer tutorials: http://mummer.sourceforge.net/examples/ + +If you use MUMmer 3, please cite: + +S. Kurtz et al. (2004). +Versatile and open software for comparing large genomes. +Genome Biology (2004), 5:R12. +http://dx.doi.org/10.1186/gb-2004-5-2-r12 + +This wrapper is available to install into other Galaxy Instances via the Galaxy +Tool Shed at http://toolshed.g2.bx.psu.edu/view/peterjc/mummer + </help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mummer/tool_dependencies.xml Mon Oct 27 12:56:55 2014 -0400 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="mummer" version="3.23"> + <repository changeset_revision="cc6c4d6ebceb" name="package_mummer_3_23" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> + </package> +</tool_dependency>