Hi all,
I want to color code scop domains in PDB entries by querrying a database
server.
It works fine if I just call the function from the python script,
however if I define the function to be a Pymol fct, the call from pymol
causes an undefined MySQL Error in subchainString:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/pymol/parser.py", line 255, in
parse
exec(com2[nest]+"\n",pymol_names,pymol_names)
File "<string>", line 1, in ?
File "scop1.py", line 19, in domainDef
cmd.select("domain", "/%s//%s/"%(pdb, subchainString(px)))
File "scop1.py", line 11, in subchainString
cursor.execute("SELECT chain_id, begin, end FROM subchain WHERE
subchain.px='%s' LIMIT 1"% px )
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 95,
in execute
return self._execute(query, args)
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 114,
in _execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
33, in defaulterrorhandler
raise errorclass, errorvalue
InterfaceError: (0, '')
I have a suspecion it's to do with the quoting?
Also, is there a command similar to Rasmol's "pause"? Or do I have to use
raw_input in the terminal I called pymol from?
Here is the simplified code:
##################################################################################
pdbLinkDir="/group/bioinf/Data/PDBLinks/"
from pymol import cmd
from pymol.cgo import *
import MySQLdb
from MySQLdb.cursors import DictCursor
def subchainString(px):
cursor.execute("SELECT chain_id, begin, end FROM subchain WHERE subchain.px='%s'
LIMIT 1"% px )
data=cursor.fetchone()
if data["begin"]: return "%s/%s-%s"%(data["chain_id"], data["begin"],
data["end"])
else: return "%s"%(data["chain_id"])
def domainDef(px, pdb):
cmd.load(pdbLinkDir+"%s.pdb"%pdb)
cmd.hide("everything","all")
cmd.select("domain", "/%s//%s/"%(pdb, subchainString(px)))
cmd.color("blue","domain")
cmd.show("cartoon", "all")
conn = MySQLdb.connect(db="pqs_psimap", host="dbserver", user="...",
passwd="...")
cursor = conn.cursor(DictCursor)
#domainDef("25880E", "1tab") ## This works fine!!!
cmd.extend("domainDef", domainDef) ## breaks when called from pymol with
## domainDef("25880E", "1tab")
conn.close()
##################################################################################
Many thanks
--
Andreas Henschel
Bioinformatics Group
TU Dresden
Tatzberg 47-51
01307 Dresden, Germany
Phone: +49 351 463 40063
EMail: a...@biotec.tu-dresden.de