[chimera-dev] mol2-parser reorders entries

Eric Pettersen pett at cgl.ucsf.edu
Wed Sep 24 15:05:41 PDT 2003


On Wednesday, September 24, 2003, at 08:18 AM, Lars Kunert wrote:

> I do like to reference chimera-atoms from my extension. I have the 
> problem
> that chimera reorders the atoms (and probably also the bond entries) of
> mol2 files.
> Which of the following workarounds would you suggest:
> - resort all my mol2-files -> will only work if the resorting ist 
> stable
> - use a dictionary -> puts some unwellcome functionallity into my
> python-wrapper
> - refer by name -> mol2-atom names do not have to be unique and will be
> slow without a dictionary
> or is there a way to switch it of???

Hi Lars,
	As you have discovered, Chimera reorders the atoms into a sequence 
that is more useful for itself (graph traversal order).  However, each 
atom has a 'serialNumber' field that corresponds to the order in the 
input file.  So, if 'mol' is a Python reference to your molecule, you 
can get a list of atoms in input order with:

	atoms = mol.atoms
	atoms.sort(lambda a, b: cmp(a.serialNumber, b.serialNumber))

                        Eric Pettersen
                         UCSF Computer Graphics Lab
                         pett at cgl.ucsf.edu
                         http://www.cgl.ucsf.edu



More information about the Chimera-dev mailing list