[MMTK] Keep order of molecules

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Feb 9 17:23:50 UTC 2009

On 09.02.2009, at 14:51, Andreas Fuchs wrote:

> After completition of the simulation, I'd like to write a pdb file  
> which has the same atom order as in the MMTK-Inputfile.  
> Unfortunately, MMTK changes the order to somethin like c0, c01,  
> c02,..,c10,..,n0, and so on. How can I prevent MMTK from doing so?

Not at all. MMTK's internal model of molecules and molecular systems  
has no notion of atom order. There is a limited conservation of atom  
order when reading PDB and DCD files, which is necessary for  
importing data from other simulation programs. However, the only  
guarantee MMTK makes when writing PDB files is that the output file  
is physically equivalent to the system in memory. Atom order is not a  
physical observable, so there is no guarantee that it is preserved.  
Within a PDB file, the unique identifier of an atom is its name, not  
its position.

If you want to produce PDB files with a predefined order, you have to  
write your own routine to do so. Fortunately you can recycle a lot of  
the routines already present in MMTK and Scientific Python. The  
general approach would be:

1) Make up a list of the atoms in your system in the order that you  

2) Create an instance of Scientific.IO.PDBFile:


3) Loop over your atom list, calling the methods writeAtom,  
nextResidue, and nextChain as appropriate.

4) Close the file.

You can use the code of MMTK.PDB.PDBOutputFile for further  
inspiration. Note that Scientific.IO.PDBFile works in the PDB unit  
system, i.e. requires positions in Angstrom. You can easily convert  
MMTK's positions in nm by dividing by the predefined constant Units.Ang.

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: hinsen at cnrs-orleans.fr

More information about the mmtk mailing list