[MMTK] energy minimizing a small molecule

Guido Wagner wagner at chemie.uni-frankfurt.de
Wed Sep 24 13:31:14 UTC 2008

Hi Robert !

In  MMTKs "PDB.py" is a dictionarray that contains the names of the 
molecules in the database ( heme an water). I did not check if it needs 
to contain the molecule name from your PDB / Database files for your 
approach to work, but maybee. I would try

configuration.createMolecules(['HHH'], 0)

this way you get an error message if  you have an unknown molecule. I 
think you either need  to  use database files alone (with the apropiate 
configuration already in it) or write some code that adds the 
"amber_atom_type"-attribute. I use a modified (for my own force field) 
version of the MMTK XML-molecule-factory, since this is a convinient way 
to have molecules and additional information in one file. I just added a 
"my_forcefield_atomType"-attribute to the atom-tags.

Once you sucessfully created a "universe" instance with your molecule, 
you may querry the internal koordinates like this:

for object in universe:
    for bonded in object.bondedUnits():

          bonds = bonded.bonds
          angles = bonded.bondAngles()
          impropers = []
          dihedrals = []
          for tor in bonded.dihedralAngles():
             if tor.improper:

You do not need to take care for the impropers yourself, while creating 
a molecule object, only atoms and bonds are required.


Robert Jorissen schrieb:
> G'day
> To get an idea of reading in small molecules into MMTK, I started with heme, since this molecule has an entry in the Database/Molecules/ directory in the MMTK package. The following script successfully reads in a heme molecule and performs energy minimization.
> #! /usr/bin/env python
> from MMTK import *
> from MMTK.ForceFields import Amber94ForceField
> from MMTK.PDB import PDBConfiguration
> universe = InfiniteUniverse(forcefield=Amber94ForceField())
> configuration = PDBConfiguration('hemeH_in.pdb')
> molecule = configuration.createMolecules(['HEM'], 1)
> universe.addObject(molecule)
> from MMTK.Minimization import ConjugateGradientMinimizer
> from MMTK.Trajectory import StandardLogOutput
> minimizer = ConjugateGradientMinimizer(universe,
>                               actions=[StandardLogOutput(50)])
> minimizer(convergence = 1.e-4, steps = 500)
> molecule.writeToFile('heme_out.pdb')
> # from MMTK.Visualization import view
> # view(universe)
> However, this approach has not worked for other molecules. If I make copies of the heme PDB file and the heme Database/Molecules entry, and only change the PDB name from "HEM" to "HHH", and run the modified Python script, I get the following error message:
> $ ./test_heme_alt.py
> Traceback (most recent call last):
>   File "./test_heme_alt.py", line 21, in <module>
>     minimizer(convergence = 1.e-4, steps = 500)
>   File "c:\Python25\lib\site-packages\MMTK\Minimization.py", line 195, in __call__
>     evaluator = self.universe.energyEvaluator(threads=nt).CEvaluator()
>   File "c:\Python25\lib\site-packages\MMTK\Universe.py", line 645, in energyEvaluator
>     threads, mpi_communicator)
>   File "c:\Python25\lib\site-packages\MMTK\ForceFields\ForceField.py", line 214, in __init__
>     self.global_data)
>   File "c:\Python25\lib\site-packages\MMTK\ForceFields\ForceField.py", line 121, in evaluatorTerms
>     global_data)
>   File "c:\Python25\lib\site-packages\MMTK\ForceFields\BondedInteractions.py", line 97, in evaluatorTerms
>     global_data)
>   File "c:\Python25\lib\site-packages\MMTK\ForceFields\MMForceField.py", line 82, in evaluatorParameters
>     self.collectAtomTypesAndIndices(universe, global_data)
>   File "c:\Python25\lib\site-packages\MMTK\ForceFields\MMForceField.py", line 48, in collectAtomTypesAndIndices
>     type[a] = o.getAtomProperty(a, self.dataset
>   File "c:\Python25\lib\site-packages\MMTK\ChemicalObjects.py", line 336, in getAtomProperty
>     return levels[-1].getAtomProperty(atom, property, levels[:-1])
>   File "c:\Python25\lib\site-packages\MMTK\ChemicalObjects.py", line 631, in getAtomProperty
>     return getattr(self, property)
>   File "c:\Python25\lib\site-packages\MMTK\ChemicalObjects.py", line 56, in __getattr__
>     return getattr(self.type, attr)
> AttributeError: AtomType instance has no attribute 'amber_atom_type'
> However, I figure that I am using the same atoms, atom connectivities and atom types, so there should not be missing forcefield parameters. Clearly I am missing something. I would appreciate it if someone could fill me in about this. And is the approach I used even the best way to read in a small molecule using MMTK? Also, I do not see a provision for adding improper angles. Are these automatically generated in MMTK?
> Thanks in advance,
> Rob Jorissen
> Ludwig Institute for Cancer Research, Melbourne branch
>       Make the switch to the world&#39;s best email. Get Yahoo!7 Mail! http://au.yahoo.com/y7mail
> ------------------------------------------------------------------------
> _______________________________________________
> mmtk maillist  -  mmtk at starship.python.net
> http://starship.python.net/mailman/listinfo/mmtk

More information about the mmtk mailing list