qrunch.chemistry.molecule.xyz_file_reader
Module containing logic for loading a XYZ file representing a molecule.
Functions
|
Parse the lines of an .xyz file to create a Molecule object. |
Parse an element symbol with an optional integer label. |
Classes
Creates a |
- class XYZFileReader
Bases:
objectCreates a
Moleculeobject from an .xyz file.- static read(file_path: Path, units: Unit[Length] = <class 'qrunch.common.units.length.Angstrom'>) Molecule
Read an .xyz or .txt file and extracts the relevant information to create a
Molecule.- Parameters:
file_path (Path) – Path to the .xyz file.
units (Unit[Length]) – The unit of the coordinates in the file.
- Raises:
MalformedXyzFileError – If the file is empty or cannot be read.
- Return type:
- molecule_from_lines(lines: list[str], units: Unit[Length]) Molecule
Parse the lines of an .xyz file to create a Molecule object.
- Parameters:
lines (list[str]) – The lines of the .xyz file.
units (Unit[Length]) – The unit of the coordinates.
- Raises:
MalformedXyzFileError – If the file is malformed or contains invalid data.
- Return type:
- parse_element_with_optional_label(raw: str) tuple[str, str | None]
Parse an element symbol with an optional integer label.
- Parameters:
raw (str) – Raw element string, e.g. “H” or “H1”.
- Raises:
ValueError – If the string does not match a valid element pattern.
- Return type:
tuple[str, str | None]