mol_interface#
- irmsd.interfaces.mol_interface.cregen(molecule_list: Sequence[Molecule], rthr: float = 0.125, ethr: float = 7.96800686e-05, bthr: float = 0.01, printlvl: int = 0, ewin: float | None = None) List[Molecule][source]#
High-level wrapper around the Fortran-backed
cregen_rawthat operates directly on Molecule objects. Returns a pruned & energy-sorted list of structures.- Parameters:
molecule_list (
Sequence[Molecule]) – Sequence of Molecule objects. All molecules must have the same number of atoms.rthr (
float) – Distance threshold for the sorter (passed through to the backend).ethr (
float) – Inter-conformer energy threshold (in Hartree)bthr (
float) – Inter-conformer rotational constant threshold (fractional)iinversion (
int, optional) – Inversion symmetry flag, passed through to the backend.printlvl (
int, optional) – Verbosity level, passed through to the backend.ewin (
float | None) – Optional energy window to limit ensembe size around lowest energy structure. In Hartree.
- Returns:
new_molecule_list – New Molecule objects reconstructed from the sorted atomic numbers and positions returned by the backend. The list contains only n_structures defined as
uniqueaccording to the selected thresholds.- Return type:
list[Molecule]- Raises:
TypeError – If
molecule_listdoes not contain Molecule instances.ValueError – If
molecule_listis empty or if the Molecules do not all have the same number of atoms.
- irmsd.interfaces.mol_interface.delta_irmsd_list_molecule(molecule_list: Sequence[Molecule], iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, use_ids: bool = True) Tuple[ndarray, List[Molecule]][source]#
High-level wrapper around the Fortran-backed
delta_irmsd_listthat operates directly on Molecule objects.- Parameters:
molecule_list (
Sequence[Molecule]) – Sequence of Molecule objects. All molecules must have the same number of atoms.iinversion (
int, optional) – Inversion symmetry flag, passed through to the backend.allcanon (
bool, optional) – Canonicalization flag, passed through to the backend.printlvl (
int, optional) – Verbosity level, passed through to the backend.
- Returns:
delta (
np.ndarray) – Float array returned by the backend (seedelta_irmsd_listfor detailed semantics).new_molecule_list (
list[Molecule]) – New Molecule objects reconstructed from the atomic numbers and positions returned by the backend. The list has the same length and ordering asmolecule_list.
- Raises:
TypeError – If
molecule_listdoes not contain Molecule instances.ValueError – If
molecule_listis empty or if the Molecules do not all have the same number of atoms.
- irmsd.interfaces.mol_interface.get_energies_from_molecule_list(molecule_list: Sequence[Molecule]) ndarray[source]#
Collect potential energies from a sequence of Molecule objects.
For each Molecule, this function calls
get_potential_energy()and stores the result in a 1D NumPy array of dtype float. If the energy is not available (for example, ifget_potential_energy()raisesAttributeErroror returnsNone), the corresponding entry is set to 0.0.- Parameters:
molecule_list (
Sequence[Molecule]) – Sequence of Molecule instances.- Returns:
energies – Array of shape (n_structures,) containing one energy per Molecule.
- Return type:
np.ndarray
- irmsd.interfaces.mol_interface.get_irmsd_molecule(molecule1: Molecule, molecule2: Molecule, iinversion: int = 0, use_ids: bool = True) Tuple[float, Molecule, Molecule][source]#
Compute the iRMSD between two Molecule objects using the iRMSD backend.
The backend may reorder atoms and/or change atomic numbers according to its canonicalization / matching logic. This wrapper returns copies of both input Molecules with the updated atomic numbers and positions.
- Parameters:
molecule1 (
Molecule) – First input structure.molecule2 (
Molecule) – Second input structure.iinversion (
int, optional) – Inversion flag passed directly to the Fortran backend. See the backend documentation for allowed values and meanings.use_ids (
bool, optional) – If True (default) and both molecules carry per-atom canonical IDs (Molecule.ids), those IDs are passed to the backend as externally supplied ranks. The backend uses them only if they are mutually consistent, otherwise it recomputes the canonical ranks.
- Returns:
irmsd (
float) – iRMSD value in Ångström.new_molecule1 (
Molecule) – Copy ofmolecule1with updated atomic numbers and positions.new_molecule2 (
Molecule) – Copy ofmolecule2with updated atomic numbers and positions.
- Raises:
TypeError – If either input is not a Molecule.
- irmsd.interfaces.mol_interface.get_rmsd_molecule(molecule1: Molecule, molecule2: Molecule, mask=None) Tuple[float, Molecule, ndarray][source]#
Compute the RMSD between two Molecule objects using the quaternion-based RMSD backend, and return an aligned copy of the second Molecule.
- Parameters:
molecule1 (
Molecule) – Reference structure.molecule2 (
Molecule) – Structure to be rotated/translated ontomolecule1.mask (
array-likeofbool, optional) – Optional mask selecting which atoms ofmolecule1participate in the RMSD. Must be broadcastable / compatible with the Fortran backend’s mask semantics.
- Returns:
rmsd (
float) – Root-mean-square deviation in Ångström.new_molecule2 (
Molecule) – Copy ofmolecule2with its positions replaced by the aligned coordinates returned by the backend.rotation_matrix (
np.ndarray) – 3×3 rotation matrix applied to alignmolecule2ontomolecule1.
- Raises:
TypeError – If either input is not a Molecule.
- irmsd.interfaces.mol_interface.prune(molecule_list: Sequence[Molecule], rthr: float, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None, use_ids: bool = True) List[Molecule][source]#
High-level wrapper around the Fortran-backed
sorter_irmsdthat operates directly on Molecule objects. Returns a pruned list of structures.- Parameters:
molecule_list (
Sequence[Molecule]) – Sequence of Molecule objects. All molecules must have the same number of atoms.rthr (
float) – Distance threshold for the sorter (passed through to the backend).iinversion (
int, optional) – Inversion symmetry flag, passed through to the backend.allcanon (
bool, optional) – Canonicalization flag, passed through to the backend.printlvl (
int, optional) – Verbosity level, passed through to the backend.ethr (
float | None) – Optional energy threshold to accelerate by pre-sortingewin (
float | None) – Optional energy window to limit ensembe size around lowest energy structure. In Hartree.
- Returns:
new_molecule_list – New Molecule objects reconstructed from the sorted atomic numbers and positions returned by the backend. The list contains only n_structures defined as
uniqueaccording to the selected thresholds.- Return type:
list[Molecule]- Raises:
TypeError – If
molecule_listdoes not contain Molecule instances.ValueError – If
molecule_listis empty or if the Molecules do not all have the same number of atoms.
- irmsd.interfaces.mol_interface.prune_by_energy_window(molecule_list: Sequence[Molecule], energy_window: float | None) List[Molecule][source]#
Prune a list of Molecule objects based on a relative energy window.
This function identifies the lowest-energy structure in
molecule_listand retains only those molecules whose energies lie withinenergy_windowHartree above this minimum. Energies are obtained viaget_energies_from_molecule_listand are assumed to be aligned with the order ofmolecule_list.If
energy_windowisNone, the input list is returned unchanged.- Parameters:
- Returns:
pruned – A new list containing only the structures within the specified energy window.
- Return type:
listofMolecule
Notes
The reference energy is the minimum energy found in the provided list. No sorting of the returned molecules is performed; the original order (minus removed entries) is preserved.
- irmsd.interfaces.mol_interface.sorter_irmsd_molecule(molecule_list: Sequence[Molecule], rthr: float = 0.125, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None, use_ids: bool = True) Tuple[ndarray, List[Molecule]][source]#
High-level wrapper around the Fortran-backed
sorter_irmsdthat operates directly on Molecule objects.- Parameters:
molecule_list (
Sequence[Molecule]) – Sequence of Molecule objects. All molecules must have the same number of atoms.rthr (
float) – Distance threshold for the sorter (passed through to the backend).iinversion (
int, optional) – Inversion symmetry flag, passed through to the backend.allcanon (
bool, optional) – Canonicalization flag, passed through to the backend.printlvl (
int, optional) – Verbosity level, passed through to the backend.ethr (
float | None) – Optional energy threshold to accelerate by pre-sortingewin (
float | None) – Optional energy window to limit ensembe size around lowest energy structure. In Hartree.
- Returns:
groups (
np.ndarray) – Integer array of shape (nat,) with group indices for the firstnatatoms (as defined by the backend).new_molecule_list (
list[Molecule]) – New Molecule objects reconstructed from the sorted atomic numbers and positions returned by the backend. The list has the same length and ordering asmolecule_list.
- Raises:
TypeError – If
molecule_listdoes not contain Molecule instances.ValueError – If
molecule_listis empty or if the Molecules do not all have the same number of atoms.