Mercurial > repos > matt-shirley > ncbi_sra_toolkit
changeset 6:e4c21444a3ba
Add sniffer, clean up imports, register sniffable datatype.
author | Matt Shirley <mdshw5@gmail.com> |
---|---|
date | Thu, 13 Mar 2014 15:30:54 -0400 |
parents | 76c7d617cd56 |
children | e724bff23fb6 |
files | datatypes_conf.xml sra.py |
diffstat | 2 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/datatypes_conf.xml Mon Oct 07 10:13:06 2013 -0400 +++ b/datatypes_conf.xml Thu Mar 13 15:30:54 2014 -0400 @@ -4,6 +4,9 @@ <datatype_file name="sra.py"/> </datatype_files> <registration> - <datatype extension="sra" type="galaxy.datatypes.sra:sra" display_in_upload="true"/> + <datatype extension="sra" type="galaxy.datatypes.binary:Sra" mimetype="application/octet-stream" display_in_upload="true"/> </registration> + <sniffers> + <sniffer type="galaxy.datatypes.binary:Sra"/> + </sniffers> </datatypes>
--- a/sra.py Mon Oct 07 10:13:06 2013 -0400 +++ b/sra.py Thu Mar 13 15:30:54 2014 -0400 @@ -3,23 +3,21 @@ """ import logging import binascii -from galaxy.datatypes.data import * -from galaxy.datatypes.sniff import * -from galaxy.datatypes.binary import * -from galaxy.datatypes.metadata import * +from galaxy.datatypes.data import nice_size +from galaxy.datatypes.binary import Binary log = logging.getLogger(__name__) -class sra( Binary ): +class Sra(Binary): """ Sequence Read Archive (SRA) """ file_ext = 'sra' def __init__( self, **kwd ): Binary.__init__( self, **kwd ) + def sniff( self, filename ): - """ The first 8 bytes of any NCBI sra file is 'NCIB.sra', and the file is binary. EBI and DDBJ files may differ, though EBI and DDBJ - submissions through NCBI (ERR and DRR accessions) read 'NCBI.sra'. - For details about the format, see http://www.ncbi.nlm.nih.gov/books/n/helpsra/SRA_Overview_BK/#SRA_Overview_BK.4_SRA_Data_Structure + """ The first 8 bytes of any NCBI sra file is 'NCBI.sra', and the file is binary. + For details about the format, see http://www.ncbi.nlm.nih.gov/books/n/helpsra/SRA_Overview_BK/#SRA_Overview_BK.4_SRA_Data_Structure """ try: header = open(filename).read(8) @@ -29,18 +27,19 @@ return False except: return False + def set_peek(self, dataset, is_multi_byte=False): if not dataset.dataset.purged: dataset.peek = 'Binary sra file' - dataset.blurb = data.nice_size(dataset.get_size()) + 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 sra file (%s)' % ( data.nice_size(dataset.get_size())) + return 'Binary sra file (%s)' % (nice_size(dataset.get_size())) -if hasattr(Binary, 'register_sniffable_binary_format'): - Binary.register_sniffable_binary_format('sra', 'sra', sra) \ No newline at end of file +Binary.register_sniffable_binary_format('sra', 'sra', 'Sra')