GROMACS Structure (.gro) Parser

Parses a GROMACS .gro file to extract residue electron counts and box volume.

class kbkit.io.gro.GroParser(path: str | Path)[source]

Bases: object

Parse a single GROMACS .gro file to compute valence electron counts and box volume.

Parameters:

gro_path (str) – Path to the .gro file.

MAX_SYMBOL_LENGTH: ClassVar = 2
property residues: ResidueGroup

Residues in the .gro file.

Type:

MDAnalysis.core.groups.ResidueGroup

property molecule_count: dict[str, int]

Unique molecule residues and corresponding counts.

Type:

dict[str, int]

property molecules: list[str]

Names of molecules present.

Type:

list[str]

property total_molecules: int

Total number of molecules present.

Type:

int

property atom_counts: dict[str, dict[str, int]]

Dictionary of residue names and their atom type counts.

Type:

dict[str, dict[str, int]]

property electron_count: dict[str, int]

Dictionary of residue types and their total electron count.

Type:

dict[str, int]

property box_volume: float

Compute box volume (nm^3) from the last line of a GROMACS .gro file.

Type:

float

static is_valid_element(symbol: str) bool[source]

Check if a string is a valid chemical element symbol.

Parameters:

symbol (str) – Element symbol to validate (e.g., ‘C’, ‘Na’, ‘Cl’).

Returns:

True if valid element, False otherwise.

Return type:

bool

static get_atomic_number(symbol: str) int[source]

Return atomic number of a valid element symbol.

Parameters:

symbol (str) – Valid element symbol (e.g., ‘C’, ‘Na’, ‘Cl’).

Returns:

Atomic number of the element.

Return type:

int