commit/galaxy-central: Peter van Heusden: Added TwoBit datatype for twobit binary nucleotide datatype. Sniffer code
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/b319d5c44acf/ changeset: b319d5c44acf user: Peter van Heusden date: 2011-06-13 14:05:41 summary: Added TwoBit datatype for twobit binary nucleotide datatype. Sniffer code based on bx-python's bx.seq.twobit. affected #: 2 files (1.3 KB) --- a/datatypes_conf.xml.sample Mon Jun 13 10:47:51 2011 -0400 +++ b/datatypes_conf.xml.sample Mon Jun 13 14:05:41 2011 +0200 @@ -116,6 +116,7 @@ <datatype extension="svg" type="galaxy.datatypes.images:Image" mimetype="image/svg+xml"/><datatype extension="taxonomy" type="galaxy.datatypes.tabular:Taxonomy" display_in_upload="true"/><datatype extension="tabular" type="galaxy.datatypes.tabular:Tabular" display_in_upload="true"/> + <datatype extension="twobit" type="galaxy.datatypes.binary:TwoBit" mimetype="application/octet-stream" display_in_upload="true"/><datatype extension="txt" type="galaxy.datatypes.data:Text" display_in_upload="true"/><datatype extension="memexml" type="galaxy.datatypes.xml:MEMEXml" mimetype="application/xml" display_in_upload="true"/><datatype extension="blastxml" type="galaxy.datatypes.xml:BlastXml" mimetype="application/xml" display_in_upload="true"/> @@ -279,6 +280,7 @@ defined format first, followed by next-most rigidly defined, and so on. --> + <sniffer type="galaxy.datatypes.binary:TwoBit"/><sniffer type="galaxy.datatypes.binary:Bam"/><sniffer type="galaxy.datatypes.binary:Sff"/><sniffer type="galaxy.datatypes.xml:BlastXml"/> --- a/lib/galaxy/datatypes/binary.py Mon Jun 13 10:47:51 2011 -0400 +++ b/lib/galaxy/datatypes/binary.py Mon Jun 13 14:05:41 2011 +0200 @@ -6,6 +6,10 @@ from galaxy.datatypes.metadata import MetadataElement from galaxy.datatypes import metadata from galaxy.datatypes.sniff import * +from galaxy import eggs +import pkg_resources +pkg_resources.require( "bx-python" ) +from bx.seq.twobit import TWOBIT_MAGIC_NUMBER, TWOBIT_MAGIC_NUMBER_SWAP, TWOBIT_MAGIC_SIZE from urllib import urlencode, quote_plus import zipfile, gzip import os, subprocess, tempfile @@ -292,3 +296,29 @@ def get_track_type( self ): return "LineTrack", {"data_standalone": "bigbed"} +class TwoBit (Binary): + """Class describing a TwoBit format nucleotide file""" + + file_ext = "twobit" + + def sniff(self, filename): + try: + input = file(filename) + magic = struct.unpack(">L", input.read(TWOBIT_MAGIC_SIZE))[0] + if magic == TWOBIT_MAGIC_NUMBER or magic == TWOBIT_MAGIC_NUMBER_SWAP: + return True + except IOError: + return False + + def set_peek(self, dataset, is_multi_byte=False): + if not dataset.dataset.purged: + dataset.peek = "Binary TwoBit format nucleotide file" + dataset.blurb = data.nice_size(dataset.get_size()) + else: + return super(TwoBit, self).set_peek(dataset, is_multi_byte) + + def display_peek(self, dataset): + try: + return dataset.peek + except: + return "Binary TwoBit format nucleotide file (%s)" % (data.nice_size(dataset.get_size())) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket