rdtools.fix.fix#

This module contains the helper functions for fixing parsed molecules.

rdtools.fix.fix.find_oxonium_bonds(mol: Mol, threshold: float = 1.65) List[tuple[int, int]]#

Find the potential oxonium atom.

Parameters:
  • mol (Chem.Mol) – The molecule to be fixed.

  • threshold (float, optional) – The threshold to determine if two atoms are connected.

Returns:

List[tuple[int, int]] – a list of (oxygen atom index, the other atom index).

rdtools.fix.fix.fix_mol(mol: Mol, remedies: List[ChemicalReaction] | None = None, max_attempts: int = 10, sanitize: bool = True, fix_spin_multiplicity: bool = True, mult: int = 0, renumber_atoms: bool = True) Mol#

Fix the molecule by applying the given remedies and fixing spin multiplicity.

Parameters:
  • mol (Chem.Mol) – The molecule to be fixed.

  • remedies (Optional[List[Chem.rdChemReactions.ChemicalReaction]], optional) – The list of remedies to fix the molecule, defined as RDKit ChemicalReaction. Defaults to rdmc.fix.DEFAULT_REMEDIES.

  • max_attempts (int, optional) – The maximum number of attempts to fix the molecule. Defaults to 10.

  • sanitize (bool, optional) – Whether to sanitize the molecule after the fix. Defaults to True. Using False is only recommended for debugging and testing.

  • fix_spin_multiplicity (bool, optional) – Whether to fix the spin multiplicity of the molecule. The fix can only reduce the spin multiplicity. Defaults to True.

  • mult (int, optional) – The desired spin multiplicity. Defaults to 0, which means the lowest possible spin multiplicity will be inferred from the number of unpaired electrons. Only used when fix_spin_multiplicity is True.

  • renumber_atoms (bool, optional) – Whether to renumber the atoms after the fix. Defaults to True. Turn this off when the atom map number is not important.

Returns:

Chem.Mol – The fixed molecule.

rdtools.fix.fix.fix_mol_by_remedies(mol: Mol, remedies: List[ChemicalReaction], max_attempts: int = 10, sanitize: bool = True) Mol#

Fix the molecule according to the given remedy.

Parameters:
  • mol (Chem.Mol) – The molecule to be fixed.

  • remedies (List[Chem.rdChemReactions.ChemicalReaction]) – A list of remedies to fix the molecule defined as an RDKit ChemicalReaction.

  • max_attempts (int, optional) – The maximum number of attempts to fix the molecule. Defaults to 10.

  • sanitize (bool, optional) – Whether to sanitize the molecule after the fix. Defaults to True.

Returns:

Chem.Mol – The fixed molecule.

rdtools.fix.fix.fix_mol_by_remedy(mol: Mol, remedy: ChemicalReaction, max_attempts: int = 10, sanitize: bool = True) Mol#

Fix the molecule according to the given remedies.

The remedies are are defined as RDKit ChemicalReaction.

Parameters:
  • mol (Chem.Mol) – The molecule to be fixed.

  • remedy (Chem.rdChemReactions.ChemicalReaction) – The functional group transformation as the remedy to fix the molecule, defined as an RDKit ChemicalReaction.

  • max_attempts (int, optional) – The maximum number of attempts to fix the molecule. Defaults to 10.

  • sanitize (bool, optional) – Whether to sanitize the molecule after the fix. Defaults to True.

Returns:

Chem.Mol – The fixed molecule.

Raises:

RuntimeError – If the maximum number of attempts is reached.

rdtools.fix.fix.fix_oxonium_bonds(mol: Mol, threshold: float = 1.65, sanitize: bool = True) Mol#

Fix the oxonium atom.

Openbabel and Jensen perception algorithm do not perceive the oxonium atom correctly. This is a fix to detect if the molecule contains oxonium atom and fix it.

Parameters:
  • mol (Chem.Mol) – The molecule to be fixed.

  • threshold (float, optional) – The threshold to determine if two atoms are connected.

  • sanitize (bool, optional) – Whether to sanitize the molecule after the fix. Defaults to True. Using False is only recommended for debugging and testing.

Returns:

Chem.Mol – The fixed molecule.