rdkit_io#

irmsd.interfaces.rdkit_io.conf_id_to_iterator(molecule: Mol, conf_id: None | int | list[int]) → Generator | List['Mol'][source]#

Iterate over the conformers selected by conf_id (None selects all).

Raises TypeError unless conf_id is None, an int, or a list.

irmsd.interfaces.rdkit_io.conformer_iterator(molecule: Mol, conf_ids: list[int]) → Conformer[source]#

Yield the conformers of molecule listed in conf_ids.

irmsd.interfaces.rdkit_io.cregen_rdkit(molecules: 'Mol' | Sequence['Mol'], rthr: float = 0.125, ethr: float = 8e-05, bthr: float = 0.01, printlvl: int = 0, ewin: float | None = None) → List['Mol'][source]#

CREGEN-style pruning: unique structures by iRMSD, energy and rotational constants.

Parameters:
  • molecules (rdkit.Chem.Mol or list of rdkit.Chem.Mol) – A single Mol must carry more than one conformer.

  • rthr (float) – iRMSD threshold in Angstrom.

  • ethr (float) – Energy threshold in Hartree.

  • bthr (float) – Relative rotational-constant threshold.

  • printlvl (int) – Verbosity, passed to the backend.

  • ewin (float or None) – Energy window in Hartree above the lowest-energy structure.

Returns:

Unique structures.

Return type:

list of rdkit.Chem.Mol

Raises:

TypeError – If the input is not an RDKit Mol or a list of them.

irmsd.interfaces.rdkit_io.delta_irmsd_list_rdkit(molecules: 'Mol' | Sequence['Mol'], iinversion: int = 0, allcanon: bool = True, printlvl: int = 0) → Tuple[np.ndarray, List['Mol']][source]#

iRMSD deltas over an ensemble.

Parameters:
  • molecules (rdkit.Chem.Mol or list of rdkit.Chem.Mol) – A single Mol must carry more than one conformer.

  • iinversion (int) – Inversion handling: 0 auto, 1 on, 2 off.

  • allcanon – Canonicalization flag and verbosity, passed to the backend.

  • printlvl – Canonicalization flag and verbosity, passed to the backend.

Returns:

  • delta (np.ndarray) – See delta_irmsd_list for semantics.

  • new_molecules_list (list of rdkit.Chem.Mol) – Processed structures.

Raises:

TypeError – If the input is not an RDKit Mol or a list of them.

irmsd.interfaces.rdkit_io.get_atom_symbols_rdkit(molecule) → list[str][source]#
irmsd.interfaces.rdkit_io.get_axis_rdkit(molecule, conf_id: None | int | list[int] = None) → Tuple[ndarray, ndarray, ndarray] | List[Tuple[ndarray, ndarray, ndarray]][source]#

Principal axes for the selected conformers.

Parameters:
  • molecule (rdkit.Chem.Mol)

  • conf_id (int, list of int, or None) – Conformer ID(s); None selects all conformers.

Returns:

(rotational constants, average moments, eigenvectors) per conformer.

Return type:

tuple of np.ndarray, or list of such tuples

Raises:

TypeError – If molecule is not an RDKit Mol.

irmsd.interfaces.rdkit_io.get_canonical_rdkit(molecule, conf_id: None | int | list[int] = None, wbo: None | ndarray = None, invtype='apsp+', heavy: bool = False) → ndarray[source]#

Canonical atom ranks for the selected conformers.

Parameters:
  • molecule (rdkit.Chem.Mol)

  • conf_id (int, list of int, or None) – Conformer ID(s); None selects all conformers.

  • wbo (np.ndarray, optional) – Wiberg bond orders, required for invtype='cangen'. Shape (n_atoms, n_atoms) to share across conformers, or (n_conf, n_atoms, n_atoms) for one per conformer.

  • invtype (str) – Invariant type.

  • heavy (bool) – Rank heavy atoms only.

Returns:

Shape (n_atoms,) for one conformer, (n_conf, n_atoms) for several.

Return type:

np.ndarray

Raises:

TypeError – If molecule is not an RDKit Mol.

irmsd.interfaces.rdkit_io.get_cn_rdkit(molecule, conf_id: None | int | list[int] = None) → ndarray[source]#

Coordination numbers for the selected conformers.

Parameters:
  • molecule (rdkit.Chem.Mol)

  • conf_id (int, list of int, or None) – Conformer ID(s); None selects all conformers.

Returns:

Shape (n_atoms,) for one conformer, (n_conf, n_atoms) for several.

Return type:

np.ndarray

Raises:

TypeError – If molecule is not an RDKit Mol.

irmsd.interfaces.rdkit_io.get_energy_rdkit(conformer) → float | None[source]#

Float of the conformer’s “energy” property, or None if unset.

irmsd.interfaces.rdkit_io.get_irmsd_rdkit(molecule_ref, molecule_align, conf_id_ref=-1, conf_id_align=-1, iinversion: int = 0) → Tuple[float, 'Mol', 'Mol'][source]#

iRMSD between two conformers after permutation and alignment.

