6.18. TNG trajectory files — MDAnalysis.coordinates.TNG

The TNG format [Lundborg2014] is a format used in GROMACS for storage of trajectory and topology information. The TNG format allows a wide range of compression algorithms and unlike the compressed XTC format can also store velocities and forces in addition to positions.

The classes in this module are based on the pytng package for reading TNG files. The reader is directed to the pytng documentation for further reading about how pytng works under the hood. Pytng is an optional dependency and must be installed to use this Reader. Use of the reader without pytng installed will raise an ImportError. The variable HAS_PYTNG indicates whether this module has pytng availble.

In addition to particle-dependent trajectory information like positions, forces and velocities, the TNG format can store trajectory metadata and other arbitrary time dependent data. Additional information can range from the virial and pressure components to the molecular topology of the system. This is enabled by a block based system in which binary flags indicate the presence or absence of various data blocks. The structure of a TNG file is provided in the TNG specification. The TNG paper [Lundborg2014] and the pytng documentation are also good resources. The user is encouraged to read the full list of TNG blocks to understand the full power of the TNG format.

6.18.1. Current Limitations

Currently there is only a Reader for TNG files and no Writer. This will depend on upstream changes in pytng. Additionally, it is not currently possible to read the molecular topology from a TNG file.

There are also some limitations to reading TNG files with pytng. Currently we do not allow data to be read off stride. In essence this means that all of the critical trajectory data (positions, box, velocities (if present), forces (if present)) must share the same stride in trajectory integrator steps. These critical blocks in the TNG file are henceforth called special blocks. Optional blocks (all blocks that are not special blocks) will not be read if they do not share an integrator step with, or are not divisible by the shared integrator step of the special blocks.

References

Lundborg2014(1,2,3)

Magnus Lundborg, Rossen Apostolov, Daniel Spångberg, Anders Gärdenäs, David van der Spoel, and Erik Lindahl. An efficient and extensible format, library, and api for binary trajectory data from molecular simulations. Journal of Computational Chemistry, 35(3):260–269, 2014. URL: https://onlinelibrary.wiley.com/doi/abs/10.1002/jcc.23495, doi:https://doi.org/10.1002/jcc.23495.

class MDAnalysis.coordinates.TNG.TNGReader(filename: str, convert_units: bool = True, **kwargs)[source]

Reader for the TNG format

The TNG format [Lundborg2014] is a format used in GROMACS for storage of trajectory and topology information. This reader is are based on the pytng package for reading TNG files. The reader is directed to the pytng documentation and TNG specification for further reading.

The TNG format allows a wide range of compression algorithms and unlike the compressed XTC format can also store velocities and forces in addition to positions.

The contents of the special blocks (positions, box, velocities, forces) are read into the timestep if present. Additional blocks are read into the ts.data dictionary if they are available at the current frame.

New in version 2.4.0.

Initialize a TNG trajectory

Parameters
  • filename (str) – filename of the trajectory

  • convert_units (bool (optional)) – convert into MDAnalysis units

Writer()[source]

Writer for TNG files

Raises

NotImplementedError – Currently there is not writer for TNG files pending implementation upstream in pytng.

property additional_blocks: List[str]

list of the additional (non-special) blocks that are being read from the trajectory. This may be exclude some blocks present in the file if they do not fall on the same trajectory stride as the positions and velocities.

Returns

additional_blocks – The additional block names in the TNG trajectory

Return type

list

property blocks: List[str]

list of the blocks that are in the file

Returns

blocks – The block names present in the TNG trajectory

Return type

list

close()[source]

close the reader

property n_frames: int

number of frames in trajectory

Returns

n_frames – The number of data containing frames in the trajectory

Return type

int

static parse_n_atoms(filename: str) int[source]

parse the number of atoms in the TNG trajectory file

Parameters

filename (str) – The name of the TNG file

Returns

n_atoms – The number of atoms in the TNG file

Return type

int

property special_blocks: List[str]

list of the special blocks that are in the file

Returns

special_blocks – The special block names (positions, box, velocities, forces) present in the TNG trajectory

Return type

list

units = {'force': 'kJ/(mol*nm)', 'length': 'nm', 'time': 'second', 'velocity': 'nm/ps'}

dict with units of of time and length (and velocity, force, … for formats that support it)