4.22. Utility functions for the TPR topology parser

The MDAnalysis.topology.tpr module contains classes and functions on which the Gromacs TPR topology reader TPRParser is built.

4.22.1. TPR support

The MDAnalysis.topology.tpr module is required for the MDAnalysis.topology.TPRParser module.

MDAnalysis.topology.tpr.SUPPORTED_VERSIONS = (58, 73, 83, 100, 103)

tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable’s items

If the argument is a tuple, the return value is the same object.

Sub-modules

4.22.2. TPRParser settings

Definition of constants.

The currently read file format versions are defined in SUPPORTED_VERSIONS.

MDAnalysis.topology.tpr.setting.SUPPORTED_VERSIONS = (58, 73, 83, 100, 103)

Gromacs TPR file format versions that can be read by the TPRParser.

MDAnalysis.topology.tpr.setting.ftupd = [(20, 3), (20, 4), (20, 5), (34, 6), (43, 7), (43, 8), (70, 9), (98, 12), (76, 13), (30, 14), (30, 15), (30, 16), (34, 17), (43, 18), (98, 21), (98, 22), (26, 23), (26, 25), (43, 26), (65, 27), (60, 28), (61, 29), (61, 30), (72, 31), (72, 32), (41, 35), (41, 36), (32, 40), (32, 44), (32, 45), (93, 46), (46, 47), (30, 48), (36, 50), (90, 53), (22, 55), (22, 56), (22, 57), (26, 60), (26, 61), (49, 71), (50, 72), (46, 73), (20, 74), (46, 78), (69, 80), (66, 81), (54, 83), (76, 51), (79, 86), (79, 87), (79, 88), (79, 89), (79, 90)]

Function types from <gromacs_dir>/src/gmxlib/tpxio.c

MDAnalysis.topology.tpr.setting.interaction_types = [('BONDS', 'Bond', 2), ('G96BONDS', 'G96Bond', 2), ('MORSE', 'Morse', 2), ('CUBICBONDS', 'Cubic Bonds', 2), ('CONNBONDS', 'Connect Bonds', 2), ('HARMONIC', 'Harmonic Pot.', 2), ('FENEBONDS', 'FENE Bonds', 2), ('TABBONDS', 'Tab. Bonds', 2), ('TABBONDSNC', 'Tab. Bonds NC', 2), ('RESTRAINTPOT', 'Restraint Pot.', 2), ('ANGLES', 'Angle', 3), ('G96ANGLES', 'G96Angle', 3), ('RESTRANGLES', 'Restricted Angles', 3), ('LINEAR_ANGLES', 'Lin. Angle', 3), ('CROSS_BOND_BOND', 'Bond-Cross', 3), ('CROSS_BOND_ANGLE', 'BA-Cross', 3), ('UREY_BRADLEY', 'U-B', 3), ('QANGLES', 'Quartic Angles', 3), ('TABANGLES', 'Tab. Angles', 3), ('PDIHS', 'Proper Dih.', 4), ('RBDIHS', 'Ryckaert-Bell.', 4), ('RESTRDIHS', 'Restricted Dih.', 4), ('CBTDIHS', 'CBT Dih.', 4), ('FOURDIHS', 'Fourier Dih.', 4), ('IDIHS', 'Improper Dih.', 4), ('PIDIHS', 'Improper Dih.', 4), ('TABDIHS', 'Tab. Dih.', 4), ('CMAP', 'CMAP Dih.', 5), ('GB12', 'GB 1-2 Pol.', 2), ('GB13', 'GB 1-3 Pol.', 2), ('GB14', 'GB 1-4 Pol.', 2), ('GBPOL', 'GB Polarization', None), ('NPSOLVATION', 'Nonpolar Sol.', None), ('LJ14', 'LJ-14', 2), ('COUL14', 'Coulomb-14', None), ('LJC14_Q', 'LJC-14 q', 2), ('LJC_NB', 'LJC Pairs NB', 2), ('LJ_SR', 'LJ (SR)', 2), ('BHAM', 'Buck.ham (SR)', 2), ('LJ_LR', 'LJ (LR)', None), ('BHAM_LR', 'Buck.ham (LR)', None), ('DISPCORR', 'Disper. corr.', None), ('COUL_SR', 'Coulomb (SR)', None), ('COUL_LR', 'Coulomb (LR)', None), ('RF_EXCL', 'RF excl.', None), ('COUL_RECIP', 'Coul. recip.', None), ('LJ_RECIP', 'LJ recip.', None), ('DPD', 'DPD', None), ('POLARIZATION', 'Polarization', 2), ('WATERPOL', 'Water Pol.', 5), ('THOLE', 'Thole Pol.', 4), ('ANHARM_POL', 'Anharm. Pol.', 2), ('POSRES', 'Position Rest.', 1), ('FBPOSRES', 'Flat-bottom posres', 1), ('DISRES', 'Dis. Rest.', 2), ('DISRESVIOL', 'D.R.Viol. (nm)', None), ('ORIRES', 'Orient. Rest.', 2), ('ORDEV', 'Ori. R. RMSD', None), ('ANGRES', 'Angle Rest.', 4), ('ANGRESZ', 'Angle Rest. Z', 2), ('DIHRES', 'Dih. Rest.', 4), ('DIHRESVIOL', 'Dih. Rest. Viol.', None), ('CONSTR', 'Constraint', 2), ('CONSTRNC', 'Constr. No Conn.', 2), ('SETTLE', 'Settle', 3), ('VSITE2', 'Virtual site 2', 3), ('VSITE3', 'Virtual site 3', 4), ('VSITE3FD', 'Virtual site 3fd', 4), ('VSITE3FAD', 'Virtual site 3fad', 4), ('VSITE3OUT', 'Virtual site 3out', 4), ('VSITE4FD', 'Virtual site 4fd', 5), ('VSITE4FDN', 'Virtual site 4fdn', 5), ('VSITEN', 'Virtual site N', 2), ('COM_PULL', 'COM Pull En.', None), ('EQM', 'Quantum En.', None), ('EPOT', 'Potential', None), ('EKIN', 'Kinetic En.', None), ('ETOT', 'Total Energy', None), ('ECONS', 'Conserved En.', None), ('TEMP', 'Temperature', None), ('VTEMP', 'Vir. Temp. (not used)', None), ('PDISPCORR', 'Pres. DC', None), ('PRES', 'Pressure', None), ('DH/DL_CON', 'dH/dl constr.', None), ('DV/DL', 'dVremain/dl', None), ('DK/DL', 'dEkin/dl', None), ('DVC/DL', 'dVcoul/dl', None), ('DVV/DL', 'dVvdw/dl', None), ('DVB/DL', 'dVbonded/dl', None), ('DVR/DL', 'dVrestraint/dl', None), ('DVT/DL', 'dVtemperature/dl', None)]

