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

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

+ Inheritance diagram for CDPL.Shape.GaussianShapeAlignment:

Public Member Functions

None __init__ ()
 Constructs the GaussianShapeAlignment instance.
 
None __init__ (GaussianShape ref_shape)
 Constructs the GaussianShapeAlignment instance with ref_shape as the single reference shape. More...
 
None __init__ (GaussianShapeSet ref_shapes)
 Constructs the GaussianShapeAlignment 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 setOverlapFunction (GaussianShapeOverlapFunction func)
 Specifies the Gaussian-shape overlap function used during alignment. More...
 
GaussianShapeOverlapFunction getOverlapFunction ()
 Returns the currently configured overlap function. More...
 
FastGaussianShapeOverlapFunction getDefaultOverlapFunction ()
 Returns the built-in default overlap function. More...
 
None setStartGenerator (GaussianShapeAlignmentStartGenerator gen)
 Specifies the alignment-start generator used to seed the overlap optimization. More...
 
GaussianShapeAlignmentStartGenerator getStartGenerator ()
 Returns the currently configured alignment-start generator. More...
 
PrincipalAxesAlignmentStartGenerator getDefaultStartGenerator ()
 Returns the built-in principal-axes alignment-start generator. More...
 
None setColorMatchFunction (Pharm.BoolSizeType2Functor func)
 Specifies the function used to decide whether two color features match. More...
 
Pharm.BoolSizeType2Functor getColorMatchFunction ()
 Returns the currently configured color-match function. More...
 
None setColorFilterFunction (BoolSizeTypeFunctor func)
 Specifies the function used to filter color features by type. More...
 
BoolSizeTypeFunctor getColorFilterFunction ()
 Returns the currently configured color-filter function. 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 calcColorOverlaps (bool calc)
 Specifies whether color overlaps shall be computed in addition to shape overlaps. More...
 
bool calcColorOverlaps ()
 Tells whether color overlaps are computed in addition to shape overlaps. More...
 
None calcSelfOverlaps (bool calc)
 Specifies whether shape self-overlaps shall be computed for the involved shapes. More...
 
bool calcSelfOverlaps ()
 Tells whether shape self-overlaps are computed for the involved shapes. More...
 
None calcColorSelfOverlaps (bool calc)
 Specifies whether color self-overlaps shall be computed for the involved shapes. More...
 
bool calcColorSelfOverlaps ()
 Tells whether color self-overlaps are computed for the involved shapes. More...
 
None setMaxOrder (int max_order)
 Sets the maximum order of the Gaussian-product expansion used by the overlap function. More...
 
int getMaxOrder ()
 Returns the currently configured maximum order of the Gaussian-product expansion. More...
 
None setDistanceCutoff (float cutoff)
 Sets the distance cutoff for pruning negligible overlap contributions. More...
 
float getDistanceCutoff ()
 Returns the currently configured distance cutoff. 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...
 
GaussianShape getReferenceShape (int idx)
 Returns the reference shape at index idx. 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_MAX_PRODUCT_ORDER = 1
 Default maximum order of the Gaussian-product expansion.
 
float DEF_DISTANCE_CUTOFF = 0.0
 Default distance cutoff for pruning negligible overlap contributions.
 
int DEF_RESULT_SELECTION_MODE = 3
 Default alignment-result selection mode.
 

Properties

 objectID = property(getObjectID)
 
 numResults = property(getNumResults)
 
 overlapFunction = property(getOverlapFunction, setOverlapFunction)
 
 defaultOverlapFunction = property(getDefaultOverlapFunction)
 
 startGenerator = property(getStartGenerator, setStartGenerator)
 
 defaultStartGenerator = property(getDefaultStartGenerator)
 
 colorMatchFunction = property(getColorMatchFunction, setColorMatchFunction)
 
 colorFilterFunction = property(getColorFilterFunction, setColorFilterFunction)
 
 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)
 
 selfOverlaps = property(calcSelfOverlaps, calcSelfOverlaps)
 
 colorSelfOverlaps = property(calcColorSelfOverlaps, calcColorSelfOverlaps)
 
 colorOverlaps = property(calcColorOverlaps, calcColorOverlaps)
 
 maxOrder = property(getMaxOrder, setMaxOrder)
 
 distCutoff = property(getDistanceCutoff, setDistanceCutoff)
 
 numReferenceShapes = property(getNumReferenceShapes)
 

