Chemical Data Processing Library Python API - Version 1.4.0
Public Member Functions | Static Public Attributes | Properties | List of all members
CDPL.Shape.FastGaussianShapeAlignment Class Reference

High-level driver for the fast alignment of Gaussian shapes against a set of reference shapes. More...

+ Inheritance diagram for CDPL.Shape.FastGaussianShapeAlignment:

Public Member Functions

None __init__ ()
 Constructs the FastGaussianShapeAlignment instance.
 
None __init__ (GaussianShape ref_shape)
 Constructs the FastGaussianShapeAlignment instance with ref_shape as the single reference shape. More...
 
None __init__ (GaussianShapeSet ref_shapes)
 Constructs the FastGaussianShapeAlignment instance with the shapes in ref_shapes as the reference set. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
None setResultCompareFunction (BoolAlignmentResult2Functor func)
 Specifies the function used to compare two alignment results for sorting and filtering. More...
 
BoolAlignmentResult2Functor getResultCompareFunction ()
 Returns the currently configured result-compare function. More...
 
None setScoringFunction (DoubleAlignmentResultFunctor func)
 Specifies the function used to score an alignment result. More...
 
DoubleAlignmentResultFunctor getScoringFunction ()
 Returns the currently configured scoring function. More...
 
None setResultSelectionMode (int mode)
 Sets the alignment-result selection mode (see namespace Shape.AlignmentResultSelectionMode). More...
 
int getResultSelectionMode ()
 Returns the currently configured alignment-result selection mode. More...
 
None setMaxNumOptimizationIterations (int max_iter)
 Sets the maximum number of overlap-optimization iterations. More...
 
int getMaxNumOptimizationIterations ()
 Returns the currently configured maximum number of overlap-optimization iterations. More...
 
None setOptimizationStopGradient (float grad_norm)
 Sets the gradient norm at which the overlap optimization is stopped. More...
 
float getOptimizationStopGradient ()
 Returns the currently configured overlap-optimization stop gradient. More...
 