Interaction types from <gromacs_dir>/gmxlib/ifunc.c

4.22.3. Class definitions for the TPRParser

class MDAnalysis.topology.tpr.obj.Atom(m, q, mB, qB, tp, typeB, ptype, resind, atomnumber)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

atomnumber

Alias for field number 8

m

Alias for field number 0

mB

Alias for field number 2

ptype

Alias for field number 6

q

Alias for field number 1

qB

Alias for field number 3

resind

Alias for field number 7

tp

Alias for field number 4

typeB

Alias for field number 5

class MDAnalysis.topology.tpr.obj.AtomKind(id, name, type, resid, resname, mass, charge)[source]
class MDAnalysis.topology.tpr.obj.Atoms(atoms, nr, nres, type, typeB, atomnames, resnames)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

atomnames

Alias for field number 5

atoms

Alias for field number 0

nr

Alias for field number 1

nres

Alias for field number 2

resnames

Alias for field number 6

type

Alias for field number 3

typeB

Alias for field number 4

class MDAnalysis.topology.tpr.obj.Box(size, rel, v)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

rel

Alias for field number 1

size

Alias for field number 0

v

Alias for field number 2

class MDAnalysis.topology.tpr.obj.Ilist(nr, ik, iatoms)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

iatoms

Alias for field number 2

ik

Alias for field number 1

nr

Alias for field number 0

class MDAnalysis.topology.tpr.obj.InteractionKind(name, long_name, natoms)[source]

natoms: number of atoms involved in this type of interaction

process(atom_ndx)[source]
class MDAnalysis.topology.tpr.obj.Molblock(molb_type, molb_nmol, molb_natoms_mol, molb_nposres_xA, molb_nposres_xB)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

molb_natoms_mol

Alias for field number 2

molb_nmol

Alias for field number 1

molb_nposres_xA

Alias for field number 3

molb_nposres_xB

Alias for field number 4

molb_type

Alias for field number 0

class MDAnalysis.topology.tpr.obj.MoleculeKind(name, atomkinds, bonds=None, angles=None, dihe=None, impr=None, donors=None, acceptors=None)[source]
number_of_atoms()[source]
number_of_residues()[source]
remap_angles(atom_start_ndx)[source]
remap_bonds(atom_start_ndx)[source]
remap_dihe(atom_start_ndx)[source]
remap_impr(atom_start_ndx)[source]
class MDAnalysis.topology.tpr.obj.Mtop(nmoltype, moltypes, nmolblock)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

