29 #ifndef CDPL_SHAPE_GAUSSIANSHAPEALIGNMENT_HPP
30 #define CDPL_SHAPE_GAUSSIANSHAPEALIGNMENT_HPP
35 #include <unordered_map>
39 #include <boost/functional/hash.hpp>
40 #include <boost/iterator/transform_iterator.hpp>
69 typedef std::vector<AlignmentResult> ResultList;
70 typedef std::vector<GaussianShapeFunction*> ShapeFunctionList;
76 static constexpr
double DEF_OPTIMIZATION_STOP_GRADIENT = 1.0;
78 static constexpr std::size_t DEF_MAX_OPTIMIZATION_ITERATIONS = 20;
80 static constexpr std::size_t DEF_MAX_PRODUCT_ORDER = 1;
84 static constexpr
double DEF_DISTANCE_CUTOFF = 0.0;
94 typedef boost::transform_iterator<GetShapeFunction, ShapeFunctionList::const_iterator>
ConstShapeIterator;
470 std::size_t setIndex;
472 unsigned int symClass;
475 double colSelfOverlap;
476 GaussianShapePtr shape;
479 typedef std::pair<std::size_t, std::size_t> ResultID;
483 void processResults(std::size_t ref_idx, std::size_t al_idx);
485 bool getResultIndex(
const ResultID& res_id, std::size_t& res_idx);
490 typedef std::vector<ShapeMetaData> ShapeMetaDataArray;
491 typedef std::unordered_map<ResultID, std::size_t, boost::hash<ResultID> > ResultIndexMap;
493 ShapeFunctionCache shapeFuncCache;
494 bool calcSlfOverlaps;
495 bool calcColSlfOverlaps;
496 unsigned int resultSelMode;
497 ResultCompareFunction resultCmpFunc;
498 ScoringFunction scoringFunc;
500 ShapeFunctionList refShapeFuncs;
501 ShapeMetaDataArray refShapeMetaData;
503 ShapeMetaData algdShapeMetaData;
504 ResultIndexMap resIndexMap;
506 std::size_t currSetIndex;
507 std::size_t currShapeIndex;
Definition of constants in namespace CDPL::Shape::AlignmentResultSelectionMode.
Definition of class CDPL::Shape::AlignmentResult.
Definition of class CDPL::Shape::GaussianShapeFunctionAlignment.
Definition of class CDPL::Shape::GaussianShapeFunction.
Definition of class CDPL::Shape::GaussianShapeSet.
Definition of matrix data types.
Definition of class CDPL::Util::ObjectStack.
Definition of the preprocessor macro CDPL_SHAPE_API.
#define CDPL_SHAPE_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Result of a Gaussian-shape alignment between a reference and an aligned shape.
Definition: AlignmentResult.hpp:52
Shape::GaussianShapeOverlapFunction implementation that uses two approximation techniques to trade so...
Definition: FastGaussianShapeOverlapFunction.hpp:58
Abstract base class for generators of starting transformations used to seed Gaussian-shape overlap op...
Definition: GaussianShapeAlignmentStartGenerator.hpp:57
High-level driver for the alignment of Gaussian shapes against a set of reference shapes.
Definition: GaussianShapeAlignment.hpp:67
PrincipalAxesAlignmentStartGenerator & getDefaultStartGenerator()
Returns the built-in principal-axes alignment-start generator.
ResultList::const_iterator ConstResultIterator
A constant iterator over the alignment results.
Definition: GaussianShapeAlignment.hpp:90
ConstShapeIterator getReferenceShapesEnd() const
Returns a constant iterator pointing one past the last reference shape.
bool calcColorOverlaps() const
Tells whether color overlaps are computed in addition to shape overlaps.
GaussianShapeFunctionAlignment::ColorFilterFunction ColorFilterFunction
Type of the function used to filter color (pharmacophore) features by type.
Definition: GaussianShapeAlignment.hpp:97
std::size_t getMaxOrder() const
Returns the currently configured maximum order of the Gaussian-product expansion.
GaussianShapeFunctionAlignment::ColorMatchFunction ColorMatchFunction
Type of the function used to decide whether two color features match.
Definition: GaussianShapeAlignment.hpp:99
GaussianShapeAlignment(const GaussianShapeSet &ref_shapes)
Constructs the GaussianShapeAlignment instance with the shapes in ref_shapes as the reference set.
const PrincipalAxesAlignmentStartGenerator & getDefaultStartGenerator() const
Returns the built-in principal-axes alignment-start generator.
void addReferenceShape(const GaussianShape &shape, bool new_set=true)
Adds shape to the reference shapes.
std::shared_ptr< GaussianShapeAlignment > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GaussianShapeAlignment instances.
Definition: GaussianShapeAlignment.hpp:87
void clearReferenceShapes()
Removes all reference shapes and reference shape sets.
void setDistanceCutoff(double cutoff)
Sets the distance cutoff for pruning negligible overlap contributions.
boost::transform_iterator< GetShapeFunction, ShapeFunctionList::const_iterator > ConstShapeIterator
A constant iterator over the reference shapes.
Definition: GaussianShapeAlignment.hpp:94
void setScoringFunction(const ScoringFunction &func)
Specifies the function used to score an alignment result.
std::function< bool(const AlignmentResult &, const AlignmentResult &)> ResultCompareFunction
Type of the function used to compare two alignment results.
Definition: GaussianShapeAlignment.hpp:103
void calcColorSelfOverlaps(bool calc)
Specifies whether color self-overlaps shall be computed for the involved shapes.
bool performAlignment() const
Tells whether the actual alignment is performed.
const FastGaussianShapeOverlapFunction & getDefaultOverlapFunction() const
Returns the built-in default overlap function.
FastGaussianShapeOverlapFunction & getDefaultOverlapFunction()
Returns the built-in default overlap function.
ResultIterator getResultsBegin()
Returns a mutable iterator pointing to the first alignment result.
AlignmentResult & getResult(std::size_t idx)
Returns the alignment result at index idx.
const GaussianShape & getReferenceShape(std::size_t idx) const
Returns the reference shape at index idx.
GaussianShapeAlignment & operator=(const GaussianShapeAlignment &alignment)=delete
~GaussianShapeAlignment()
Destructor.
std::size_t getNumReferenceShapes() const
Returns the total number of reference shapes.
const ColorFilterFunction & getColorFilterFunction() const
Returns the currently configured color-filter function.
double getOptimizationStopGradient() const
Returns the currently configured overlap-optimization stop gradient.
const ResultCompareFunction & getResultCompareFunction() const
Returns the currently configured result-compare function.
bool greedyOptimization() const
Tells whether the overlap optimization uses a greedy strategy.
ConstShapeIterator getReferenceShapesBegin() const
Returns a constant iterator pointing to the first reference shape.
GaussianShapeAlignment(const GaussianShapeAlignment &alignment)=delete
const ColorMatchFunction & getColorMatchFunction() const
Returns the currently configured color-match function.
double getDistanceCutoff() const
Returns the currently configured distance cutoff.
void setStartGenerator(GaussianShapeAlignmentStartGenerator &gen)
Specifies the alignment-start generator used to seed the overlap optimization.
ResultIterator getResultsEnd()
Returns a mutable iterator pointing one past the last alignment result.
bool calcSelfOverlaps() const
Tells whether shape self-overlaps are computed for the involved shapes.
void optimizeOverlap(bool optimize)
Specifies whether the overlap shall be optimized iteratively after the initial alignment.
GaussianShapeOverlapFunction & getOverlapFunction() const
Returns the currently configured overlap function.
GaussianShapeAlignmentStartGenerator & getStartGenerator() const
Returns the currently configured alignment-start generator.
std::size_t getMaxNumOptimizationIterations() const
Returns the currently configured maximum number of overlap-optimization iterations.
void setResultSelectionMode(unsigned int mode)
Sets the alignment-result selection mode (see namespace Shape::AlignmentResultSelectionMode).
ConstResultIterator getResultsBegin() const
Returns a constant iterator pointing to the first alignment result.
bool align(const GaussianShapeSet &shapes)
Aligns each shape in shapes against all reference shapes.
void setOverlapFunction(GaussianShapeOverlapFunction &func)
Specifies the Gaussian-shape overlap function used during alignment.
void setColorMatchFunction(const ColorMatchFunction &func)
Specifies the function used to decide whether two color features match.
const ScoringFunction & getScoringFunction() const
Returns the currently configured scoring function.
ConstResultIterator getResultsEnd() const
Returns a constant iterator pointing one past the last alignment result.
std::function< double(const AlignmentResult &)> ScoringFunction
Type of the function used to score an alignment result.
Definition: GaussianShapeAlignment.hpp:101
void performAlignment(bool perf_align)
Specifies whether the actual alignment shall be performed (vs. only computing overlaps in the initial...
std::size_t getNumResults() const
Returns the number of stored alignment results.
void greedyOptimization(bool greedy)
Specifies whether the overlap optimization shall use a greedy strategy that stops at the first local ...
bool calcColorSelfOverlaps() const
Tells whether color self-overlaps are computed for the involved shapes.
GaussianShapeAlignment()
Constructs the GaussianShapeAlignment instance.
bool optimizeOverlap() const
Tells whether the overlap is optimized iteratively.
void setOptimizationStopGradient(double grad_norm)
Sets the gradient norm at which the overlap optimization is stopped.
void calcColorOverlaps(bool calc)
Specifies whether color overlaps shall be computed in addition to shape overlaps.
void addReferenceShapes(const GaussianShapeSet &shapes, bool new_set=true)
Adds the shapes in shapes to the reference shapes.
void calcSelfOverlaps(bool calc)
Specifies whether shape self-overlaps shall be computed for the involved shapes.
ResultList::iterator ResultIterator
A mutable iterator over the alignment results.
Definition: GaussianShapeAlignment.hpp:92
const AlignmentResult & getResult(std::size_t idx) const
Returns the alignment result at index idx.
void setMaxOrder(std::size_t max_order)
Sets the maximum order of the Gaussian-product expansion used by the overlap function.
void setMaxNumOptimizationIterations(std::size_t max_iter)
Sets the maximum number of overlap-optimization iterations.
void setResultCompareFunction(const ResultCompareFunction &func)
Specifies the function used to compare two alignment results for sorting and filtering.
void setColorFilterFunction(const ColorFilterFunction &func)
Specifies the function used to filter color features by type.
GaussianShapeAlignment(const GaussianShape &ref_shape)
Constructs the GaussianShapeAlignment instance with ref_shape as the single reference shape.
unsigned int getResultSelectionMode() const
Returns the currently configured alignment-result selection mode.
bool align(const GaussianShape &shape)
Aligns shape against all reference shapes.
Driver for the alignment of one Shape::GaussianShapeFunction (the aligned shape) against a fixed refe...
Definition: GaussianShapeFunctionAlignment.hpp:63
GaussianShapeOverlapFunction::ColorMatchFunction ColorMatchFunction
Type of the function used to decide whether two color features match.
Definition: GaussianShapeFunctionAlignment.hpp:88
GaussianShapeOverlapFunction::ColorFilterFunction ColorFilterFunction
Type of the function used to filter color (pharmacophore) features by type.
Definition: GaussianShapeFunctionAlignment.hpp:85
Function representation of a Gaussian shape, used to evaluate the shape's density,...
Definition: GaussianShapeFunction.hpp:61
Abstract base class for functions evaluating the overlap between two Gaussian shape functions.
Definition: GaussianShapeOverlapFunction.hpp:56
Data structure storing a set of (shared) Gaussian shapes.
Definition: GaussianShapeSet.hpp:52
Data type for the descripton of arbitrary shapes composed of spheres approximated by gaussian functio...
Definition: GaussianShape.hpp:51
std::shared_ptr< GaussianShape > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GaussianShape instances.
Definition: GaussianShape.hpp:157
Generator that produces alignment starting transformations by aligning the principal axes of the alig...
Definition: PrincipalAxesAlignmentStartGenerator.hpp:58
constexpr unsigned int BEST_PER_REFERENCE_SET
Keep only the best alignment result per reference shape set.
Definition: AlignmentResultSelectionMode.hpp:63
CDPL_SHAPE_API void transform(GaussianShape &shape, const Math::Matrix4D &xform)
Applies an affine transformation to the element positions of shape.
The namespace of the Chemical Data Processing Library.