[MMTK] adding pdb file to universe

Konrad Hinsen research at khinsen.fastmail.net
Fri Feb 3 11:11:49 UTC 2012


Ivan Vyalov writes:

 > thank you for the help! I tried to isolate the problem and the only
 > change that makes PDB working is the justification of the element
 > field 76-78, a namely if "F" is in position 76 it doesn't work and
 > it works if "F" is in 78.

Which is where it is supposed to be, although the various versions of
the PDB format definition don't all agree on this.

 > It looks to me that MMTK was looking for element "F "(with
 > space. Indeed, when I copied Atoms/f to "Atoms/f " everything
 > works) in the database. Probably, one should strip the element name
 > before looking in the database, something like this:

That sounds like a good idea, but I'd rather do this in MMTK and at
the level of database lookup. The PDB handling code in ScientificPython
and MMTK is supposed to do no more than pass on the data from the PDB
file. There may even be client code that relies on the spaces being
passed along.

Here is my proposed patch. Can yoy please check if that works for you?

Konrad.
-- 
---------------------------------------------------------------------
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: research AT khinsen DOT fastmail DOT net
http://dirac.cnrs-orleans.fr/~hinsen/
---------------------------------------------------------------------

diff -r 419dee1df16b MMTK/PDB.py
--- a/MMTK/PDB.py	Mon Jan 30 20:52:35 2012 +0100
+++ b/MMTK/PDB.py	Fri Feb 03 12:10:14 2012 +0100
@@ -375,11 +375,11 @@
                             while aname[0] in string.digits:
                                 aname = aname[1:] + aname[0]
                             try:
-                                element = atom['element']
+                                element = atom['element'].strip()
                                 a = ChemicalObjects.Atom(element, name = aname)
                             except KeyError:
                                 try:
-                                    a = ChemicalObjects.Atom(aname[:2],
+                                    a = ChemicalObjects.Atom(aname[:2].strip(),
                                                              name = aname)
                                 except IOError:
                                     a = ChemicalObjects.Atom(aname[:1],




More information about the mmtk mailing list