# HG changeset patch # User g2cmnty@test-web1.g2.bx.psu.edu # Date 1308664091 14400 # Node ID 73263d5c2c9ff66394259c740b7b286dffbae237 # Parent e53a79816f5fb23ce6092eaf0032a87fe5c97ec6 Remove botched upload (see Galaxy issue 586) diff -r e53a79816f5f -r 73263d5c2c9f mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.py --- a/mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.py Thu Jun 16 04:44:00 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -#!/usr/bin/env python -"""A simple wrapper script to call MIRA and collect its output. -""" -import os -import sys -import subprocess -import shutil -import time - -def stop_err(msg, err=1): - sys.stderr.write(msg+"\n") - sys.exit(err) - -def tcs_to_tabular(old, new): - in_handle = open(old, "rU") - out_handle = open(new, "w") - assert in_handle.readline() == "#TCS V1.0\n" - assert in_handle.readline() == "#\n" - assert in_handle.readline() == "# contig name padPos upadPos | B Q | tcov covA covC covG covT cov* | qA qC qG qT q* | S | Tags\n" - assert in_handle.readline() == "#\n" - out_handle.write("#%s\n" % "\t".join(["contig", "pasPos", "upadPos", "B", "Q", - "tcov", "covA", "covC", "covG", "covT", "cov*", - "qA", "qC", "qG", "qT", "q*", "S", "Tags"])) - for line in in_handle: - parts = line.rstrip("\n").split(None,22) - assert parts[3] == parts[6] == parts[13] == parts[19] == parts[21] == "|" - wanted = parts[:3] + parts[4:6]+parts[7:13]+parts[14:19]+parts[20:21]+parts[22:] - out_handle.write("%s\n" % "\t".join(wanted)) - out_handle.close() - in_handle.close() - -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): - stop_err("Missing output folder") - if not os.listdir(f): - stop_err("Empty output folder") - for old, new in [("%s/%s_out.unpadded.fasta" % (f, name), out_fasta), - ("%s/%s_out.unpadded.fasta.qual" % (f, name), out_qual), - ("%s/%s_out.wig" % (f, name), out_wig), - ("%s/%s_out.caf" % (f, name), out_caf), - ("%s/%s_out.ace" % (f, name), out_ace)]: - if not os.path.isfile(old): - stop_err("Missing %s output file" % os.path.splitext(old)[-1]) - else: - shutil.move(old, new) - tcs_to_tabular("%s/%s_assembly/%s_d_results/%s_out.tcs" % n3, out_tcs) - -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/ -temp = "." -name, out_fasta, out_qual, out_tcs, out_ace, out_caf, out_wig, out_log = sys.argv[1:9] - -start_time = time.time() -cmd = " ".join(sys.argv[9:]) - -assert os.path.isdir(temp) -d = "%s_assembly" % name -assert not os.path.isdir(d) -try: - #Check path access - os.mkdir(d) -except Exception, err: - sys.stderr.write("Error making directory %s\n%s" % (d, err)) - sys.exit(1) - -#print os.path.abspath(".") -#print cmd - -handle = open(out_log, "w") -try: - #Run MIRA - child = subprocess.Popen(sys.argv[9:], - stdout=handle, - stderr=subprocess.STDOUT) -except Exception, err: - sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err)) - #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(), -stdout, stderr = child.communicate() -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) -if return_code: - handle.write("Return error code %i from command:\n" % return_code) - handle.write(cmd + "\n") - handle.close() - clean_up(temp, name) - stop_err("Return error code %i from command:\n%s" % (return_code, cmd), - return_code) -handle.close() - -collect_output(temp, name) -clean_up(temp, name) -print "Done" diff -r e53a79816f5f -r 73263d5c2c9f mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.txt --- a/mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.txt Thu Jun 16 04:44:00 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -Galaxy tool to wrap the MIRA sequence assembly program -====================================================== - -This tool is copyright 2011 by Peter Cock, The James Hutton Institute -(formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. -See the licence text below. - -This tool is a short Python script (to collect the MIRA output and move it -to where Galaxy expects the files, and convert MIRA's TCS file into a tab -separate file for use in Galaxy). There are just two files to install: - -* mira.py (the Python script) -* mira.xml (the Galaxy tool definition) - -The suggested location is the tools/sr_assembly folder. You will also need to -modify the tools_conf.xml file to tell Galaxy to offer the tool and also do -this to tools_conf.xml.sample in order to run any tests: - - - -You will also need to install MIRA, we used version 3.2.1. See: - -http://chevreux.org/projects_mira.html -http://sourceforge.net/projects/mira-assembler/ - -WARNING: This tool was developed to construct viral genome assembly and -mapping pipelines, for which the run time and memory requirements are -negligible. For larger tasks, be aware that MIRA can require vast amounts -of RAM and run-times of over a week are possible. This tool wrapper makes -no attempt to spot and reject such large jobs. - - -History -======= - -v0.0.1 - Initial version (working prototype) -v0.0.2 - Improve capture of stdout/stderr (should see it as it runs) - - -Developers -========== - -This script and related tools are being developed on the following hg branch: -http://bitbucket.org/peterjc/galaxy-central/src/tools - -For making the "Galaxy Tool Shed" http://community.g2.bx.psu.edu/ tarball use -the following command from the Galaxy root folder: - -tar -czf mira_wrapper.tar.gz tools/sr_assembly/mira.* - -Check this worked: - -$ tar -tzf mira_wrapper.tar.gz -tools/sr_assembly/mira.py -tools/sr_assembly/mira.txt -tools/sr_assembly/mira.xml - - -Licence (MIT/BSD style) -======================= - -Permission to use, copy, modify, and distribute this software and its -documentation with or without modifications and for any purpose and -without fee is hereby granted, provided that any copyright notices -appear in all copies and that both those copyright notices and this -permission notice appear in supporting documentation, and that the -names of the contributors or copyright holders not be used in -advertising or publicity pertaining to distribution of the software -without specific prior permission. - -THE CONTRIBUTORS AND COPYRIGHT HOLDERS OF THIS SOFTWARE DISCLAIM ALL -WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT -OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE -OR PERFORMANCE OF THIS SOFTWARE. diff -r e53a79816f5f -r 73263d5c2c9f mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.xml --- a/mira_wrapper_v0.0.2.tar.gz/tools/sr_assembly/mira.xml Thu Jun 16 04:44:00 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ - - Takes Sanger, Roche, and Illumina data - mira.py mira $out_fasta $out_qual $out_tcs $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 - -##Input files -#if $condBackbone.use == "true": - ## Can this be linked to job_method as well? If mapping we need the backbone... - -SB:lb=yes -SB:bft=fasta -FN:bbin=${condBackbone.filename} -#end if -#if $condSanger.use == "true": - Sanger_SETTINGS - ## Not easy to add sanger to --job, so use load_sequence_data(lsd) instead - -LR:lsd=yes - ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file - -LR:mxti=no -LR:ft=fastq -FN:fqi=${condSanger.filename} -#end if -#if $condRoche.use == "true": - 454_SETTINGS - ## Not easy to add 454 to --job, so use load_sequence_data(lsd) instead - -LR:lsd=yes - ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file - -LR:mxti=no -LR:ft=fastq -FN:fqi=${condRoche.filename} -#end if -#if $condIllumina.use == "true": - SOLEXA_SETTINGS - ## Not easy to add solexa to --job, so use load_sequence_data(lsd) instead - -LR:lsd=yes -LR:ft=fastq -FN:fgi=${condIllumina.filename} - ##TODO - Look at -LR FASTQ qual offset (fqqo) -#end if - - -##Output files -COMMON_SETTINGS -##remove_rollover_logs, remove_log_directory --OUT:rrol=yes -OUT:rld=yes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bio - - - -**What it does** - -Runs MIRA v3, collects the output, and throws away all the temporary files. - -The MIRA transposed contig summary (TCS) file is converted into a tabular file for use within Galaxy. -This records one line per base per contig, and including things like the base, quality, coverage and any tags. - -**Citation** - -This tool uses MIRA. If you use this tool in scientific work leading to a -publication, please cite: - -Chevreux et al. (1999) Genome Sequence Assembly Using Trace Signals and Additional Sequence Information Computer Science and Biology: Proceedings of the German Conference on Bioinformatics (GCB) 99, pp. 45-56. - - -