Gromacs TOP file format¶
Classes¶
-
class
gromacs.fileformats.top.
TOP
(fname)¶ Class to make a TOP object from a GROMACS processed.top file
The force-field and molecules data is exposed as python object.
Note
Only processed.top files generated by GROMACS ‘grompp -pp’ are supported - the usual topol.top files are not supported (yet!)
Initialize the TOP structure.
Arguments: - fname
name of the processed.top file
-
write
(filename)¶ Write the TOP object to a file
-
class
gromacs.fileformats.top.
SystemToGroTop
(system, outfile='output.top', multiple_output=False)¶ Converter class - represent TOP objects as GROMACS topology file.
Initialize GROMACS topology writer.
Arguments: - system
blocks.System
object, containing the topology- outfile
name of the file to write to
- multiple_output
if True, write moleculetypes to separate files, named mol_MOLNAME.itp (default: False)
-
assemble_topology
()¶ Call the various member self._make_* functions to convert the topology object into a string
History¶
Sources adapted from code by Reza Salari https://github.com/resal81/PyTopol
Example: Read a processed.top file and scale charges¶
Run grompp -pp
to produce a processed.top from conf.gro, grompp.mdp and topol.top files:
$ grompp -pp
This file now containts all the force-field information:
from gromacs.fileformats import TOP
top = TOP("processed.top")
Scale the LJ epsilon by an arbitrary number, here 0.9
scaling = 0.9
for at in top.atomtypes:
at.gromacs['param']['lje'] *= scaling
Write out the scaled down topology:
top.write("output.top")
Note
You can use this to prepare a series of top files for Hamiltonian Replica
Exchange (HREX) simulations. See scripts/gw-partial_tempering.py
for an example.