# HG changeset patch # User peterjc # Date 1366821797 14400 # Node ID 4266cccbb45aa3360b83c159ac111f3286f0d5e3 # Parent 4d3f94dfb857b5651db2176f28c6cda964308110 Uploaded v0.0.7 take 2, fixed path in installation diff -r 4d3f94dfb857 -r 4266cccbb45a tools/mira_3_4/mira.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mira_3_4/mira.py Wed Apr 24 12:43:17 2013 -0400 @@ -0,0 +1,124 @@ +#!/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 + +WRAPPER_VER = "0.0.5" #Keep in sync with the XML file + +def stop_err(msg, err=1): + sys.stderr.write(msg+"\n") + sys.exit(err) + + +def get_version(): + """Run MIRA to find its version number""" + # At the commend line I would use: mira -v | head -n 1 + # however there is some pipe error when doing that here. + try: + child = subprocess.Popen(["mira", "-v"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + except Exception, err: + sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) + sys.exit(1) + ver, tmp = child.communicate() + del child + return ver.split("\n", 1)[0] + + +mira_ver = get_version() +if "V3.4." not in mira_ver: + stop_err("This wrapper is for MIRA V3.4, not %s" % mira_ver) +if "-v" in sys.argv: + print "MIRA wrapper version %s," % WRAPPER_VER + print mira_ver + sys.exit(0) + + +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") + missing = [] + 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): + missing.append(os.path.splitext(old)[-1]) + else: + shutil.move(old, new) + if missing: + stop_err("Missing output files: %s" % ", ".join(missing)) + +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_ace, out_caf, out_wig, out_log = sys.argv[1:8] + +start_time = time.time() +cmd_list =sys.argv[8:] +cmd = " ".join(cmd_list) + +assert os.path.isdir(temp) +d = "%s_assembly" % name +assert not os.path.isdir(d), "Path %s already exists" % 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(cmd_list, + 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() + +#print "Collecting output..." +collect_output(temp, name) + +#print "Cleaning up..." +clean_up(temp, name) + +print "Done" diff -r 4d3f94dfb857 -r 4266cccbb45a tools/mira_3_4/mira.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mira_3_4/mira.txt Wed Apr 24 12:43:17 2013 -0400 @@ -0,0 +1,104 @@ +Galaxy tool to wrap the MIRA sequence assembly program (v3.4) +============================================================= + +This tool is copyright 2011-2013 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 +separated file for use in Galaxy). + + +Automated Installation +====================== + +This should be straightforward, Galaxy should automatically download and +install the precompiled binary for MIRA v3.4.0 for the Galaxy wrapper, +and run any tests. + + +Manual Installation +=================== + +There are just two Galaxy files to install: + +* mira.py (the Python script) +* mira.xml (the Galaxy tool definition) + +The suggested location is a new tools/mira_3_4 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.4.1.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, using MIRA 3.2.1) +v0.0.2 - Improve capture of stdout/stderr (should see it as it runs) +v0.0.3 - Support Ion Torrent reads, now requires MIRA 3.4.0 or later + (some other switches changed, e.g. -OUT rrol to rrot, which + means the wrapper no longer works with MIRA 3.2.x) + - The contig summary file (TCS file) was removed in MIRA 3.4 + - Report all missing output files (not just first missing one) +v0.0.4 - Fix problem with backbone arguments inroduced in v0.0.3 +v0.0.5 - Implement the tag to record the wrapper + version and the MIRA version being used. + - Check using MIRA 3.4 (later versions have a different API) +v0.0.6 - Tell MIRA to use /tmp for temporary files + - Tell MIRA to ignore long read names (otherwise it aborts) +v0.0.7 - Automated installation of the 64 bit Linux MIRA binary. + + +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://toolshed.g2.bx.psu.edu/ tarball use +the following command from the Galaxy root folder: + +tar -czf mira_wrapper.tar.gz tools/mira_3_4/mira.* + +Check this worked: + +$ tar -tzf mira_wrapper.tar.gz +tools/mira_3_4/mira.py +tools/mira_3_4/mira.txt +tools/mira_3_4/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 4d3f94dfb857 -r 4266cccbb45a tools/mira_3_4/mira.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mira_3_4/mira.xml Wed Apr 24 12:43:17 2013 -0400 @@ -0,0 +1,155 @@ + + Takes Sanger, Roche, Illumina, and Ion Torrent data + mira.py -v + mira.py mira $out_fasta $out_qual $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=1:bft=fasta -FN:bbin=${condBackbone.filename} +#end if +#if $condSanger.use == "true": + SANGER_SETTINGS + ## Not easy in Galaxy to add sanger to --job, so use load_sequence_data(lsd) instead + ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file + -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condSanger.filename} +#end if +#if $condRoche.use == "true": + 454_SETTINGS + ## Not easy in Galaxy to add 454 to --job, so use load_sequence_data(lsd) instead + ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file + -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condRoche.filename} +#end if +#if $condIllumina.use == "true": + SOLEXA_SETTINGS + ## Not easy in Galaxy to add solexa to --job, so use load_sequence_data(lsd) instead + -LR:lsd=1:ft=fastq -FN:fqi=${condIllumina.filename} + ##TODO - Look at -LR FASTQ qual offset (fqqo) +#end if +#if $condIonTorrent.use == "true": + IONTOR_SETTINGS + ## Not easy in Galaxy to add iontor to --job, so use load_sequence_data(lsd) instead + ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file + -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condIonTorrent.filename} +#end if + +##Output files +COMMON_SETTINGS + +##ignore warnings about long read names +-MI:somrnl=0 + +##Explicitly request the FASTA (+QUAL), CAF, ACE, WIG output +##Explicitly disable formats we won't use like MAF (reduce IO) +-OUT:orf=1:orc=1:ora=1:orw=1:orm=0:org=0:ors=0 + +##remove_rollover_tmps, remove_tmp_directory +-OUT:rrot=1:rtd=1 + +##put mira temp directory on local storage +-DI:trt=/tmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bio + mira + + + +**What it does** + +Runs MIRA v3.4, collects the output, and throws away all the temporary files. + +**Citation** + +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. + + + diff -r 4d3f94dfb857 -r 4266cccbb45a tools/sr_assembly/mira.py --- a/tools/sr_assembly/mira.py Thu Feb 14 06:26:32 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +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 - -WRAPPER_VER = "0.0.5" #Keep in sync with the XML file - -def stop_err(msg, err=1): - sys.stderr.write(msg+"\n") - sys.exit(err) - - -def get_version(): - """Run MIRA to find its version number""" - # At the commend line I would use: mira -v | head -n 1 - # however there is some pipe error when doing that here. - try: - child = subprocess.Popen(["mira", "-v"], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - except Exception, err: - sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) - sys.exit(1) - ver, tmp = child.communicate() - del child - return ver.split("\n", 1)[0] - - -mira_ver = get_version() -if "V3.4." not in mira_ver: - stop_err("This wrapper is for MIRA V3.4, not %s" % mira_ver) -if "-v" in sys.argv: - print "MIRA wrapper version %s," % WRAPPER_VER - print mira_ver - sys.exit(0) - - -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") - missing = [] - 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): - missing.append(os.path.splitext(old)[-1]) - else: - shutil.move(old, new) - if missing: - stop_err("Missing output files: %s" % ", ".join(missing)) - -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_ace, out_caf, out_wig, out_log = sys.argv[1:8] - -start_time = time.time() -cmd_list =sys.argv[8:] -cmd = " ".join(cmd_list) - -assert os.path.isdir(temp) -d = "%s_assembly" % name -assert not os.path.isdir(d), "Path %s already exists" % 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(cmd_list, - 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() - -#print "Collecting output..." -collect_output(temp, name) - -#print "Cleaning up..." -clean_up(temp, name) - -print "Done" diff -r 4d3f94dfb857 -r 4266cccbb45a tools/sr_assembly/mira.txt --- a/tools/sr_assembly/mira.txt Thu Feb 14 06:26:32 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +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 -separated 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.4.0. 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, using MIRA 3.2.1) -v0.0.2 - Improve capture of stdout/stderr (should see it as it runs) -v0.0.3 - Support Ion Torrent reads, now requires MIRA 3.4.0 or later - (some other switches changed, e.g. -OUT rrol to rrot, which - means the wrapper no longer works with MIRA 3.2.x) - - The contig summary file (TCS file) was removed in MIRA 3.4 - - Report all missing output files (not just first missing one) -v0.0.4 - Fix problem with backbone arguments inroduced in v0.0.3 -v0.0.5 - Implement the tag to record the wrapper - version and the MIRA version being used. - - Check using MIRA 3.4 (later versions have a different API) -v0.0.6 - Tell MIRA to use /tmp for temporary files - - Tell MIRA to ignore long read names (otherwise it aborts) - - -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 4d3f94dfb857 -r 4266cccbb45a tools/sr_assembly/mira.xml --- a/tools/sr_assembly/mira.xml Thu Feb 14 06:26:32 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ - - Takes Sanger, Roche, Illumina, and Ion Torrent data - mira.py -v - mira.py mira $out_fasta $out_qual $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=1:bft=fasta -FN:bbin=${condBackbone.filename} -#end if -#if $condSanger.use == "true": - SANGER_SETTINGS - ## Not easy in Galaxy to add sanger to --job, so use load_sequence_data(lsd) instead - ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file - -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condSanger.filename} -#end if -#if $condRoche.use == "true": - 454_SETTINGS - ## Not easy in Galaxy to add 454 to --job, so use load_sequence_data(lsd) instead - ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file - -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condRoche.filename} -#end if -#if $condIllumina.use == "true": - SOLEXA_SETTINGS - ## Not easy in Galaxy to add solexa to --job, so use load_sequence_data(lsd) instead - -LR:lsd=1:ft=fastq -FN:fqi=${condIllumina.filename} - ##TODO - Look at -LR FASTQ qual offset (fqqo) -#end if -#if $condIonTorrent.use == "true": - IONTOR_SETTINGS - ## Not easy in Galaxy to add iontor to --job, so use load_sequence_data(lsd) instead - ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file - -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condIonTorrent.filename} -#end if - -##Output files -COMMON_SETTINGS - -##ignore warnings about long read names --MI:somrnl=0 - -##Explicitly request the FASTA (+QUAL), CAF, ACE, WIG output -##Explicitly disable formats we won't use like MAF (reduce IO) --OUT:orf=1:orc=1:ora=1:orw=1:orm=0:org=0:ors=0 - -##remove_rollover_tmps, remove_tmp_directory --OUT:rrot=1:rtd=1 - -##put mira temp directory on local storage --DI:trt=/tmp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bio - mira - - - -**What it does** - -Runs MIRA v3, collects the output, and throws away all the temporary files. - -**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. - - -