Expand description
§minitpr
minitpr
is a Rust library designed for basic parsing of Gromacs tpr files, focusing on extracting system topology information.
§Capabilities and Limitations
- Supports parsing of tpr files from version 103 onwards (compatible with Gromacs 5.1 and later). It efficiently extracts system topology: atoms, their basic properties, and the bonds between them.
- Is currently not able to read positions and velocities of atoms, as well as forces acting on them.
- Does not currently interpret intermolecular bonds, resulting in their omission from the parsed data.
- Will not support parsing of force-field and simulation parameters, nor will it offer capabilities to write tpr files.
§Usage
To include minitpr
in your project, add it as a dependency using Cargo:
cargo add minitpr
§Parsing a tpr file
Example usage to parse a tpr file and handle potential errors:
use minitpr::TprFile;
fn main() {
let tpr = match TprFile::parse("topol.tpr") {
Ok(file) => file,
Err(error) => {
eprintln!("{}", error);
return;
},
};
// now you can work with the `tpr` object, accessing its properties and data
// for instance, to iterate through the atoms of the molecular system, use:
for atom in tpr.topology.atoms.iter() {
// perform some operation with the atom
}
}
§Data Structures
The TprFile
structure encapsulates the following information:
- Header: Detailed metadata about the tpr file (see
TprHeader
structure). - Molecular System Name: The name of the simulated system.
- Simulation Box Dimensions: Available within the
SimBox
structure if present. - System Topology: Topology of the molecular system (see
TprTopology
structure).
Each atom (see Atom
) represented in the system topology includes:
- Atom name.
- Sequential atom number, starting from 1.
- Residue name.
- Sequential residue number, starting from 1.
- Mass.
- Charge.
- Element (
None
if unidentifiable).
§Features
§Serialization/Deserialization
Enable (de)serialization support for TprFile
with serde
by adding the feature flag during installation:
cargo add minitpr --features serde
§License
minitpr
is open-sourced under either the Apache License 2.0 or the MIT License at your option.
§Disclaimer
Due to the huge number of various force field and simulation parameters and Gromacs options, it is very difficult to comprehensively test the minitpr
library.
Your contributions in the form of tests, tpr files with unusual parameters, or new functionality are very welcome. See github.com/Ladme/minitpr.
If the library is unable to parse your tpr file, but you believe it should be able to, please open a GitHub issue and upload your tpr file.
Re-exports§
pub use structures::*;
Modules§
- This file defines errors that can be returned by the
minitpr
library. - This file contains public data structures used in the
minitpr
library.
Constants§
- Current version of the
minitpr
library.