Skip to content
Snippets Groups Projects
forcefield.rst 21.94 KiB

Forcefields

The forcefields are a dump for interactions with their parameters, but also for atom specific information or residue definitions in the form of a :class:`BuildingBlock`. Objects for modifying residues can be set in form of :class:`BlockModifier` or :class:`HydrogenConstructor`. They're also involved in dealing with the naming mess we're observing in the molecular mechanics community and contain definable renaming rules that can be applied on an :class:`EntityHandle` for renaming from e.g. PDB standard to the forcefield specific standard. The standard forcefields in OpenStructure are loaded from the files provided by Gromacs and the "standard" naming is therefore the same. This has implications for controlling the protonation states for histidine. If you e.g. want to enforce a d-protonated histidine you have to name it HISD. Further reading can be found in the Gromacs Manual

Loading the standard forcefields provided by OpenStructure

Reading forcefields

The :class:`FFReader` builds up a :class:`Forcefield`, that gets updated with every call to the read functions. If the read files contain preprocessor statements as they are used in Gromacs, they will be applied to all subsequent lines read in. Parsed preprocessor statements are: #include, #define, #ifdef, #ifndef, #else and #endif

Note that this class is rather experimental. It has nevertheless been thoroughly tested for loading the CHARMM and AMBER forcefields in the Gromacs format. The reader is capable of resolving the preprocessor statements as they are used in Gromacs.

param base_dir: Base path of the reader. All loaded files must be defined relative to this base path.
type base_dir: :class:`str`
path = "path_to_gromacs/share/top/charmm27.ff"
reader = FFReader(path)

#read in the data given in forcefield.itp and atomtypes.atp
reader.ReadGromacsForcefield()

#we also want to read several residue databases
reader.ReadResidueDatabase("aminoacids")
reader.ReadResidueDatabase("rna")
reader.ReadResidueDatabase("dna")

#ions and water are also nice to have, they're stored in itp files
reader.ReadITP("tip3p")
reader.ReadITP("ions")

#let's finally get the reader internal forcefield out
ff = reader.GetForcefield()

#there is also an amazing ion definition in some other directory
new_reader = FFReader("path/to/directory/with/itp/files")

#we want to modify the previously read forcefield
new_reader.SetForcefield(ff)

#and read the amazing ion definition from an itp file
#note, that any previously defined preprocessor statements
#from the previous reader are lost
new_reader.ReadITP("amazing_ion")

#the new forcefield finally contains everything we need, lets
#extract it and save it down
ff = new_reader.GetForcefield()
ff.Save("charmm_forcefield.dat")

Generating forcefields with Antechamber

The antechamber submodule of mol.mm defines functions to use Antechamber (from AmberTools) to automatically generate force field parameters and load the results into :class:`~ost.mol.mm.Forcefield` objects.

Example usage:

from ost.mol import mm

# create parameters for RVP using PDB's component dictionary
mm.antechamber.RunAntechamber('RVP', 'components.cif', base_out_dir='ligands')

# create force field
ff = mm.Forcefield()
ff = mm.antechamber.AddFromPath(ff, 'ligands/RVP')
# equivalent: ff = mm.antechamber.AddFromFiles(ff, 'ligands/RVP/frcmod',
#                                              'ligands/RVP/out.mpdb')
# since Antechamber cannot deal with ions, you can do it manually
ff = mm.antechamber.AddIon(ff, 'CL', 'CL', 35.45, -1.0, 0.4401, 0.4184)
# save it
ff.Save('ligands/ff.dat')

Functions:

The Forcefield Class