Chemical Data Processing Library C++ API - Version 1.4.0
FeatureInteractionScoreGridCalculator.hpp
Go to the documentation of this file.
1 /*
2  * FeatureInteractionScoreGridCalculator.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_GRAIL_FEATUREINTERACTIONSCOREGRIDCALCULATOR_HPP
30 #define CDPL_GRAIL_FEATUREINTERACTIONSCOREGRIDCALCULATOR_HPP
31 
32 #include <vector>
33 #include <cstddef>
34 #include <memory>
35 #include <functional>
36 
37 #include "CDPL/GRAIL/APIPrefix.hpp"
38 #include "CDPL/Math/Vector.hpp"
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Internal
47  {
48 
49  template <typename PT, typename CT, typename ST>
50  class Octree;
51  }
52 
53  namespace Pharm
54  {
55 
56  class FeatureContainer;
57  class Feature;
58  } // namespace Pharm
59 
60  namespace GRAIL
61  {
62 
73  {
74 
75  public:
79  static constexpr double DEF_DISTANCE_CUTOFF = 10.0;
80 
84  typedef std::shared_ptr<FeatureInteractionScoreGridCalculator> SharedPointer;
85 
89  typedef std::function<bool(const Pharm::Feature&)> FeaturePredicate;
90 
94  typedef std::function<double(const Math::Vector3D&, const Pharm::Feature&)> ScoringFunction;
95 
99  typedef std::function<double(const Math::DVector&)> ScoreCombinationFunction;
100 
105  {
106 
107  double operator()(const Math::DVector& scores) const
108  {
109  return normInf(scores);
110  }
111  };
112 
117  {
118 
119  double operator()(const Math::DVector& scores) const
120  {
121  return sum(scores);
122  }
123  };
124 
129 
135 
142 
148 
153 
158  void normalizeScores(bool normalize);
159 
164  bool scoresNormalized() const;
165 
171 
177 
183 
189 
195 
201 
206  void setDistanceCutoff(double dist);
207 
212  double getDistanceCutoff() const;
213 
220 
227 
228  private:
229  typedef std::vector<const Pharm::Feature*> FeatureList;
230  typedef Internal::Octree<Math::Vector3D, Math::Vector3DArray, double> Octree;
231  typedef std::shared_ptr<Octree> OctreePtr;
232  typedef std::vector<std::size_t> FeatureIndexList;
233 
234  FeatureList tgtFeatures;
235  Math::DVector partialScores;
236  ScoringFunction scoringFunc;
237  ScoreCombinationFunction scoreCombinationFunc;
238  FeaturePredicate ftrSelectionPred;
239  double distCutoff;
240  OctreePtr octree;
241  Math::Vector3DArray featureCoords;
242  FeatureIndexList featureIndices;
243  bool normScores;
244  };
245  } // namespace GRAIL
246 } // namespace CDPL
247 
248 #endif // CDPL_GRAIL_FEATUREINTERACTIONSCOREGRIDCALCULATOR_HPP
Definition of the preprocessor macro CDPL_GRAIL_API.
#define CDPL_GRAIL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of a spatial grid data type.
Definition of class CDPL::Math::VectorArray.
Definition of vector data types.
Calculator that fills a spatial grid with per-cell feature-interaction scores against a set of target...
Definition: FeatureInteractionScoreGridCalculator.hpp:73
const ScoringFunction & getScoringFunction() const
Returns the currently configured scoring function.
FeatureInteractionScoreGridCalculator(const ScoringFunction &func)
Constructs the FeatureInteractionScoreGridCalculator instance with the given scoring function.
void setFeatureSelectionPredicate(const FeaturePredicate &pred)
Sets the predicate that decides whether a target feature shall be considered.
void normalizeScores(bool normalize)
Enables or disables normalization of the combined per-cell scores to the range [0,...
FeatureInteractionScoreGridCalculator & operator=(const FeatureInteractionScoreGridCalculator &calc)
Copy assignment operator.
void setScoringFunction(const ScoringFunction &func)
Sets the scoring function used to score the interaction between a grid cell and a target feature.
double getDistanceCutoff() const
Returns the currently configured cutoff distance.
std::function< double(const Math::Vector3D &, const Pharm::Feature &)> ScoringFunction
Type of the generic functor that scores the interaction between a grid cell and a target feature.
Definition: FeatureInteractionScoreGridCalculator.hpp:94
std::function< double(const Math::DVector &)> ScoreCombinationFunction
Type of the generic functor that combines per-feature scores into a single grid cell value.
Definition: FeatureInteractionScoreGridCalculator.hpp:99
bool scoresNormalized() const
Tells whether the combined per-cell scores are normalized.
void setScoreCombinationFunction(const ScoreCombinationFunction &func)
Sets the function used to combine per-feature scores into a single grid cell value.
FeatureInteractionScoreGridCalculator()
Constructs the FeatureInteractionScoreGridCalculator instance.
const ScoreCombinationFunction & getScoreCombinationFunction() const
Returns the currently configured score-combination function.
std::shared_ptr< FeatureInteractionScoreGridCalculator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FeatureInteractionScoreGridCalcul...
Definition: FeatureInteractionScoreGridCalculator.hpp:84
void setDistanceCutoff(double dist)
Sets the cutoff distance beyond which target features are not considered.
std::function< bool(const Pharm::Feature &)> FeaturePredicate
Type of the generic functor that decides whether a target feature shall be considered.
Definition: FeatureInteractionScoreGridCalculator.hpp:89
const FeaturePredicate & getFeatureSelectionPredicate() const
Returns the currently configured feature-selection predicate.
FeatureInteractionScoreGridCalculator(const ScoringFunction &scoring_func, const ScoreCombinationFunction &comb_func)
Constructs the FeatureInteractionScoreGridCalculator instance with the given scoring and score-combin...
FeatureInteractionScoreGridCalculator(const FeatureInteractionScoreGridCalculator &calc)
Constructs a copy of the FeatureInteractionScoreGridCalculator instance calc.
void calculate(const Pharm::FeatureContainer &tgt_ftrs, Grid::DSpatialGrid &grid)
Calculates the feature-interaction score at each cell of grid against tgt_ftrs.
Abstract base class for attributed grids whose elements have a defined 3D position in space.
Definition: SpatialGrid.hpp:53
Abstract base class for containers holding a sequence of Pharm::Feature objects with associated prope...
Definition: FeatureContainer.hpp:55
Abstract base class representing a single pharmacophore feature within a parent Pharm::Pharmacophore.
Definition: Feature.hpp:48
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:85
MatrixNormInfinity< E >::ResultType normInf(const MatrixExpression< E > &e)
Returns the L∞ (maximum absolute row sum) norm of the matrix expression e.
Definition: MatrixExpression.hpp:1650
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Returns the sum of all elements of the grid expression e.
Definition: GridExpression.hpp:720
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:2937
The namespace of the Chemical Data Processing Library.
Score-combination functor returning the maximum (infinity norm) of the per-feature scores.
Definition: FeatureInteractionScoreGridCalculator.hpp:105
double operator()(const Math::DVector &scores) const
Definition: FeatureInteractionScoreGridCalculator.hpp:107
Score-combination functor returning the sum of the per-feature scores.
Definition: FeatureInteractionScoreGridCalculator.hpp:117
double operator()(const Math::DVector &scores) const
Definition: FeatureInteractionScoreGridCalculator.hpp:119