From ab4dc39a67ddecbd75fdf7090a2d773149f4baf5 Mon Sep 17 00:00:00 2001 From: Jim Johnson Date: Sun, 5 Jul 2015 04:33:39 -0500 Subject: [PATCH] Add datatype: galaxy.datatypes.proteomics:MzSQlite extension: mz.sqlite This is a SQLite schema for representing Peptide Spectral Matches from mzid and mzML datatypes. --- config/datatypes_conf.xml.sample | 2 ++ lib/galaxy/datatypes/proteomics.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config/datatypes_conf.xml.sample b/config/datatypes_conf.xml.sample index 02ab894525b..da8c9ef7e0c 100644 --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -167,6 +167,7 @@ + @@ -422,6 +423,7 @@ + diff --git a/lib/galaxy/datatypes/proteomics.py b/lib/galaxy/datatypes/proteomics.py index c505197c58d..020a35a9a5d 100644 --- a/lib/galaxy/datatypes/proteomics.py +++ b/lib/galaxy/datatypes/proteomics.py @@ -398,3 +398,28 @@ class XHunterAslFormat(Binary): class Sf3(Binary): """Class describing a Scaffold SF3 files""" file_ext = "sf3" + +class MzSQLite( SQlite ): + """Class describing a Proteomics Sqlite database """ + file_ext = "mz.sqlite" + + def set_meta( self, dataset, overwrite = True, **kwd ): + super( MzSQLite, self ).set_meta( dataset, overwrite = overwrite, **kwd ) + + def sniff( self, filename ): + if super( MzSQLite, self ).sniff( filename ): + mz_table_names = [ "DBSequence", "Modification", "Peaks", "Peptide", "PeptideEvidence", "Score", "SearchDatabase", "Source", "SpectraData", "Spectrum", "SpectrumIdentification] + 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 mz_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 +