rdkit.Chem.rdGaussianShape module

Module containing implementation of Gaussian-based shape overlay and scoring. NOTE: This functionality is experimental and the API and/or results may change in future releases.

class rdkit.Chem.rdGaussianShape.OptimMode(*values)

Bases: Enum

SHAPE_ONLY = 0
SHAPE_PLUS_COLOR = 2
SHAPE_PLUS_COLOR_SCORE = 1
class rdkit.Chem.rdGaussianShape.ShapeInput(self, mol: rdkit.Chem.rdchem.Mol, confId: int = -1, shapeOpt: rdkit.Chem.rdGaussianShape.ShapeInputOptions = <rdkit.Chem.rdGaussianShape.ShapeInputOptions object at 0x7e0a493819b0>, overlayOpts: rdkit.Chem.rdGaussianShape.ShapeOverlayOptions = <rdkit.Chem.rdGaussianShape.ShapeOverlayOptions object at 0x7e0a493246c0>)

Bases: object

ShapeInput object

BestSimilarity(self, fitShape: rdkit.Chem.rdGaussianShape.ShapeInput, threshold: float = -1.0, overlayOpts: rdkit.Chem.rdGaussianShape.ShapeOverlayOptions | None = None) tuple

Find the best similarity score between all shapes in this shape and the other one. Stops as soon as it gets something above the threshold. The score runs between 0.0 and 1.0, so the default threshold of -1.0 means no threshold. Fills in the shape numbers of the two that were responsible if there is something above the threshold, and the transformation that did it. Returns a tuple of the similarity scores ((-1.0, -1.0, -1.0) if there was nothing above the threshold), the number of the shape for this object and the shape number of the fitShape that gave the best similarity and the transformation matrix (as a list of 16 floats) that will reproduce the best overlay. The shapes won’t necessarily be left in the state that gave the best similarity. Note that the shape numbers are not necessarily the same as the original molecule conformation numbers.

property ColorVolume

Get the volume of the shape’s color features.

property GetSmiles

Get the SMILES string for the molecule that the shape relates to.

MaxPossibleSimilarity(self, fitShape: rdkit.Chem.rdGaussianShape.ShapeInput, overlayOpts: rdkit.Chem.rdGaussianShape.ShapeOverlayOptions | None = None) float

Get the maximum possible similarity score between all shapes in this shape and all shapes in the fitShape. The maximum similarity is when one shape is entirely inside the other. This returns the similarity in that case, which is the upper bound on what is achievable between these 2 shapes.

NormalizeCoords(self) None

Align the principal axes to the cartesian axes and centre on the origin. Doesn’t require that the shape was created from a molecule. Creates the necessary transformation if not already done.

property NumAtoms

Get the number of atoms defining the shape.

property NumFeatures

Get the number of features in the shape.

property NumShapes

Get the number of shapes. There will be a shape for each conformation of the input molecule, unless shape pruning was carried out in which case there may be fewer.

ShapeToMol(self, includeColors: bool = False, withBonds: bool = True) rdkit.Chem.rdchem.Mol

Return a molecule with coordinates of the current active shape. If includeColors is True, (default is False) the color features will be added as xenon atoms. If withBonds is True (the default) a molecule with bonds will be created, if not then just atoms at the appropriate positions will be produced.

property ShapeVolume

Get the shape’s volume due to the atoms.

getActiveShape(self) int

Return the number of the active shape.

setActiveShape(self, arg: int, /) None

Set the active shape, the one that will be used for overlays etc.

class rdkit.Chem.rdGaussianShape.ShapeInputOptions(self)

Bases: object

ShapeInputOptions - options for setting up ShapeInput objects.

property allCarbonRadii

Whether to use the same radius, appropriate for Carbon, for all atoms. There is a slight accuracy penalty but significant speed gain if used. Default=True.

property atomRadii

Non-standard radii to use for the atoms specified by their indices in the molecule. Not all atoms need have a radius specified. A list of tuples of [int, float].

property atomSubset

If not empty, use just these atoms in the molecule to form the ShapeInput object.

property customFeatures

Custom features for the shape. Requires a list of lists of tuples of int (the feature type), Point3D (the coordinates), float (the radius) and optionally a list of indices of the atoms that the feature was derived from.

property includeDummies

Whether to include dummy atoms in the shape or not. Default=True.

property shapePruneThreshold

If there is more than 1 conformer for the input molecule, prune the shapes so that none of them are more similar to each other than the threshold. Default -1.0 means no pruning.

property sortShapes

If True (the default), the shapes are sorted into descending order of total volume.

property useColors

Whether to use color features in overlay. Default=True.

class rdkit.Chem.rdGaussianShape.ShapeOverlayOptions(self)

Bases: object

ShapeOverlayOptions - options for controlling the shape overlay process.

property distCutoff

If using a distance cutoff, this is the value used. Default=4.5 of whatever units the coordinates are in.

property nSteps

Maximum number of steps for the shape overlay process. Default=100.

property normalize

Whether to normalize the shapes before overlay by putting them into their canonical orientation (centred on the origin, aligned along its principal axes. Default=True.

property optParam

If using colors, the relative weights of the shape and color scores, as a fraction of 1. Default=0.5.

property optimMode

Optimisation mode, controlling what parameters are used to drive the overlay. Default=SHAPE_PLUS_COLOR_SCORE which optimises using just the overlap of shape, but uses the color to decide which is the best overlay. Other options are SHAPE_ONLY and SHAPE_AND_COLOR with the latter using the overlap of color features as well.

property shapeConvergenceCriterion

Optimisation stops when the shape Tversky score changes by less than this amount after an optimisation step. A larger number is faster but gives less precise overlays. Default=0.001.

property simAlpha

When doing a Tversky similarity, the alpha value. If alpha and beta are both the default 1.0, it’s a Tanimoto similarity. A high alpha and low beta emphasize the fit volume in the similarity and vice versa. Tversky is O / (A * (R - O) + B * (F - O) + O) where O is the overlap volume, R is the reference’s volume and F is the fit’s volume. This is different from that used by OpenEye (O / (A * R + B * F)).

property simBeta

When doing a Tversky similarity, the beta value.

property startMode

Start modes for optimisation. Default is A_LA_PUBCHEM - as used by the PubChem code - either ROTATE_180_WIGGLE or ROTATE_45 depending on the shape of the two molecules. ROTATE_180_WIGGLE means 180 rotations about the x, y and z axes, then a small rotation about each axis from that point, using the best scoring one of those. ROTATE_180 uses 180 degree rotations for 4 start points, ROTATE_45 uses 45 degree rotations for 9 start points and ROTATE_0 leaves the relative orientations of the 2 molecules as passed in before optimisation. There are also ROTATE_0_FRAGMENT, ROTATE_45_FRAGMENT and ROTATE_180_FRAGMENT that as well as the above move the fit molecule to the ends of each of the principal axes and then does the appropriate rotations. This is useful when the fit molecule is a lot smaller than the reference molecule, but requires a large number of optimisations so is relatively slow.

property useDistCutoff

Whether to use distance cutoff when calculating the shape volumes. If used, there will be a small penalty in accuracy but a significant increase in speed. Default=True.

class rdkit.Chem.rdGaussianShape.StartMode(*values)

Bases: Enum

A_LA_PUBCHEM = 7
ROTATE_0 = 0
ROTATE_0_FRAGMENT = 4
ROTATE_180 = 1
ROTATE_180_FRAGMENT = 5
ROTATE_180_WIGGLE = 2
ROTATE_45 = 3
ROTATE_45_FRAGMENT = 6