moltypes

Alias for field number 1

nmolblock

Alias for field number 2

nmoltype

Alias for field number 0

class MDAnalysis.topology.tpr.obj.Params(atnr, ntypes, functype, reppow, fudgeQQ, iparams)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

atnr

Alias for field number 0

fudgeQQ

Alias for field number 4

functype

Alias for field number 2

iparams

Alias for field number 5

ntypes

Alias for field number 1

reppow

Alias for field number 3

class MDAnalysis.topology.tpr.obj.TPRTopology(atoms, bonds, angles, dihe, impr)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

angles

Alias for field number 2

atoms

Alias for field number 0

bonds

Alias for field number 1

dihe

Alias for field number 3

impr

Alias for field number 4

class MDAnalysis.topology.tpr.obj.TpxHeader(number, ver_str, precision, fver, fgen, file_tag, natoms, ngtc, fep_state, lamb, bIr, bTop, bX, bV, bF, bBox)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

bBox

Alias for field number 15

bF

Alias for field number 14

bIr

Alias for field number 10

bTop

Alias for field number 11

bV

Alias for field number 13

bX

Alias for field number 12

fep_state

Alias for field number 8

fgen

Alias for field number 4

file_tag

Alias for field number 5

fver

Alias for field number 3

lamb

Alias for field number 9

natoms

Alias for field number 6

ngtc

Alias for field number 7

number

Alias for field number 0

precision

Alias for field number 2

ver_str

Alias for field number 1

4.22.4. Utilities for the TPRParser

Function calling order:

(TPRParser.py call do_mtop)
do_mtop -> do_symtab
        -> do_ffparams -> do_iparams
        -> do_moltype  -> do_atoms  -> do_atom
                                    -> do_resinfo
                       -> do_ilists
                       -> do_block
                       -> do_blocka
        -> do_molblock

Then compose the stuffs in the format MDAnalysis.Universe reads in.

The module also contains the do_inputrec() to read the TPR header with.

MDAnalysis.topology.tpr.utils.define_unpack_real(prec, data)[source]

Define an unpack_real method of data based on the float precision used

MDAnalysis.topology.tpr.utils.do_atom(data, fver)[source]
MDAnalysis.topology.tpr.utils.do_atoms(data, symtab, fver)[source]
MDAnalysis.topology.tpr.utils.do_atomtypes(data)[source]
MDAnalysis.topology.tpr.utils.do_block(data)[source]
MDAnalysis.topology.tpr.utils.do_blocka(data)[source]
MDAnalysis.topology.tpr.utils.do_ffparams(data, fver)[source]
MDAnalysis.topology.tpr.utils.do_groups(data, symtab)[source]
MDAnalysis.topology.tpr.utils.do_grps(data)[source]
MDAnalysis.topology.tpr.utils.do_harm(data)[source]
MDAnalysis.topology.tpr.utils.do_ilists(data, fver)[source]
MDAnalysis.topology.tpr.utils.do_inputrec(data)[source]

Read through header information from TPR file data structure.

Note that this function does not return any useful data itself. If your are interested in using the header information, use this functions as a starting point for your own code.

MDAnalysis.topology.tpr.utils.do_iparams(data, functypes, fver)[source]
MDAnalysis.topology.tpr.utils.do_molblock(data)[source]
MDAnalysis.topology.tpr.utils.do_moltype(data, symtab, fver)[source]
MDAnalysis.topology.tpr.utils.do_mtop(data, fver, u)[source]
MDAnalysis.topology.tpr.utils.do_resinfo(data, symtab, fver, nres)[source]
MDAnalysis.topology.tpr.utils.do_rvec(data)[source]
MDAnalysis.topology.tpr.utils.do_symstr(data, symtab)[source]
MDAnalysis.topology.tpr.utils.do_symtab(data)[source]
MDAnalysis.topology.tpr.utils.extract_box_info(data, fver)[source]
MDAnalysis.topology.tpr.utils.fver_err(fver)[source]
MDAnalysis.topology.tpr.utils.ndo_int(data, n)[source]

mimic of gmx_fio_ndo_real in gromacs

MDAnalysis.topology.tpr.utils.ndo_ivec(data, n)[source]

mimic of gmx_fio_ndo_rvec in gromacs

MDAnalysis.topology.tpr.utils.ndo_real(data, n)[source]

mimic of gmx_fio_ndo_real in gromacs

MDAnalysis.topology.tpr.utils.ndo_rvec(data, n)[source]

mimic of gmx_fio_ndo_rvec in gromacs

MDAnalysis.topology.tpr.utils.read_tpxheader(data)[source]

this function is now compatible with do_tpxheader in tpxio.c