Change in ensembl DB causing major errors!!

Help
Nick Schurch
2012-08-23
2013-04-29
  • Nick Schurch
    Nick Schurch
    2012-08-23

    I'm using python 2.6.4, ipython 0.13, and pycogent 1.5.1. When I try to get a gene by stable ID I get an error that boils down to "Table 'homo_sapiens_core_68_37.gene_stable_id' doesn't exist". This is because it doesn't. Ensembl changes the database structure going from v66 to v67 and this table was a casualty.

    Unless there is a more recent version of pycogent that this is fixed in, this is a major problem. Am I missing something?

    nanna.cluster.lifesci.dundee.ac.uk > /sw/bin/ipython
    Python 2.6.4 (r264:75706, Sep 10 2010, 16:37:14)
    Type "copyright", "credits" or "license" for more information.
    IPython 0.13 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    In [1]: import cogent.db.ensembl
    In [2]: cogent.db.ensembl.__version__
    Out[2]: '1.5.1'
    In [3]: compara = Compara(["human","chicken"], Release=68)
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    <ipython-input-3-eaa3c6aed488> in <module>()
    ----> 1 compara = Compara(["human","chicken"], Release=68)
    NameError: name 'Compara' is not defined
    In [4]: from cogent.db.ensembl import *
    In [5]: compara = Compara(["human","chicken"], Release=68)
    In [6]: egene = compara.Human.getGeneByStableId(StableId="ENSG00000111642")
    ---------------------------------------------------------------------------
    ProgrammingError                          Traceback (most recent call last)
    <ipython-input-6-0d70b62abba8> in <module>()
    ----> 1 egene = compara.Human.getGeneByStableId(StableId="ENSG00000111642")
    /sw/opt/lib/python2.6/site-packages/cogent/db/ensembl/genome.pyc in getGeneByStableId(self, StableId)
        209     def getGeneByStableId(self, StableId):
        210         """returns the gene matching StableId, or None if no record found"""
    --> 211         query = self._get_gene_query(self.CoreDb, StableId=StableId)
        212         try:
        213             record = list(query.execute())[0]
    /sw/opt/lib/python2.6/site-packages/cogent/db/ensembl/genome.pyc in _get_gene_query(self, db, Symbol, Description, StableId, BioType, synonym, like)
        187         xref_table = [None, db.getTable('xref')][db.Type == 'core']
        188         gene_table = db.getTable('gene')
    --> 189         gene_id_table = db.getTable('gene_stable_id')
        190
        191         assert Symbol or Description or StableId or BioType, "no valid argument provided"
    /sw/opt/lib/python2.6/site-packages/cogent/db/ensembl/database.pyc in getTable(self, name)
         41         table = self._tables.get(name, None)
         42         if table is None:
    ---> 43             c = self._db.execute("DESCRIBE %s" % name)
         44             custom_columns = []
         45             for r in c.fetchall():
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in execute(self, statement, *multiparams, **params)
       1786
       1787         connection = self.contextual_connect(close_with_result=True)
    -> 1788         return connection.execute(statement, *multiparams, **params)
       1789
       1790     def scalar(self, statement, *multiparams, **params):
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in execute(self, object, *multiparams, **params)
       1189                                                 object,
       1190                                                 multiparams,
    -> 1191                                                 params)
       1192         else:
       1193             raise exc.InvalidRequestError(
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in _execute_text(self, statement, multiparams, params)
       1285                                 statement=statement,
       1286                                 parameters=parameters)
    -> 1287         return self.__execute_context(context)
       1288
       1289     def __execute_context(self, context):
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in __execute_context(self, context)
       1300                             context.cursor,
       1301                             context.statement,
    -> 1302                             context.parameters[0], context=context)
       1303
       1304         if context.compiled:
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in _cursor_execute(self, cursor, statement, parameters, context)
       1399                                 parameters,
       1400                                 cursor,
    -> 1401                                 context)
       1402             raise
       1403
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/base.pyc in _cursor_execute(self, cursor, statement, parameters, context)
       1392                                 statement,
       1393                                 parameters,
    -> 1394                                 context)
       1395         except Exception, e:
       1396             self._handle_dbapi_exception(
    /homes/nschurch/cluster_installs/python_modules/SQLAlchemy-0.6.7/SQLAlchemy-0.6.7-py2.6.egg/sqlalchemy/engine/default.pyc in do_execute(self, cursor, statement, parameters, context)
        297
        298     def do_execute(self, cursor, statement, parameters, context=None):
    --> 299         cursor.execute(statement, parameters)
        300
        301     def is_disconnect(self, e):
    /sw/lib/python2.6/site-packages/MySQLdb/cursors.pyc in execute(self, query, args)
        172             del tb
        173             self.messages.append((exc, value))
    --> 174             self.errorhandler(self, exc, value)
        175         self._executed = query
        176         if not self._defer_warnings: self._warning_check()
    /sw/lib/python2.6/site-packages/MySQLdb/connections.pyc in defaulterrorhandler(***failed resolving arguments***)
         34     del cursor
         35     del connection
    ---> 36     raise errorclass, errorvalue
         37
         38 re_numeric_part = re.compile(r"^(\d+)")
    ProgrammingError: (ProgrammingError) (1146, "Table 'homo_sapiens_core_68_37.gene_stable_id' doesn't exist") 'DESCRIBE gene_stable_id' ()
    
     
  • gav
    gav
    2012-08-23

    This is a known bug that has been fixed in the svn repository. Instructions for getting access to the repository are here.

    With the latest svn revision, I get:

    >>> from cogent.db.ensembl import *
    >>> compara = Compara(["human","chicken"], Release=68)
    >>> egene = compara.Human.getGeneByStableId(StableId="ENSG00000111642")
    >>> print egene
    Gene(Species='Homo sapiens'; BioType='protein_coding'; Description='chromodomain helicase DNA...'; StableId='ENSG0000011164
    2'; Status='KNOWN'; Symbol='CHD4')
    >>>
    
     
  • Nick Schurch
    Nick Schurch
    2012-08-27

    Cheers. I ended up rolling my own wrapper script for a straight sql query in end, but its nice to know pycogent has caught the repo version.