None performAlignment (bool perf_align)
 Specifies whether the actual alignment shall be performed (vs. More...
 
bool performAlignment ()
 Tells whether the actual alignment is performed. More...
 
None optimizeOverlap (bool optimize)
 Specifies whether the overlap shall be optimized iteratively after the initial alignment. More...
 
bool optimizeOverlap ()
 Tells whether the overlap is optimized iteratively. More...
 
None greedyOptimization (bool greedy)
 Specifies whether the overlap optimization shall use a greedy strategy that stops at the first local maximum. More...
 
bool greedyOptimization ()
 Tells whether the overlap optimization uses a greedy strategy. More...
 
None setSymmetryThreshold (float thresh)
 Sets the relative threshold for treating two principal moments as equal. More...
 
float getSymmetryThreshold ()
 Returns the currently configured symmetry threshold. More...
 
None genShapeCenterStarts (bool generate)
 Enables or disables the generation of a starting transformation at the shape centroid. More...
 
bool genShapeCenterStarts ()
 Tells whether a starting transformation at the shape centroid is generated. More...
 
None genColorCenterStarts (bool generate)
 Enables or disables the generation of starting transformations at color (pharmacophore) feature centers. More...
 
bool genColorCenterStarts ()
 Tells whether starting transformations at color (pharmacophore) feature centers are generated. More...
 
None genNonColorCenterStarts (bool generate)
 Enables or disables the generation of starting transformations at non-color (shape) element centers. More...
 
bool genNonColorCenterStarts ()
 Tells whether starting transformations at non-color (shape) element centers are generated. More...
 
None genRandomStarts (bool generate)
 Enables or disables the generation of random starting transformations. More...
 
bool genRandomStarts ()
 Tells whether random starting transformations are generated. More...
 
None genForAlignedShapeCenters (bool generate)
 Specifies whether element-/color-center starts shall be generated for centers of the aligned shape. More...
 
bool genForAlignedShapeCenters ()
 Tells whether element-/color-center starts are generated for centers of the aligned shape. More...
 
None genForReferenceShapeCenters (bool generate)
 Specifies whether element-/color-center starts shall be generated for centers of the reference shape. More...
 
bool genForReferenceShapeCenters ()
 Tells whether element-/color-center starts are generated for centers of the reference shape. More...
 
None genForLargerShapeCenters (bool generate)
 Specifies whether element-/color-center starts shall be generated for centers of the shape with more elements (instead of both shapes). More...
 
bool genForLargerShapeCenters ()
 Tells whether element-/color-center starts are generated for centers of the shape with more elements (instead of both shapes). More...
 
None setMaxRandomTranslation (float max_trans)
 Sets the maximum random translation magnitude applied to random starts. More...
 
float getMaxRandomTranslation ()
 Returns the currently configured maximum random translation. More...
 
None setNumRandomStarts (int num_starts)
 Sets the number of random starting transformations. More...
 
int getNumRandomStarts ()
 Returns the currently configured number of random starts. More...
 
None setRandomSeed (int seed)
 Sets the seed used by the random number generator that produces the random starts. More...
 
None clearReferenceShapes ()
 Removes all reference shapes and reference shape sets.
 
None addReferenceShape (GaussianShape shape, bool new_set=True)
 Adds shape to the reference shapes. More...
 
None addReferenceShapes (GaussianShapeSet shapes, bool new_set=True)
 Adds the shapes in shapes to the reference shapes. More...
 
int getNumReferenceShapes ()
 Returns the total number of reference shapes. More...
 
bool align (GaussianShape shape)
 Aligns shape against all reference shapes. More...
 
bool align (GaussianShapeSet shapes)
 Aligns each shape in shapes against all reference shapes. More...
 
int getNumResults ()
 Returns the number of stored alignment results. More...
 
AlignmentResult getResult (int idx)
 Returns the alignment result at index idx. More...
 
int __len__ ()
 
AlignmentResult __getitem__ (int idx)
 

Static Public Attributes

float DEF_OPTIMIZATION_STOP_GRADIENT = 1.0
 Default gradient norm at which the overlap optimization is stopped.
 
int DEF_MAX_OPTIMIZATION_ITERATIONS = 20
 Default maximum number of overlap-optimization iterations.
 
int DEF_RESULT_SELECTION_MODE = 3
 Default alignment-result selection mode.
 
float DEF_SYMMETRY_THRESHOLD = 0.15
 Default relative threshold for treating two principal moments as equal.
 
int DEF_NUM_RANDOM_STARTS = 4
 Default number of random starting transformations.
 
float DEF_MAX_RANDOM_TRANSLATION = 2.0
 Default maximum random translation magnitude applied to random starts.
 

Properties

 objectID = property(getObjectID)
 
 numResults = property(getNumResults)
 
 resultCompareFunction = property(getResultCompareFunction, setResultCompareFunction)
 
 scoringFunction = property(getScoringFunction, setScoringFunction)
 
 resultSelectionMode = property(getResultSelectionMode, setResultSelectionMode)
 
 maxNumOptIterations = property(getMaxNumOptimizationIterations, setMaxNumOptimizationIterations)
 
 optStopGradient = property(getOptimizationStopGradient, setOptimizationStopGradient)
 
 perfAlignment = property(performAlignment, performAlignment)
 
 optOverlap = property(optimizeOverlap, optimizeOverlap)
 
 greedyOpt = property(greedyOptimization, greedyOptimization)
 
 numReferenceShapes = property(getNumReferenceShapes)
 
 symmetryThreshold = property(getSymmetryThreshold, setSymmetryThreshold)
 
 maxRandomTranslation = property(getMaxRandomTranslation, setMaxRandomTranslation)
 
 numRandomStarts = property(getNumRandomStarts, setNumRandomStarts)
 
 shapeCenterStarts = property(genShapeCenterStarts, genShapeCenterStarts)
 
 colorCenterStarts = property(genColorCenterStarts, genColorCenterStarts)
 
 nonColorCenterStarts = property(genNonColorCenterStarts, genNonColorCenterStarts)
 
 randomStarts = property(getNumRandomStarts, setNumRandomStarts)
 
 genForAlignedShapeCtrs = property(genForAlignedShapeCenters, genForAlignedShapeCenters)
 
 genForReferenceShapeCrs = property(genForReferenceShapeCenters, genForReferenceShapeCenters)
 
 genForLargerShapeCtrs = property(genForLargerShapeCenters, genForLargerShapeCenters)
 

Detailed Description

High-level driver for the fast alignment of Gaussian shapes against a set of reference shapes.

Unlike Shape.GaussianShapeAlignment, which delegates the alignment to a separate Shape.GaussianShapeFunctionAlignment instance, FastGaussianShapeAlignment integrates the entire pipeline (start-transform generation, BFGS overlap optimization, result selection) into one class and operates on a self-contained Gaussian-product representation. The configuration combines settings exposed by Shape.PrincipalAxesAlignmentStartGenerator (start-transform options) and the iterative overlap optimization.

Constructor & Destructor Documentation

◆ __init__() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.__init__ ( GaussianShape  ref_shape)

Constructs the FastGaussianShapeAlignment instance with ref_shape as the single reference shape.

Parameters
ref_shapeThe reference shape.

◆ __init__() [2/2]

None CDPL.Shape.FastGaussianShapeAlignment.__init__ ( GaussianShapeSet  ref_shapes)

Constructs the FastGaussianShapeAlignment instance with the shapes in ref_shapes as the reference set.

Parameters
ref_shapesThe reference shapes.

Member Function Documentation

◆ getObjectID()

int CDPL.Shape.FastGaussianShapeAlignment.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python FastGaussianShapeAlignment instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two FastGaussianShapeAlignment instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ setResultCompareFunction()

None CDPL.Shape.FastGaussianShapeAlignment.setResultCompareFunction ( BoolAlignmentResult2Functor  func)

Specifies the function used to compare two alignment results for sorting and filtering.

Parameters
funcThe result-compare function.

◆ getResultCompareFunction()

BoolAlignmentResult2Functor CDPL.Shape.FastGaussianShapeAlignment.getResultCompareFunction ( )

Returns the currently configured result-compare function.

Returns
A reference to the result-compare function.

◆ setScoringFunction()

None CDPL.Shape.FastGaussianShapeAlignment.setScoringFunction ( DoubleAlignmentResultFunctor  func)

Specifies the function used to score an alignment result.

Parameters
funcThe scoring function.

◆ getScoringFunction()

DoubleAlignmentResultFunctor CDPL.Shape.FastGaussianShapeAlignment.getScoringFunction ( )

Returns the currently configured scoring function.

Returns
A reference to the scoring function.

◆ setResultSelectionMode()

None CDPL.Shape.FastGaussianShapeAlignment.setResultSelectionMode ( int  mode)

Sets the alignment-result selection mode (see namespace Shape.AlignmentResultSelectionMode).

Parameters
modeThe new result-selection mode.

◆ getResultSelectionMode()

int CDPL.Shape.FastGaussianShapeAlignment.getResultSelectionMode ( )

Returns the currently configured alignment-result selection mode.

Returns
The result-selection mode (see namespace Shape.AlignmentResultSelectionMode).

◆ setMaxNumOptimizationIterations()

None CDPL.Shape.FastGaussianShapeAlignment.setMaxNumOptimizationIterations ( int  max_iter)

Sets the maximum number of overlap-optimization iterations.

Parameters
max_iterThe new maximum number of iterations.

◆ getMaxNumOptimizationIterations()

int CDPL.Shape.FastGaussianShapeAlignment.getMaxNumOptimizationIterations ( )

Returns the currently configured maximum number of overlap-optimization iterations.

Returns
The maximum number of iterations.

◆ setOptimizationStopGradient()

None CDPL.Shape.FastGaussianShapeAlignment.setOptimizationStopGradient ( float  grad_norm)

Sets the gradient norm at which the overlap optimization is stopped.

Parameters
grad_normThe new stop gradient norm.

◆ getOptimizationStopGradient()

float CDPL.Shape.FastGaussianShapeAlignment.getOptimizationStopGradient ( )

Returns the currently configured overlap-optimization stop gradient.

Returns
The stop gradient norm.

◆ performAlignment() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.performAlignment ( bool  perf_align)

Specifies whether the actual alignment shall be performed (vs.

only evaluating overlaps in the initial pose).

Parameters
perf_alignTrue to perform the alignment, and False to only evaluate the initial pose.

◆ performAlignment() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.performAlignment ( )

Tells whether the actual alignment is performed.

Returns
True if the alignment is performed, and False otherwise.

◆ optimizeOverlap() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.optimizeOverlap ( bool  optimize)

Specifies whether the overlap shall be optimized iteratively after the initial alignment.

Parameters
optimizeTrue to optimize the overlap, and False to skip optimization.

◆ optimizeOverlap() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.optimizeOverlap ( )

Tells whether the overlap is optimized iteratively.

Returns
True if the overlap is optimized, and False otherwise.

◆ greedyOptimization() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.greedyOptimization ( bool  greedy)

Specifies whether the overlap optimization shall use a greedy strategy that stops at the first local maximum.

Parameters
greedyTrue to use the greedy strategy, and False to use the full optimization.

◆ greedyOptimization() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.greedyOptimization ( )

Tells whether the overlap optimization uses a greedy strategy.

Returns
True if the greedy strategy is used, and False otherwise.

◆ setSymmetryThreshold()

None CDPL.Shape.FastGaussianShapeAlignment.setSymmetryThreshold ( float  thresh)

Sets the relative threshold for treating two principal moments as equal.

Parameters
threshThe new symmetry threshold.

◆ getSymmetryThreshold()

float CDPL.Shape.FastGaussianShapeAlignment.getSymmetryThreshold ( )

Returns the currently configured symmetry threshold.

Returns
The symmetry threshold.

◆ genShapeCenterStarts() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genShapeCenterStarts ( bool  generate)

Enables or disables the generation of a starting transformation at the shape centroid.

Parameters
generateTrue to enable the shape-centroid start, and False to disable it.

◆ genShapeCenterStarts() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genShapeCenterStarts ( )

Tells whether a starting transformation at the shape centroid is generated.

Returns
True if a shape-centroid start is generated, and False otherwise.

◆ genColorCenterStarts() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genColorCenterStarts ( bool  generate)

Enables or disables the generation of starting transformations at color (pharmacophore) feature centers.

Parameters
generateTrue to enable the color-center starts, and False to disable them.

◆ genColorCenterStarts() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genColorCenterStarts ( )

Tells whether starting transformations at color (pharmacophore) feature centers are generated.

Returns
True if color-center starts are generated, and False otherwise.

◆ genNonColorCenterStarts() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genNonColorCenterStarts ( bool  generate)

Enables or disables the generation of starting transformations at non-color (shape) element centers.

Parameters
generateTrue to enable the non-color-center starts, and False to disable them.

◆ genNonColorCenterStarts() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genNonColorCenterStarts ( )

Tells whether starting transformations at non-color (shape) element centers are generated.

Returns
True if non-color-center starts are generated, and False otherwise.

◆ genRandomStarts() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genRandomStarts ( bool  generate)

Enables or disables the generation of random starting transformations.

Parameters
generateTrue to enable the random starts, and False to disable them.

◆ genRandomStarts() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genRandomStarts ( )

Tells whether random starting transformations are generated.

Returns
True if random starts are generated, and False otherwise.

◆ genForAlignedShapeCenters() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genForAlignedShapeCenters ( bool  generate)

Specifies whether element-/color-center starts shall be generated for centers of the aligned shape.

Parameters
generateTrue to consider aligned-shape centers, and False to ignore them.

◆ genForAlignedShapeCenters() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genForAlignedShapeCenters ( )

Tells whether element-/color-center starts are generated for centers of the aligned shape.

Returns
True if aligned-shape centers are considered, and False otherwise.

◆ genForReferenceShapeCenters() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genForReferenceShapeCenters ( bool  generate)

Specifies whether element-/color-center starts shall be generated for centers of the reference shape.

Parameters
generateTrue to consider reference-shape centers, and False to ignore them.

◆ genForReferenceShapeCenters() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genForReferenceShapeCenters ( )

Tells whether element-/color-center starts are generated for centers of the reference shape.

Returns
True if reference-shape centers are considered, and False otherwise.

◆ genForLargerShapeCenters() [1/2]

None CDPL.Shape.FastGaussianShapeAlignment.genForLargerShapeCenters ( bool  generate)

Specifies whether element-/color-center starts shall be generated for centers of the shape with more elements (instead of both shapes).

Parameters
generateTrue to use only the centers of the larger shape, and False to use the centers of all configured shapes.

◆ genForLargerShapeCenters() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.genForLargerShapeCenters ( )

Tells whether element-/color-center starts are generated for centers of the shape with more elements (instead of both shapes).

Returns
True if only the centers of the larger shape are used, and False otherwise.

◆ setMaxRandomTranslation()

None CDPL.Shape.FastGaussianShapeAlignment.setMaxRandomTranslation ( float  max_trans)

Sets the maximum random translation magnitude applied to random starts.

Parameters
max_transThe new maximum random translation magnitude.

◆ getMaxRandomTranslation()

float CDPL.Shape.FastGaussianShapeAlignment.getMaxRandomTranslation ( )

Returns the currently configured maximum random translation.

Returns
The maximum random translation magnitude.

◆ setNumRandomStarts()

None CDPL.Shape.FastGaussianShapeAlignment.setNumRandomStarts ( int  num_starts)

Sets the number of random starting transformations.

Parameters
num_startsThe new number of random starts.

◆ getNumRandomStarts()

int CDPL.Shape.FastGaussianShapeAlignment.getNumRandomStarts ( )

Returns the currently configured number of random starts.

Returns
The number of random starts.

◆ setRandomSeed()

None CDPL.Shape.FastGaussianShapeAlignment.setRandomSeed ( int  seed)

Sets the seed used by the random number generator that produces the random starts.

Parameters
seedThe new random seed.

◆ addReferenceShape()

None CDPL.Shape.FastGaussianShapeAlignment.addReferenceShape ( GaussianShape  shape,
bool   new_set = True 
)

Adds shape to the reference shapes.

Parameters
shapeThe reference shape.
new_setIf True, shape is added to a new reference set. Otherwise, it is appended to the most recent reference set.

◆ addReferenceShapes()

None CDPL.Shape.FastGaussianShapeAlignment.addReferenceShapes ( GaussianShapeSet  shapes,
bool   new_set = True 
)

Adds the shapes in shapes to the reference shapes.

Parameters
shapesThe reference shapes.
new_setIf True, the shapes are added to a new reference set. Otherwise, they are appended to the most recent reference set.

◆ getNumReferenceShapes()

int CDPL.Shape.FastGaussianShapeAlignment.getNumReferenceShapes ( )

Returns the total number of reference shapes.

Returns
The number of reference shapes.

◆ align() [1/2]

bool CDPL.Shape.FastGaussianShapeAlignment.align ( GaussianShape  shape)

Aligns shape against all reference shapes.

Parameters
shapeThe shape to align.
Returns
True if at least one alignment result was produced, and False otherwise.

◆ align() [2/2]

bool CDPL.Shape.FastGaussianShapeAlignment.align ( GaussianShapeSet  shapes)

Aligns each shape in shapes against all reference shapes.

Parameters
shapesThe shapes to align.
Returns
True if at least one alignment result was produced, and False otherwise.

◆ getNumResults()

int CDPL.Shape.FastGaussianShapeAlignment.getNumResults ( )

Returns the number of stored alignment results.

Returns
The number of alignment results.

◆ getResult()

AlignmentResult CDPL.Shape.FastGaussianShapeAlignment.getResult ( int  idx)

Returns the alignment result at index idx.

Parameters
idxThe zero-based result index.
Returns
A reference to the result.
Exceptions
Base.IndexErrorif the number of results is zero or idx is not in the range [0, getNumResults() - 1].

◆ __len__()

int CDPL.Shape.FastGaussianShapeAlignment.__len__ ( )
Returns

◆ __getitem__()

AlignmentResult CDPL.Shape.FastGaussianShapeAlignment.__getitem__ ( int  idx)
Parameters
idx
Returns