# HG changeset patch # User peterjc # Date 1599663699 0 # Node ID 242cf17c3bf90c5b292952a0d6e1274db079aca5 # Parent 05eef6b222af8e9efd4177ce80f8c07ebefa8130 "planemo upload for repository https://github.com/peterjc/galaxy_blast/tree/master/tools/blast2go commit 0c82b9ef284c686cbffd30582d2586e4fb52881e" diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/README.rst --- a/tools/blast2go/README.rst Fri May 15 06:01:16 2015 -0400 +++ b/tools/blast2go/README.rst Wed Sep 09 15:01:39 2020 +0000 @@ -1,7 +1,7 @@ Galaxy wrapper for Blast2GO for pipelines, b2g4pipe =================================================== -This wrapper is copyright 2011-2015 by Peter Cock, The James Hutton Institute +This wrapper is copyright 2011-2017 by Peter Cock, The James Hutton Institute (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. See the licence text below (MIT licence). @@ -24,22 +24,22 @@ Peter Cock, Bjoern Gruening, Konrad Paszkiewicz and Leighton Pritchard (2013). Galaxy tools and workflows for sequence analysis with applications in molecular plant pathology. PeerJ 1:e167 -http://dx.doi.org/10.7717/peerj.167 +https://doi.org/10.7717/peerj.167 S. Geotz et al. (2008). High-throughput functional annotation and data mining with the Blast2GO suite. Nucleic Acids Res. 36(10):3420-3435. -http://dx.doi.org/10.1093/nar/gkn176 +https://doi.org/10.1093/nar/gkn176 A. Conesa and S. Geotz (2008). Blast2GO: A Comprehensive Suite for Functional Analysis in Plant Genomics. International Journal of Plant Genomics. 619832. -http://dx.doi.org/10.1155/2008/619832 +https://doi.org/10.1155/2008/619832 A. Conesa et al. (2005). Blast2GO: A universal tool for annotation, visualization and analysis in functional genomics research. Bioinformatics 21:3674-3676. -http://dx.doi.org/10.1093/bioinformatics/bti610 +https://doi.org/10.1093/bioinformatics/bti610 See also http://www.blast2go.com/ @@ -166,6 +166,13 @@ - Tool definition now embeds citation information. v0.0.10 - Reorder XML elements (internal change only). - Planemo for Tool Shed upload (``.shed.yml``, internal change only). +v0.0.11 - Fix parameter help text which was not being displayed. + - PEP8 style updates to the Python script (internal change only). + - Use ```` (internal change only). + - Single quote command line arguments (internal change only). + - Python 3 compatible syntax. + - Record ``b2g4pipe_v2.5.zip`` SHA256 checksum, and download this via + the Galaxy pacakge cache. ======= ====================================================================== @@ -183,19 +190,19 @@ 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/galaxy_blast/tools/blast2go/ + $ planemo shed_update -t testtoolshed --check_diff ~/repositories/galaxy_blast/tools/blast2go/ ... or:: - $ planemo shed_upload --shed_target toolshed --check_diff ~/repositories/galaxy_blast/tools/blast2go/ + $ planemo shed_update -t toolshed --check_diff ~/repositories/galaxy_blast/tools/blast2go/ ... To just build and check the tar ball, use:: $ planemo shed_upload --tar_only ~/repositories/galaxy_blast/tools/blast2go/ ... - $ tar -tzf shed_upload.tar.gz + $ tar -tzf shed_upload.tar.gz test-data/blastp_sample.blast2go.tabular test-data/blastp_sample.xml tool-data/blast2go.loc.sample diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/blast2go.py --- a/tools/blast2go/blast2go.py Fri May 15 06:01:16 2015 -0400 +++ b/tools/blast2go/blast2go.py Wed Sep 09 15:01:39 2020 +0000 @@ -26,61 +26,65 @@ This script is under version control here: https://github.com/peterjc/galaxy_blast/tree/master/blast2go """ -import sys + +from __future__ import print_function + import os import subprocess +import sys -#You may need to edit this to match your local setup, +# You may need to edit this to match your local setup, blast2go_dir = os.environ.get("B2G4PIPE", "/opt/b2g4pipe_v2.5/") blast2go_jar = os.path.join(blast2go_dir, "blast2go.jar") -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) try: from massage_xml_for_blast2go import prepare_xml except ImportError: - stop_err("Missing sister file massage_xml_for_blast2go.py") + sys.exit("Missing sister file massage_xml_for_blast2go.py") if len(sys.argv) != 4: - stop_err("Require three arguments: XML filename, properties filename, output tabular filename") + sys.exit( + "Require three arguments: XML filename, " + "properties filename, output tabular filename" + ) xml_file, prop_file, tabular_file = sys.argv[1:] -#We should have write access here: +# We should have write access here: tmp_xml_file = tabular_file + ".tmp.xml" if not os.path.isfile(blast2go_jar): - stop_err("Blast2GO JAR file not found: %s" % blast2go_jar) + sys.exit("Blast2GO JAR file not found: %s" % blast2go_jar) if not os.path.isfile(xml_file): - stop_err("Input BLAST XML file not found: %s" % xml_file) + sys.exit("Input BLAST XML file not found: %s" % xml_file) if not os.path.isfile(prop_file): tmp = os.path.join(os.path.split(blast2go_jar)[0], prop_file) if os.path.isfile(tmp): - #The properties file seems to have been given relative to the JAR + # The properties file seems to have been given relative to the JAR prop_file = tmp else: - stop_err("Blast2GO configuration file not found: %s" % prop_file) + sys.exit("Blast2GO configuration file not found: %s" % prop_file) del tmp def run(cmd): - #Avoid using shell=True when we call subprocess to ensure if the Python - #script is killed, so too is the child process. + """Run the given command line string via subprocess.""" + # Avoid using shell=True when we call subprocess to ensure if the Python + # script is killed, so too is the child process. try: - child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - except Exception, err: - stop_err("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) - #Use .communicate as can get deadlocks with .wait(), + child = subprocess.Popen( + cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + except Exception as err: + sys.exit("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) stdout, stderr = child.communicate() return_code = child.returncode - #keep stdout minimal as shown prominently in Galaxy - #Record it in case a silent error needs diagnosis + # keep stdout minimal as shown prominently in Galaxy + # Record it in case a silent error needs diagnosis if stdout: sys.stderr.write("Standard out:\n%s\n\n" % stdout) if stderr: @@ -90,14 +94,14 @@ if return_code: cmd_str = " ".join(cmd) error_msg = "Return code %i from command:\n%s" % (return_code, cmd_str) - elif "Database or network connection (timeout) error" in stdout+stderr: + elif "Database or network connection (timeout) error" in stdout + stderr: error_msg = "Database or network connection (timeout) error" - elif "Annotation of 0 seqs with 0 annots finished." in stdout+stderr: + elif "Annotation of 0 seqs with 0 annots finished." in stdout + stderr: error_msg = "No sequences processed!" if error_msg: - print error_msg - stop_err(error_msg) + print(error_msg) + sys.exit(error_msg) blast2go_classpath = os.path.split(blast2go_jar)[0] @@ -105,30 +109,37 @@ blast2go_classpath = "%s/*:%s/ext/*:" % (blast2go_classpath, blast2go_classpath) prepare_xml(xml_file, tmp_xml_file) -#print "XML file prepared for Blast2GO" +# print "XML file prepared for Blast2GO" -#We will have write access wherever the output should be, -#so we'll ask Blast2GO to use that as the stem for its output -#(it will append .annot to the filename) -cmd = ["java", "-cp", blast2go_classpath, "es.blast2go.prog.B2GAnnotPipe", - "-in", tmp_xml_file, - "-prop", prop_file, - "-out", tabular_file, #Used as base name for output files - "-annot", # Generate *.annot tabular file - #NOTE: For v2.3.5 must use -a, for v2.5 must use -annot instead - #"-img", # Generate images, feature not in v2.3.5 - ] -#print " ".join(cmd) +# We will have write access wherever the output should be, +# so we'll ask Blast2GO to use that as the stem for its output +# (it will append .annot to the filename) +cmd = [ + "java", + "-cp", + blast2go_classpath, + "es.blast2go.prog.B2GAnnotPipe", + "-in", + tmp_xml_file, + "-prop", + prop_file, + "-out", + tabular_file, # Used as base name for output files + "-annot", # Generate *.annot tabular file + # NOTE: For v2.3.5 must use -a, for v2.5 must use -annot instead + # "-img", # Generate images, feature not in v2.3.5 +] +# print " ".join(cmd) run(cmd) -#Remove the temp XML file +# Remove the temp XML file os.remove(tmp_xml_file) out_file = tabular_file + ".annot" if not os.path.isfile(out_file): - stop_err("ERROR - No output annotation file from Blast2GO") + sys.exit("ERROR - No output annotation file from Blast2GO") -#Move the output file where Galaxy expects it to be: +# Move the output file where Galaxy expects it to be: os.rename(out_file, tabular_file) -print "Done" +print("Done") diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/blast2go.xml --- a/tools/blast2go/blast2go.xml Fri May 15 06:01:16 2015 -0400 +++ b/tools/blast2go/blast2go.xml Wed Sep 09 15:01:39 2020 +0000 @@ -1,19 +1,14 @@ - + Maps BLAST results to GO annotation terms b2g4pipe - - - - - - - blast2go.py "${xml}" "${prop.fields.path}" "${tab}" + +python $__tool_directory__/blast2go.py '$xml' '${prop.fields.path}' '$tab' - - + + @@ -92,22 +87,22 @@ Peter Cock, Bjoern Gruening, Konrad Paszkiewicz and Leighton Pritchard (2013). Galaxy tools and workflows for sequence analysis with applications in molecular plant pathology. PeerJ 1:e167 -http://dx.doi.org/10.7717/peerj.167 +https://doi.org/10.7717/peerj.167 S. Götz et al. (2008). High-throughput functional annotation and data mining with the Blast2GO suite. Nucleic Acids Res. 36(10):3420–3435. -http://dx.doi.org/10.1093/nar/gkn176 +https://doi.org/10.1093/nar/gkn176 A. Conesa and S. Götz (2008). Blast2GO: A Comprehensive Suite for Functional Analysis in Plant Genomics. International Journal of Plant Genomics. 619832. -http://dx.doi.org/10.1155/2008/619832 +https://doi.org/10.1155/2008/619832 A. Conesa et al. (2005). Blast2GO: A universal tool for annotation, visualization and analysis in functional genomics research. Bioinformatics 21:3674-3676. -http://dx.doi.org/10.1093/bioinformatics/bti610 +https://doi.org/10.1093/bioinformatics/bti610 See also http://www.blast2go.com/ diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/massage_xml_for_blast2go.py --- a/tools/blast2go/massage_xml_for_blast2go.py Fri May 15 06:01:16 2015 -0400 +++ b/tools/blast2go/massage_xml_for_blast2go.py Wed Sep 09 15:01:39 2020 +0000 @@ -14,18 +14,15 @@ This script is called from my Galaxy wrapper for Blast2GO for pipelines, available from the Galaxy Tool Shed here: -http://toolshed.g2.bx.psu.edu/view/peterjc/blast2go +http://toolshed.g2.bx.psu.edu/view/peterjc/blast2go This script is under version control here: https://github.com/peterjc/galaxy_blast/tree/master/blast2go """ -import sys -import os -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) +import os +import sys + def prepare_xml(original_xml, mangled_xml): """Reformat BLAST XML to suit Blast2GO. @@ -44,8 +41,8 @@ while True: line = in_handle.readline() if not line: - #No hits? - stop_err("Problem with XML file?") + # No hits? + sys.exit("Problem with XML file?") if line.strip() == "": break header += line @@ -56,7 +53,7 @@ print("BLASTP output identified") else: in_handle.close() - stop_err("Expect BLASTP or BLASTX output") + sys.exit("Expect BLASTP or BLASTX output") out_handle = open(mangled_xml, "w") out_handle.write(header) @@ -67,10 +64,10 @@ if not line: break elif line.strip() == "": - #Insert footer/header - out_handle.write(footer) - out_handle.write(header) - count += 1 + # Insert footer/header + out_handle.write(footer) + out_handle.write(header) + count += 1 out_handle.write(line) out_handle.close() @@ -81,11 +78,11 @@ if __name__ == "__main__": # Run the conversion... if len(sys.argv) != 3: - stop_err("Require two arguments: XML input filename, XML output filename") + sys.exit("Require two arguments: XML input filename, XML output filename") xml_file, out_xml_file = sys.argv[1:] if not os.path.isfile(xml_file): - stop_err("Input BLAST XML file not found: %s" % xml_file) + sys.exit("Input BLAST XML file not found: %s" % xml_file) prepare_xml(xml_file, out_xml_file) diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/repository_dependencies.xml --- a/tools/blast2go/repository_dependencies.xml Fri May 15 06:01:16 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ - - - - diff -r 05eef6b222af -r 242cf17c3bf9 tools/blast2go/tool_dependencies.xml --- a/tools/blast2go/tool_dependencies.xml Fri May 15 06:01:16 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ - - - - - - - - http://www.blast2go.com/data/blast2go/b2g4pipe_v2.5.zip - - -cp b2gPipe.properties Spain_2012_August.properties && -sed -i "s/Dbacces.dbname=b2g_apr12/Dbacces.dbname=b2g_aug12/g" Spain_2012_August.properties && -sed -i "s/Dbacces.dbhost=10.10.100.203/Dbacces.dbhost=publicdb.blast2go.com/g" Spain_2012_August.properties - - -cp b2gPipe.properties Spain_2011_June.properties && -sed -i "s/Dbacces.dbname=b2g_apr12/Dbacces.dbname=b2g_jun11/g" Spain_2011_June.properties && -sed -i "s/Dbacces.dbhost=10.10.100.203/Dbacces.dbhost=publicdb.blast2go.com/g" Spain_2011_June.properties - - .$INSTALL_DIR/ - - - $INSTALL_DIR - - - - -Downloads b2g4pipe v2.5 - - - -