BaseTopologyReader

class mdcraft.io.base.BaseTopologyReader(filename: str | Path, /, *, n_workers: int | None = 1)[source]

Bases: BaseReader

Base class for topology readers.

Subclasses must set values for

  • the _FORMAT and _EXTENSIONS attributes, which specify the format and standard extension(s) of the topology file, respectively,

  • the _PARALLELIZABLE attribute, which specifies whether the reader can process a file in parallel,

  • the _units attribute, which specifies the base units (charge, energy, length, mass, temperature, and time) used by the simulation software that generated the trajectory file,

  • the _reduced attribute, which specifies whether the data is in reduced units,

  • the dimensions() property, which specifies the simulation box dimensions (or lattice parameters), and

  • the n_atoms(), n_bonds(), n_angles(), n_dihedrals(), n_improper_dihedrals(), n_residues(), n_segments(), n_chains(), and n_molecules() properties, which specify the number of atoms, bonds, angles, dihedrals, improper dihedrals, residues, segments, chains, and molecules, respectively,

and implement

  • the __repr__() method to provide a string representation of the reader that can be used to recreate it, and

  • the open() and close() methods to handle the opening and closing of the file.

Parameters:
filenamestr or pathlib.Path, positional-only

Filename or path to the topology file.

n_workersint, keyword-only, default: 1

Number of threads to use when reading the file. If None, the number of available logical threads is used.

Methods

close

Closes the topology or trajectory file and deletes the handle.

open

Opens the topology or trajectory file and stores a handle to it.

read_topology

abstractmethod close() None

Closes the topology or trajectory file and deletes the handle.

abstract property dimensions: ndarray[float64] | None

Simulation box dimensions (or lattice parameters). If None, the system size could not be determined from the topology.

Reference units: \(\mathrm{nm}\) for lengths and degrees (\(^\circ\)) for angles.

abstract property n_angles: int

Number of angles.

abstract property n_atoms: int

Number of atoms.

abstract property n_bonds: int

Number of bonds.

abstract property n_chains: int

Number of chains.

abstract property n_dihedrals: int

Number of dihedrals.

abstract property n_molecules: int

Number of molecules.

abstract property n_residues: int

Number of residues.

abstract property n_segments: int

Number of segments.

abstractmethod open() None

Opens the topology or trajectory file and stores a handle to it.