Topology Parser

Parses a topology file to extract composition information.

class kbkit.io.topology.TopologyFormat(*values)[source]

Bases: Enum

Formatting for various topology types.

LAMMPS = 1
GROMACS = 2
TOP = 3
class kbkit.io.topology.TopologyParser(path: str | Path)[source]

Bases: object

Parses topology files to get molecules present and their counts.

Parameters:

path (str) – Path to the topology file.

static extract_molecules_from_top(top_file: str | Path) → dict[str, int][source]

Read the GROMACS topology file (.top) and returns a dictionary of molecule names and counts.

Returns:

Dictionary containing molecules present and their number.

Return type:

dict[str, int]

property molecule_count: dict[str, int]

Dictionary of molecules present and their corresponding numbers.

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 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).

Type:

float