Parameters:
  • molecule_ref (rdkit.Chem.Mol)

  • molecule_align (rdkit.Chem.Mol)

  • conf_id_ref (int) – Conformer IDs; -1 is the RDKit default conformer.

  • conf_id_align (int) – Conformer IDs; -1 is the RDKit default conformer.

  • iinversion (int) – Inversion handling: 0 auto, 1 on, 2 off.

Returns:

  • irmsd (float) – In Angstrom.

  • ref, aligned (rdkit.Chem.Mol) – Processed reference and aligned molecules.

Raises:

TypeError – If either input is not an RDKit Mol.

irmsd.interfaces.rdkit_io.get_point_group_rdkit(molecule, conf_id: None | int | list[int] = None, **settings) → str | None | List[str | None][source]#

Schoenflies point group for the selected conformers.

Parameters:
Returns:

Symbol per conformer; None if the analyzer skipped it.

Return type:

str or None, or list of those

Raises:

TypeError – If molecule is not an RDKit Mol.

irmsd.interfaces.rdkit_io.get_rmsd_rdkit(molecule_ref, molecule_align, conf_id_ref=-1, conf_id_align=-1, mask=None) → Tuple[float, 'Mol', np.ndarray][source]#

RMSD between two conformers after alignment, without permutation.

Parameters:
  • molecule_ref (rdkit.Chem.Mol)

  • molecule_align (rdkit.Chem.Mol)

  • conf_id_ref (int) – Conformer IDs; -1 is the RDKit default conformer.

  • conf_id_align (int) – Conformer IDs; -1 is the RDKit default conformer.

  • mask (array-like of bool, optional) – Atoms to include in the RMSD.

Returns:

  • rmsd (float) – In Angstrom.

  • aligned (rdkit.Chem.Mol)

  • rotmat (np.ndarray) – Rotation matrix.

Raises:

TypeError – If either input is not an RDKit Mol.

irmsd.interfaces.rdkit_io.molecule_to_rdkit(molecule: Molecule) → Mol[source]#
irmsd.interfaces.rdkit_io.molecule_to_rdkit(molecules: Sequence[Molecule]) → list['Mol']

Convert irmsd Molecule(s) to RDKit Mol(s) carrying atoms and one conformer.

No bonds or properties are transferred. Returns a single Mol if exactly one Molecule results, else a list.

Raises:

TypeError – If the input is not a Molecule or a list of them.

irmsd.interfaces.rdkit_io.prune_rdkit(molecules: 'Mol' | Sequence['Mol'], rthr: float, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None) → List['Mol'][source]#

Prune an ensemble by iRMSD, keeping the first structure of each group.

Parameters:
  • molecules (rdkit.Chem.Mol or list of rdkit.Chem.Mol) – A single Mol must carry more than one conformer.

  • rthr (float) – iRMSD threshold in Angstrom.

  • iinversion (int) – Inversion handling: 0 auto, 1 on, 2 off.

  • allcanon – Canonicalization flag and verbosity, passed to the backend.

  • printlvl – Canonicalization flag and verbosity, passed to the backend.

  • ethr (float or None) – Energy pre-sorting threshold.

  • ewin (float or None) – Energy window in Hartree above the lowest-energy structure.

Returns:

Retained structures.

Return type:

list of rdkit.Chem.Mol

Raises:

TypeError – If the input is not an RDKit Mol or a list of them.

irmsd.interfaces.rdkit_io.rdkit_to_molecule(molecules: Mol, conf_id: int | list[int] | None = None) → Molecule | list[Molecule][source]#
irmsd.interfaces.rdkit_io.rdkit_to_molecule(molecules: Sequence['Mol'], conf_id: int | list[int] | None = None) → list[Molecule]

Convert RDKit Mol(s) to irmsd Molecule(s), one per selected conformer.

Mol-level and conformer-level properties are merged into info; conformer properties win on key clashes.

Parameters:
  • molecules (rdkit.Chem.Mol or list of rdkit.Chem.Mol)

  • conf_id (int, list of int, or None, optional) – Conformer ID(s); None selects all conformers.

Returns:

A single Molecule if exactly one conformer was converted, else a list.

Return type:

Molecule or list of Molecule

Raises:

TypeError – If the input is not a Mol or list of Mols, or a conformer is not 3D.

irmsd.interfaces.rdkit_io.sorter_irmsd_rdkit(molecules: 'Mol' | Sequence['Mol'], rthr: float = 0.125, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None) → Tuple[np.ndarray, List['Mol']][source]#

Group an ensemble by iRMSD.

Parameters:
  • molecules (rdkit.Chem.Mol or list of rdkit.Chem.Mol) – A single Mol must carry more than one conformer.

  • rthr (float) – iRMSD threshold in Angstrom.

  • iinversion (int) – Inversion handling: 0 auto, 1 on, 2 off.

  • allcanon – Canonicalization flag and verbosity, passed to the backend.

  • printlvl – Canonicalization flag and verbosity, passed to the backend.

  • ethr (float or None) – Energy pre-sorting threshold.

  • ewin (float or None) – Energy window in Hartree above the lowest-energy structure.

Returns:

  • groups (np.ndarray) – Integer group index per structure.

  • new_molecules_list (list of rdkit.Chem.Mol) – Sorted structures.

Raises:

TypeError – If the input is not an RDKit Mol or a list of them.