TPR (GROMACS run topology files)¶
Topology parser |
A GROMACS TPR file is a portable binary run input file. It contains both topology and coordinate information. However, MDAnalysis currently only reads topology information about atoms, bonds, dihedrals, and impropers; it does not read the coordinate information.
Important
Atom ids, residue resids, and molnums
GROMACS indexes atom numbers and residue numbers from 1 in user-readable files. However, the MDAnalysis TPRParser creates atom ids
and residue resids
from 0. This means that if your atom is numbered 3 in your GRO, ITP, or TOP file, it will have an Atom.id
of 2 in MDAnalysis. Likewise, if your residue ALA has a residue number of 4 in your GRO file, it will have a Residue.resid
number of 3 in MDAnalysis. Finally, molecules are also numbered from 0, in the attribute molnums
.
Atom indices
and residue resindices
are MDAnalysis derived and always index from 0, no matter the file type.
Supported versions¶
TPX format |
TPX generation |
Gromacs release |
read |
---|---|---|---|
?? |
?? |
3.3, 3.3.1 |
no |
58 |
17 |
4.0, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.6, 4.0.7 |
yes |
73 |
23 |
4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.5.4, 4.5.5 |
yes |
83 |
24 |
4.6, 4.6.1 |
yes |
100 |
26 |
5.0, 5.0.1, 5.0.2, 5.0.3,5.0.4, 5.0.5 |
yes |
103 |
26 |
5.1 |
yes |
110 |
26 |
2016 |
yes |
112 |
26 |
2018 |
yes |
116 |
26 |
2019 |
yes |
For further discussion and notes see Issue 2. Please open a new issue in the Issue Tracker when a new or different TPR file format version should be supported.
TPR specification¶
The TPR reader is a pure-python implementation of a basic TPR parser. Currently the following sections of the topology are parsed:
Atoms: number, name, type, resname, resid, segid, mass, charge, [residue, segment, radius, bfactor, resnum, moltype]
Bonds
Angles
Dihedrals
Impropers
Bonded interactions available in Gromacs are described in the Gromacs manual. The following ones are used to build the topology (see Issue 463):
Directive |
Type |
Description |
---|---|---|
bonds |
1 |
|
bonds |
2 |
|
bonds |
3 |
|
bonds |
4 |
|
bonds |
5 |
|
bonds |
6 |
|
bonds |
7 |
|
bonds |
8 |
|
bonds |
9 |
|
bonds |
10 |
|
constraints |
1 |
|
constraints |
2 |
|
settles |
1 |
Directive |
Type |
Description |
---|---|---|
angles |
1 |
|
angles |
2 |
|
angles |
3 |
|
angles |
4 |
|
angles |
5 |
|
angles |
6 |
|
angles |
8 |
|
angles |
10 |
Directive |
Type |
Description |
---|---|---|
dihedrals |
1 |
|
dihedrals |
3 |
|
dihedrals |
5 |
|
dihedrals |
8 |
|
dihedrals |
9 |
|
dihedrals |
10 |
|
dihedrals |
11 |
Directive |
Type |
Description |
---|---|---|
dihedrals |
2 |
|
dihedrals |
4 |
Developer notes¶
This tpr parser is written according to the following files
gromacs_dir/src/kernel/gmxdump.c
gromacs_dir/src/gmxlib/tpxio.c
(the most important one)gromacs_dir/src/gmxlib/gmxfio_rw.c
gromacs_dir/src/gmxlib/gmxfio_xdr.c
gromacs_dir/include/gmxfiofio.h
or their equivalent in more recent versions of Gromacs.
The function read_tpxheader()
is based on the
TPRReaderDevelopment notes. Functions with names starting with
read_
or do_
are trying to be similar to those in
gmxdump.c
or tpxio.c
, those with extract_
are new.
Wherever fver_err(fver)
is used, it means the tpx version problem
has not been solved. Versions prior to Gromacs 4.0.x are not supported.