Detailed Description

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

The class manages a list of reference Gaussian shapes (organised into reference sets), runs the underlying Shape.GaussianShapeFunctionAlignment for each (reference, aligned) pair, and collects the Shape.AlignmentResult instances filtered according to the configured selection mode and comparator/scoring functions.

Constructor & Destructor Documentation

◆ __init__() [1/2]

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

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

Parameters
ref_shapeThe reference shape.

◆ __init__() [2/2]

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

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

Parameters
ref_shapesThe reference shapes.

Member Function Documentation

◆ getObjectID()

int CDPL.Shape.GaussianShapeAlignment.getObjectID ( )

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

Different Python GaussianShapeAlignment 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 GaussianShapeAlignment 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.

◆ setOverlapFunction()

None CDPL.Shape.GaussianShapeAlignment.setOverlapFunction ( GaussianShapeOverlapFunction  func)

Specifies the Gaussian-shape overlap function used during alignment.

Parameters
funcThe overlap function.

◆ getOverlapFunction()

GaussianShapeOverlapFunction CDPL.Shape.GaussianShapeAlignment.getOverlapFunction ( )

Returns the currently configured overlap function.

Returns
A reference to the overlap function.

◆ getDefaultOverlapFunction()

FastGaussianShapeOverlapFunction CDPL.Shape.GaussianShapeAlignment.getDefaultOverlapFunction ( )

Returns the built-in default overlap function.

Returns
A reference to the default overlap function.

◆ setStartGenerator()

None CDPL.Shape.GaussianShapeAlignment.setStartGenerator ( GaussianShapeAlignmentStartGenerator  gen)

Specifies the alignment-start generator used to seed the overlap optimization.

Parameters
genThe alignment-start generator.

◆ getStartGenerator()

GaussianShapeAlignmentStartGenerator CDPL.Shape.GaussianShapeAlignment.getStartGenerator ( )

Returns the currently configured alignment-start generator.

Returns
A reference to the alignment-start generator.

◆ getDefaultStartGenerator()

PrincipalAxesAlignmentStartGenerator CDPL.Shape.GaussianShapeAlignment.getDefaultStartGenerator ( )

Returns the built-in principal-axes alignment-start generator.

Returns
A reference to the default alignment-start generator.

◆ setColorMatchFunction()

None CDPL.Shape.GaussianShapeAlignment.setColorMatchFunction ( Pharm.BoolSizeType2Functor  func)

Specifies the function used to decide whether two color features match.

Parameters
funcThe color-match function.

◆ getColorMatchFunction()

Pharm.BoolSizeType2Functor CDPL.Shape.GaussianShapeAlignment.getColorMatchFunction ( )

Returns the currently configured color-match function.

Returns
A reference to the color-match function.

◆ setColorFilterFunction()

None CDPL.Shape.GaussianShapeAlignment.setColorFilterFunction ( BoolSizeTypeFunctor  func)

Specifies the function used to filter color features by type.

Parameters
funcThe color-filter function.

◆ getColorFilterFunction()

BoolSizeTypeFunctor CDPL.Shape.GaussianShapeAlignment.getColorFilterFunction ( )

Returns the currently configured color-filter function.

Returns
A reference to the color-filter function.

◆ setResultCompareFunction()

None CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.getResultCompareFunction ( )

Returns the currently configured result-compare function.

Returns
A reference to the result-compare function.

◆ setScoringFunction()

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

Specifies the function used to score an alignment result.

Parameters
funcThe scoring function.

◆ getScoringFunction()

DoubleAlignmentResultFunctor CDPL.Shape.GaussianShapeAlignment.getScoringFunction ( )

Returns the currently configured scoring function.

Returns
A reference to the scoring function.

◆ setResultSelectionMode()

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

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

Parameters
modeThe new result-selection mode.

◆ getResultSelectionMode()

int CDPL.Shape.GaussianShapeAlignment.getResultSelectionMode ( )

Returns the currently configured alignment-result selection mode.

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

◆ setMaxNumOptimizationIterations()

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

Sets the maximum number of overlap-optimization iterations.

