A Rust port of the Trajectory Next Generation (TNG) library. The original library was made by the GROMACS team and can be found here
The port matches the behavior at commit f8d55273 at https://gitlab.com/gromacs/tng.
A few bug fixes has been commited. These have been and will be tagged with (extra) to more easily distinguish code changes from the original TNG lib.
You can run the tests with debug output in the following way:
RUST_LOG=debug cargo test -- --nocaptureThere is internal unit testing to make sure that the Rust code works (and keeps working), there's FFI tests to compare with the C lib where the C code acts as the ground-truth (bugs and all),
and there's some property-based testing using proptest where either the Rust code is expected to be internally consistent or the C code is used as a ground-truth.
There are some patterns that are quite difficult to port where I decided to change the public API slightly. One being the fact that the original C lib makes use of circular references to have a molecule point to its parent residue while the parent residue points to that molecule. It's not impossible to have in Rust, just a bit more cumbersome than in C. Due to this, in some places the takes/returns an index to the residue, chain, molecules, etc. instead of the entity itself.
Searches over molecule-owned collections are exposed on Molecule in Rust. In practice, chain_find and atom_find correspond to C's tng_molecule_chain_find and tng_molecule_atom_find, while residue_find is a Rust convenience.
Consider citing original paper developing the TNG format -- "An efficient and extensible format, library, and API for binary trajectory data from molecular simulations" -- if you find this lib useful.
Parts of the code has been translated with the use of large language models (LLMs). All code has been reviewed by humans.