Entering edit mode
10.9 years ago
pld
5.1k
I am attempting to connect to ensembl with pycogent. Their tutorial unfortunately assumes that you've installed the database locally so I am not sure that I am doing this correctly with the useastdb.ensembl.org. I get an error stating that there was an issue creating the cursor, I am thinking that MySQLdb is having trouble connecting.
import re, csv, sys
from cogent.db.ensembl import HostAccount
from cogent.db.ensembl import Genome
account = HostAccount("useastdb.ensembl.org", "anonymous", "", port=5306)
human = Genome("human", Release=67, account=account)
print human
genes = human.getGenesMatching(Symbol="BRCA2")
for gene in genes:
print gene
Here is the resulting output:
Genome(Species='Homo sapiens'; Release='67')
Traceback (most recent call last):
File "query-ensembl.py", line 9, in <module>
for gene in genes:
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 271, in getGenesMatching
query = self._get_gene_query(self.CoreDb, **args)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 121, in _get_core_db
self._connect_db('core')
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 111, in _connect_db
self._core_db = Database(db_type='core', **connection)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/database.py", line 22, in __init__
release=release, db_type=db_type, division=division)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/host.py", line 94, in get_db_name
cursor = server.cursor()
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 243, in cursor
return (cursorclass or self.cursorclass)(self)
AttributeError: 'Connection' object has no attribute 'cursorclass'
I have also tried "password" and "-" for the password and get a different error:
Genome(Species='Homo sapiens'; Release='67')
Traceback (most recent call last):
File "query-ensembl.py", line 9, in <module>
for gene in genes:
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 271, in getGenesMatching
query = self._get_gene_query(self.CoreDb, **args)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 121, in _get_core_db
self._connect_db('core')
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/genome.py", line 111, in _connect_db
self._core_db = Database(db_type='core', **connection)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/database.py", line 22, in __init__
release=release, db_type=db_type, division=division)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/host.py", line 93, in get_db_name
server = DbConnection(account, db_name='PARENT')
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/cogent/db/ensembl/host.py", line 57, in __call__
passwd=account.passwd, port=account.port)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/local/Python/2.7.3/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'anonymous'@'128.231.2.3' (using password: YES)")