qrunch.chemistry.molecule.xyz_file_reader

Module containing logic for loading a XYZ file representing a molecule.

Functions

molecule_from_lines(lines, units)

Parse the lines of an .xyz file to create a Molecule object.

Classes

XYZFileReader

Creates a Molecule object from an .xyz file.

class XYZFileReader

Bases: object

Creates a Molecule object from an .xyz file.

static read(file_path: ~pathlib.Path, units: ~qrunch.common.units._base.Unit[~qrunch.common.units.length.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

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:

Molecule