rdkit_utilities.rdmolops

rdkit_utilities.rdmolops.AtomFromQueryAtom(atom)[source]

Convert Chem.QueryAtom to Chem.Atom

Parameters

atom (QueryAtom) –

Return type

Atom

rdkit_utilities.rdmolops.AtomToQueryAtom(atom, strict=False, includeIsotope=True)[source]

Convert Chem.Atom to Chem.QueryAtom

Parameters
  • atom (Atom) –

  • strict (bool) –

  • includeIsotope (bool) –

Return type

QueryAtom

rdkit_utilities.rdmolops.GetAtomNeighborIndices(mol, centralAtomIndices=[], includeCentralAtoms=True, numAtomNeighbors=0)[source]

Get neighbor atom indices around specified core

Parameters
  • mol (rdkit.Chem.Mol)

  • centralAtomIndices (List[int]) – Central atoms to get neighbors around

  • includeCentralAtoms (bool) – Whether to include the central atoms in the output

  • numAtomNeighbors (int) – Size of shell around the central core. -1 returns all indices in the molecule; 0 returns no additional neighbors; 1 returns the first shell around the central core, and so on.

Returns

Set of neighbor atom indices around specified core

Return type

Set[int]

Parameters
  • mol (Mol) –

  • centralAtomIndices (Union[Set[int], List[int]]) –

  • includeCentralAtoms (bool) –

  • numAtomNeighbors (int) –

rdkit_utilities.rdmolops.KeepConformerIds(mol, confIds)[source]

Remove conformers from mol except those in confIds

Parameters
  • mol (Mol) –

  • confIds (Union[List[int], ndarray]) –

rdkit_utilities.rdmolops.MolAsMolWithAtoms(mol)[source]

If Mol contains Chem.QueryAtoms, convert to Mol with Chem.Atoms

If Mol already is composed of Atoms, returns the same object

Parameters

mol (Mol) –

Return type

Mol

rdkit_utilities.rdmolops.MolAsMolWithQueryAtoms(mol, strict=False, includeIsotopes=True)[source]

If Mol contains Chem.Atoms, convert to Mol with Chem.QueryAtoms

If Mol already is composed of QueryAtoms, returns the same object

Parameters
  • mol (Mol) –

  • strict (bool) –

  • includeIsotopes (bool) –

Return type

Mol

rdkit_utilities.rdmolops.MolToMolWithAtoms(mol)[source]

Convert Mol with QueryAtoms to Mol with Atoms

Parameters

mol (Mol) –

Return type

Mol

rdkit_utilities.rdmolops.MolToMolWithQueryAtoms(mol, strict=False, includeIsotopes=True)[source]

Convert Mol with Atoms to Mol with QueryAtoms

Parameters
  • mol (Mol) –

  • strict (bool) –

  • includeIsotopes (bool) –

Return type

Mol

rdkit_utilities.rdmolops.OrderByMapNumber(mol, clearAtomMapNumbers=True)[source]

Reorder RDKit molecule by atom map number. This returns a copy.

Parameters
  • mol (rdkit.Chem.Mol) – RDKit molecule

  • clearAtomMapNumbers (bool) – Whether to set atom map numbers in the output molecule to 0

Returns

Output molecule. This is a copy of the input molecule.

Return type

rdkit.Chem.Mol

Parameters
  • mol (Mol) –

  • clearAtomMapNumbers (bool) –

Example

>>> rdmol = Chem.MolFromSmiles("[C:3][C:2][O:1]")
>>> rdmol.GetAtomWithIdx(0).GetSymbol()
'C'
>>> reordered = OrderByMapNumber(rdmol)
>>> reordered.GetAtomWithIdx(0).GetSymbol()
'O'
rdkit_utilities.rdmolops.ReorderConformers(mol, order, resetConfId=True)[source]

Reorder conformers in-place by order

Parameters
  • mol (rdkit.Chem.Mol) – Molecule of interest

  • order (Union[List[int], np.ndarray]) – New order. This should be indexed from 0, and is typically the output of np.argsort. If an index is not present in this list, the associated conformer is removed from the molecule.

  • resetConfId (bool) – Whether to reset the conformer ID so they are sequential.

Parameters
  • mol (Mol) –

  • order (Union[List[int], ndarray]) –

  • resetConfId (bool) –

rdkit_utilities.rdmolops.SubsetMol(mol, atomIndices, reorder=False, clear_atom_valences=True)[source]

Return a subset of a molecule, as a copy

Parameters
  • mol (Mol) –

  • atomIndices (List[int]) –

  • reorder (bool) –

  • clear_atom_valences (bool) –

Return type

Mol