Skip to content

Instantly share code, notes, and snippets.

@CS76
Last active December 7, 2015 13:21
Show Gist options
  • Save CS76/5afd1d3c9689b5b0f397 to your computer and use it in GitHub Desktop.
Save CS76/5afd1d3c9689b5b0f397 to your computer and use it in GitHub Desktop.
cdf Datatype Extension - IPO - Galaxy
""" ipo-galaxy/lib/galaxy/datatypes/binary.py """
class Cdf( Binary ):
"""Generic CDF file datatype implementation"""
file_ext = 'cdf'
def __init__( self, **kwd ):
Binary.__init__( self, **kwd )
def sniff( self, filename ):
cdf_header = binascii.hexlify('CDF')
try:
header = open(filename).read(3)
if binascii.b2a_hex(header) == cdf_header:
return True
header = gzip.open( filename ).read(3)
if binascii.b2a_hex(header) == cdf_header:
return True
except:
return False
Binary.register_sniffable_binary_format('cdf', 'cdf', Cdf)
<!-- ipo-galaxy/config/datatypes_conf.xml -->
// sniffer
<sniffer type="galaxy.datatypes.binary:Cdf" />
// registration
<!-- Metabolomics Data types -->
<datatype extension="cdf" type="galaxy.datatypes.binary:Cdf" display_in_upload="true" description="Metabolights study formats"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment