commit/galaxy-central: dan: Add gemini.sqlite datatype.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/55553f94d810/ Changeset: 55553f94d810 User: dan Date: 2015-01-09 19:48:56+00:00 Summary: Add gemini.sqlite datatype. Affected #: 3 files diff -r 63d901ca0e6e9cfa405bae41f7088e3fa6bf243f -r 55553f94d810f4ce3ff44a46b439690003d848cb config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -181,7 +181,8 @@ <datatype extension="taxonomy" type="galaxy.datatypes.tabular:Taxonomy" display_in_upload="true"/><datatype extension="tabular" type="galaxy.datatypes.tabular:Tabular" display_in_upload="true" description="Any data in tab delimited format (tabular)." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Tabular_.28tab_delimited.29"/><datatype extension="twobit" type="galaxy.datatypes.binary:TwoBit" mimetype="application/octet-stream" display_in_upload="true"/> - <datatype extension="sqlite" type="galaxy.datatypes.binary:SQlite" mimetype="application/octet-stream" display_in_upload="true"/> + <datatype extension="sqlite" type="galaxy.datatypes.binary:SQlite" mimetype="application/octet-stream" display_in_upload="true"/> + <datatype extension="gemini.sqlite" type="galaxy.datatypes.binary:GeminiSQLite" mimetype="application/octet-stream" display_in_upload="True" /><datatype extension="txt" type="galaxy.datatypes.data:Text" display_in_upload="true" description="Any text file." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Plain_text"/><datatype extension="linecount" type="galaxy.datatypes.data:LineCount" display_in_upload="false"/><datatype extension="memexml" type="galaxy.datatypes.xml:MEMEXml" mimetype="application/xml" display_in_upload="true"/> @@ -271,6 +272,7 @@ --><sniffer type="galaxy.datatypes.tabular:Vcf"/><sniffer type="galaxy.datatypes.binary:TwoBit"/> + <sniffer type="galaxy.datatypes.binary:GeminiSQLite"/><sniffer type="galaxy.datatypes.binary:SQlite"/><sniffer type="galaxy.datatypes.binary:Bam"/><sniffer type="galaxy.datatypes.binary:Sff"/> diff -r 63d901ca0e6e9cfa405bae41f7088e3fa6bf243f -r 55553f94d810f4ce3ff44a46b439690003d848cb lib/galaxy/datatypes/binary.py --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -20,7 +20,7 @@ from bx.seq.twobit import TWOBIT_MAGIC_NUMBER, TWOBIT_MAGIC_NUMBER_SWAP, TWOBIT_MAGIC_SIZE from galaxy.util import sqlite -from galaxy.datatypes.metadata import MetadataElement,ListParameter,DictParameter +from galaxy.datatypes.metadata import MetadataElement, MetadataParameter, ListParameter, DictParameter from galaxy.datatypes import metadata import dataproviders @@ -640,8 +640,66 @@ return dataproviders.dataset.SQliteDataDictProvider( dataset_source, **settings ) +#Binary.register_sniffable_binary_format("sqlite", "sqlite", SQlite) + + +class GeminiSQLite( SQlite ): + """Class describing a Gemini Sqlite database """ + MetadataElement( name="gemini_version", default='0.10.0' , param=MetadataParameter, desc="Gemini Version", + readonly=True, visible=True, no_value='0.10.0' ) + file_ext = "gemini.sqlite" + + def set_meta( self, dataset, overwrite = True, **kwd ): + super( GeminiSQLite, self ).set_meta( dataset, overwrite = overwrite, **kwd ) + try: + conn = sqlite.connect( dataset.file_name ) + c = conn.cursor() + tables_query = "SELECT version FROM version" + result = c.execute( tables_query ).fetchall() + for version, in result: + dataset.metadata.gemini_version = version + # TODO: Can/should we detect even more attributes, such as use of PED file, what was input annotation type, etc. + except Exception, e: + log.warn( '%s, set_meta Exception: %s', self, e ) + + def sniff( self, filename ): + if super( GeminiSQLite, self ).sniff( filename ): + gemini_table_names = [ "gene_detailed", "gene_summary", "resources", "sample_genotype_counts", "sample_genotypes", "samples", + "variant_impacts", "variants", "version" ] + try: + conn = sqlite.connect( filename ) + c = conn.cursor() + tables_query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name" + result = c.execute( tables_query ).fetchall() + result = map( lambda x: x[0], result ) + for table_name in gemini_table_names: + if table_name not in result: + return False + return True + except Exception, e: + log.warn( '%s, sniff Exception: %s', self, e ) + return False + + def set_peek( self, dataset, is_multi_byte=False ): + if not dataset.dataset.purged: + dataset.peek = "Gemini SQLite Database, version %s" % ( dataset.metadata.gemini_version or 'unknown' ) + dataset.blurb = data.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 "Gemini SQLite Database, version %s" % ( dataset.metadata.gemini_version or 'unknown' ) + +Binary.register_sniffable_binary_format( "gemini.sqlite", "gemini.sqlite", GeminiSQLite ) +# FIXME: We need to register gemini.sqlite before sqlite, since register_sniffable_binary_format and is_sniffable_binary called in upload.py +# ignores sniff order declared in datatypes_conf.xml Binary.register_sniffable_binary_format("sqlite", "sqlite", SQlite) + class Xlsx(Binary): """Class for Excel 2007 (xlsx) files""" file_ext="xlsx" diff -r 63d901ca0e6e9cfa405bae41f7088e3fa6bf243f -r 55553f94d810f4ce3ff44a46b439690003d848cb tools/data_source/upload.py --- a/tools/data_source/upload.py +++ b/tools/data_source/upload.py @@ -113,6 +113,8 @@ ext = sniff.guess_ext( dataset.path, is_multi_byte=True ) # Is dataset content supported sniffable binary? else: + # FIXME: This ignores the declared sniff order in datatype_conf.xml + # resulting in improper behavior type_info = Binary.is_sniffable_binary( dataset.path ) if type_info: data_type = type_info[0] 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)
-
commits-noreply@bitbucket.org