Parameters
max_iterThe new maximum number of iterations.

◆ getMaxNumOptimizationIterations()

int CDPL.Shape.GaussianShapeAlignment.getMaxNumOptimizationIterations ( )

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

Returns
The maximum number of iterations.

◆ setOptimizationStopGradient()

None CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.getOptimizationStopGradient ( )

Returns the currently configured overlap-optimization stop gradient.

Returns
The stop gradient norm.

◆ performAlignment() [1/2]

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

Specifies whether the actual alignment shall be performed (vs.

only computing 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.GaussianShapeAlignment.performAlignment ( )

Tells whether the actual alignment is performed.

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

◆ optimizeOverlap() [1/2]

None CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.optimizeOverlap ( )

Tells whether the overlap is optimized iteratively.

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

◆ greedyOptimization() [1/2]

None CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.greedyOptimization ( )

Tells whether the overlap optimization uses a greedy strategy.

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

◆ calcColorOverlaps() [1/2]

None CDPL.Shape.GaussianShapeAlignment.calcColorOverlaps ( bool  calc)

Specifies whether color overlaps shall be computed in addition to shape overlaps.

Parameters
calcTrue to compute color overlaps, and False to skip them.

◆ calcColorOverlaps() [2/2]

bool CDPL.Shape.GaussianShapeAlignment.calcColorOverlaps ( )

Tells whether color overlaps are computed in addition to shape overlaps.

Returns
True if color overlaps are computed, and False otherwise.

◆ calcSelfOverlaps() [1/2]

None CDPL.Shape.GaussianShapeAlignment.calcSelfOverlaps ( bool  calc)

Specifies whether shape self-overlaps shall be computed for the involved shapes.

Parameters
calcTrue to compute shape self-overlaps, and False to skip them.

◆ calcSelfOverlaps() [2/2]

bool CDPL.Shape.GaussianShapeAlignment.calcSelfOverlaps ( )

Tells whether shape self-overlaps are computed for the involved shapes.

Returns
True if shape self-overlaps are computed, and False otherwise.

◆ calcColorSelfOverlaps() [1/2]

None CDPL.Shape.GaussianShapeAlignment.calcColorSelfOverlaps ( bool  calc)

Specifies whether color self-overlaps shall be computed for the involved shapes.

Parameters
calcTrue to compute color self-overlaps, and False to skip them.

◆ calcColorSelfOverlaps() [2/2]

bool CDPL.Shape.GaussianShapeAlignment.calcColorSelfOverlaps ( )

Tells whether color self-overlaps are computed for the involved shapes.

Returns
True if color self-overlaps are computed, and False otherwise.

◆ setMaxOrder()

None CDPL.Shape.GaussianShapeAlignment.setMaxOrder ( int  max_order)

Sets the maximum order of the Gaussian-product expansion used by the overlap function.

Parameters
max_orderThe new maximum product order.

◆ getMaxOrder()

int CDPL.Shape.GaussianShapeAlignment.getMaxOrder ( )

Returns the currently configured maximum order of the Gaussian-product expansion.

Returns
The maximum product order.

◆ setDistanceCutoff()

None CDPL.Shape.GaussianShapeAlignment.setDistanceCutoff ( float  cutoff)

Sets the distance cutoff for pruning negligible overlap contributions.

Parameters
cutoffThe new distance cutoff.

◆ getDistanceCutoff()

float CDPL.Shape.GaussianShapeAlignment.getDistanceCutoff ( )

Returns the currently configured distance cutoff.

Returns
The distance cutoff.

◆ addReferenceShape()

None CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.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.GaussianShapeAlignment.getNumReferenceShapes ( )

Returns the total number of reference shapes.

Returns
The number of reference shapes.

◆ getReferenceShape()

GaussianShape CDPL.Shape.GaussianShapeAlignment.getReferenceShape ( int  idx)

Returns the reference shape at index idx.

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

◆ align() [1/2]

bool CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.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.GaussianShapeAlignment.getNumResults ( )

Returns the number of stored alignment results.

Returns
The number of alignment results.

◆ getResult()

AlignmentResult CDPL.Shape.GaussianShapeAlignment.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.GaussianShapeAlignment.__len__ ( )
Returns

◆ __getitem__()

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