From 3d5fd7b5e27d33df02ea929f73250163f2e4e007 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Fri, 17 Aug 2012 11:35:31 -0400 Subject: [PATCH] Migrate NCBI Blast+ (and blastxml) to the toolshed. --- lib/galaxy/datatypes/registry.py | 3 - lib/galaxy/datatypes/xml.py | 120 ------------------ .../tool_shed/migrate/versions/0004_tools.py | 12 ++ scripts/migrate_tools/0004_tools.sh | 4 + scripts/migrate_tools/0004_tools.xml | 12 ++ 5 files changed, 28 insertions(+), 123 deletions(-) create mode 100644 lib/galaxy/tool_shed/migrate/versions/0004_tools.py create mode 100644 scripts/migrate_tools/0004_tools.sh create mode 100644 scripts/migrate_tools/0004_tools.xml diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 50315904e00..b054b423d11 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -276,7 +276,6 @@ class Registry( object ): 'axt' : sequence.Axt(), 'bam' : binary.Bam(), 'bed' : interval.Bed(), - 'blastxml' : xml.BlastXml(), 'coverage' : coverage.LastzCoverage(), 'customtrack' : interval.CustomTrack(), 'csfasta' : sequence.csFasta(), @@ -310,7 +309,6 @@ class Registry( object ): 'axt' : 'text/plain', 'bam' : 'application/octet-stream', 'bed' : 'text/plain', - 'blastxml' : 'application/xml', 'customtrack' : 'text/plain', 'csfasta' : 'text/plain', 'eland' : 'application/octet-stream', @@ -348,7 +346,6 @@ class Registry( object ): self.sniff_order = [ binary.Bam(), binary.Sff(), - xml.BlastXml(), xml.GenericXml(), sequence.Maf(), sequence.Lav(), diff --git a/lib/galaxy/datatypes/xml.py b/lib/galaxy/datatypes/xml.py index ef1f1623e28..37f34f55169 100644 --- a/lib/galaxy/datatypes/xml.py +++ b/lib/galaxy/datatypes/xml.py @@ -27,9 +27,6 @@ class GenericXml( data.Text ): >>> fname = get_test_fname( 'megablast_xml_parser_test1.blastxml' ) >>> GenericXml().sniff( fname ) True - >>> fname = get_test_fname( 'tblastn_four_human_vs_rhodopsin.xml' ) - >>> BlastXml().sniff( fname ) - True >>> fname = get_test_fname( 'interval.interval' ) >>> GenericXml().sniff( fname ) False @@ -50,123 +47,6 @@ class GenericXml( data.Text ): data.Text.merge(split_files, output_file) merge = staticmethod(merge) -class BlastXml( GenericXml ): - """NCBI Blast XML Output data""" - file_ext = "blastxml" - - def set_peek( self, dataset, is_multi_byte=False ): - """Set the peek and blurb text""" - if not dataset.dataset.purged: - dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) - dataset.blurb = 'NCBI Blast XML data' - else: - dataset.peek = 'file does not exist' - dataset.blurb = 'file purged from disk' - def sniff( self, filename ): - """ - Determines whether the file is blastxml - - >>> fname = get_test_fname( 'megablast_xml_parser_test1.blastxml' ) - >>> BlastXml().sniff( fname ) - True - >>> fname = get_test_fname( 'tblastn_four_human_vs_rhodopsin.xml' ) - >>> BlastXml().sniff( fname ) - True - >>> fname = get_test_fname( 'interval.interval' ) - >>> BlastXml().sniff( fname ) - False - """ - #TODO - Use a context manager on Python 2.5+ to close handle - handle = open(filename) - line = handle.readline() - if line.strip() != '': - handle.close() - return False - line = handle.readline() - if line.strip() not in ['', - '']: - handle.close() - return False - line = handle.readline() - if line.strip() != '': - handle.close() - return False - handle.close() - return True - - def merge(split_files, output_file): - """Merging multiple XML files is non-trivial and must be done in subclasses.""" - if len(split_files) == 1: - #For one file only, use base class method (move/copy) - return data.Text.merge(split_files, output_file) - out = open(output_file, "w") - h = None - for f in split_files: - h = open(f) - body = False - header = h.readline() - if not header: - out.close() - h.close() - raise ValueError("BLAST XML file %s was empty" % f) - if header.strip() != '': - out.write(header) #for diagnosis - out.close() - h.close() - raise ValueError("%s is not an XML file!" % f) - line = h.readline() - header += line - if line.strip() not in ['', - '']: - out.write(header) #for diagnosis - out.close() - h.close() - raise ValueError("%s is not a BLAST XML file!" % f) - while True: - line = h.readline() - if not line: - out.write(header) #for diagnosis - out.close() - h.close() - raise ValueError("BLAST XML file %s ended prematurely" % f) - header += line - if "" in line: - break - if len(header) > 10000: - #Something has gone wrong, don't load too much into memory! - #Write what we have to the merged file for diagnostics - out.write(header) - out.close() - h.close() - raise ValueError("BLAST XML file %s has too long a header!" % f) - if "" not in header: - out.close() - h.close() - raise ValueError("%s is not a BLAST XML file:\n%s\n..." % (f, header)) - if f == split_files[0]: - out.write(header) - old_header = header - elif old_header[:300] != header[:300]: - #Enough to check and match - out.close() - h.close() - raise ValueError("BLAST XML headers don't match for %s and %s - have:\n%s\n...\n\nAnd:\n%s\n...\n" \ - % (split_files[0], f, old_header[:300], header[:300])) - else: - out.write(" \n") - for line in h: - if "" in line: - break - #TODO - Increment and if required automatic query names - #like Query_3 to be increasing? - out.write(line) - h.close() - out.write(" \n") - out.write("\n") - out.close() - merge = staticmethod(merge) - - class MEMEXml( GenericXml ): """MEME XML Output data""" file_ext = "memexml" diff --git a/lib/galaxy/tool_shed/migrate/versions/0004_tools.py b/lib/galaxy/tool_shed/migrate/versions/0004_tools.py new file mode 100644 index 00000000000..f20bd83b251 --- /dev/null +++ b/lib/galaxy/tool_shed/migrate/versions/0004_tools.py @@ -0,0 +1,12 @@ +""" +The NCBI BLAST+ tools have been eliminated from the distribution. The tools and datatypes are are now available in repositories named ncbi_blast_plus +and blast_datatypes, respectively, from the main Galaxy tool shed at http://toolshed.g2.bx.psu.edu will be installed into your local Galaxy instance +at the location discussed above by running the following command. +""" + +import sys + +def upgrade(): + print __doc__ +def downgrade(): + pass diff --git a/scripts/migrate_tools/0004_tools.sh b/scripts/migrate_tools/0004_tools.sh new file mode 100644 index 00000000000..40b76956fa2 --- /dev/null +++ b/scripts/migrate_tools/0004_tools.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd `dirname $0`/../.. +python ./scripts/migrate_tools/migrate_tools.py 0004_tools.xml $@ diff --git a/scripts/migrate_tools/0004_tools.xml b/scripts/migrate_tools/0004_tools.xml new file mode 100644 index 00000000000..53664f9823c --- /dev/null +++ b/scripts/migrate_tools/0004_tools.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +