4.13. Gromacs portable run input TPR format parser¶
The TPRParser
module allows reading of a
Gromacs portable run input file (a TPR file). Because
the file format of the TPR file is changing rapidly, not all versions
are currently supported. The known working versions and the
approximate Gromacs release numbers are listed in the table
TPR format 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 |
For further discussion and notes see Issue 2. Also add a comment to Issue 2 if a new or different TPR file format version should be supported.
Bonded interactions available in Gromacs are described in table 5.5 of the Gromacs manual. The following ones are used to build the topology (see Issue 463):
- bonds: regular bonds (type 1), G96 bonds (type 2), Morse (type 3), cubic bonds (type 4), connections (type 5), harmonic potentials (type 6), FENE bonds (type 7), restraint potentials (type 10), tabulated potential with exclusion/connection (type 8), tabulated potential without exclusion/connection (type 9), constraints with exclusion/connection (type 1), constraints without exclusion/connection (type 2)
- angles: regular angles (type 1), G96 angles (type 2), cross bond-bond (type3), cross-bond-angle (type 4), Urey-Bradley (type 5), quartic angles (type 6), restricted bending potential (type 10), tabulated angles (type 8)
- dihedrals: proper dihedrals (type 1 and type 9), Ryckaert-Bellemans dihedrals (type 3), Fourier dihedrals (type 5), restricted dihedrals (type 10), combined bending-torsion potentials (type 11), tabulated dihedral (type 8)
- impropers: improper dihedrals (type 2), periodic improper dihedrals (type 4)
4.13.1. Classes¶
-
class
MDAnalysis.topology.TPRParser.
TPRParser
(filename, universe=None, **kwargs)[source]¶ Read topology information from a Gromacs TPR_ file.
See also
MDAnalysis.topology.TPR
Standard arguments for a TopologyReader:
Parameters: *filename* – name of the topology file
Keywords: - universe
Supply a Universe to the Parser. This then passes it to the atom instances that are created within parsers.
- kwargs
Other keyword arguments that can vary with the specific format. These are stored as self.kwargs
-
__delattr__
¶ x.__delattr__(‘name’) <==> del x.name
-
__format__
()¶ default object formatter
-
__getattribute__
¶ x.__getattribute__(‘name’) <==> x.name
-
__hash__
¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶
-
__setattr__
¶ x.__setattr__(‘name’, value) <==> x.name = value
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶
-
close
()¶ Close the trajectory file.
-
convert_forces_from_native
(force, inplace=True)¶ In-place conversion of forces array force from native units to base units.
By default, the input force is modified in place and also returned.
New in version 0.7.7.
-
convert_forces_to_native
(force, inplace=True)¶ In-place conversion of force array force from base units to native units.
By default, the input force is modified in place and also returned.
New in version 0.7.7.
-
convert_pos_from_native
(x, inplace=True)¶ In-place conversion of coordinate array x from native units to base units.
By default, the input x is modified in place and also returned.
Changed in version 0.7.5: Keyword inplace can be set to
False
so that a modified copy is returned unless no conversion takes place, in which case the reference to the unmodified x is returned.
-
convert_pos_to_native
(x, inplace=True)¶ Conversion of coordinate array x from base units to native units.
By default, the input x is modified in place and also returned.
Changed in version 0.7.5: Keyword inplace can be set to
False
so that a modified copy is returned unless no conversion takes place, in which case the reference to the unmodified x is returned.
-
convert_time_from_native
(t, inplace=True)¶ Convert time t from native units to base units.
By default, the input t is modified in place and also returned (although note that scalar values t are passed by value in Python and hence an in-place modification has no effect on the caller.)
Changed in version 0.7.5: Keyword inplace can be set to
False
so that a modified copy is returned unless no conversion takes place, in which case the reference to the unmodified x is returned.
-
convert_time_to_native
(t, inplace=True)¶ Convert time t from base units to native units.
By default, the input t is modified in place and also returned. (Also note that scalar values t are passed by value in Python and hence an in-place modification has no effect on the caller.)
Changed in version 0.7.5: Keyword inplace can be set to
False
so that a modified copy is returned unless no conversion takes place, in which case the reference to the unmodified x is returned.
-
convert_velocities_from_native
(v, inplace=True)¶ In-place conversion of velocities array v from native units to base units.
By default, the input v is modified in place and also returned.
New in version 0.7.5.
-
convert_velocities_to_native
(v, inplace=True)¶ In-place conversion of coordinate array v from base units to native units.
By default, the input v is modified in place and also returned.
New in version 0.7.5.
See also
4.13.2. Development notes¶
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]
- Bonds
- Angels
- Dihedrals
- Impropers
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.