Skip to content

Commit

Permalink
Merge pull request #2706 from lecorguille/add_netcdf_datatype
Browse files Browse the repository at this point in the history
add a netcdf datatype for metabolomics spectre data
  • Loading branch information
bgruening committed Aug 4, 2016
2 parents 65f0a83 + 37a0ec5 commit 7efa1e0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<datatype extension="searchgui_archive" type="galaxy.datatypes.binary:SearchGuiArchive" display_in_upload="True"/>
<datatype extension="peptideshaker_archive" type="galaxy.datatypes.binary:CompressedArchive" subclass="True" display_in_upload="True"/>
<!-- End Proteomics Datatypes -->
<datatype extension="netcdf" type="galaxy.datatypes.binary:NetCDF" mimetype="application/octet-stream" display_in_upload="true" description="Format used by netCDF software library for writing and reading chromatography-MS data files." />
<datatype extension="eps" type="galaxy.datatypes.images:Eps" mimetype="image/eps"/>
<datatype extension="rast" type="galaxy.datatypes.images:Rast" mimetype="image/rast"/>
<datatype extension="laj" type="galaxy.datatypes.images:Laj"/>
Expand Down Expand Up @@ -575,6 +576,7 @@
<sniffer type="galaxy.datatypes.binary:CRAM"/>
<sniffer type="galaxy.datatypes.binary:Sff"/>
<sniffer type="galaxy.datatypes.binary:Sra"/>
<sniffer type="galaxy.datatypes.binary:NetCDF"/>
<sniffer type="galaxy.datatypes.triples:Rdf"/>
<sniffer type="galaxy.datatypes.xml:Phyloxml"/>
<sniffer type="galaxy.datatypes.xml:Owl"/>
Expand Down
33 changes: 33 additions & 0 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,3 +1331,36 @@ def display_peek( self, dataset ):
return "SearchGUI Archive, version %s" % ( dataset.metadata.searchgui_version or 'unknown' )

Binary.register_sniffable_binary_format("searchgui_archive", "searchgui_archive", SearchGuiArchive)


class NetCDF( Binary ):
"""Binary data in netCDF format"""
file_ext = "netcdf"
edam_format = "format_3650"
edam_data = "data_0943"

def set_peek( self, dataset, is_multi_byte=False ):
if not dataset.dataset.purged:
dataset.peek = "Binary netCDF file"
dataset.blurb = nice_size( dataset.get_size() )
else:
dataset.peek = 'file does not exist'
dataset.blurb = 'file purged from disk'

def display_peek( self, dataset ):
try:
return dataset.peek
except:
return "Binary netCDF file (%s)" % ( nice_size( dataset.get_size() ) )

def sniff( self, filename ):
try:
with open( filename, 'r' ) as f:
header = f.read(3)
if binascii.b2a_hex( header ) == binascii.hexlify( 'CDF' ):
return True
return False
except:
return False

Binary.register_sniffable_binary_format("netcdf", "netcdf", NetCDF)

0 comments on commit 7efa1e0

Please sign in to comment.