Chemical Data Processing Library C++ API - Version 1.4.0
GRAILDataSetGenerator.hpp
Go to the documentation of this file.
1 /*
2  * GRAILDataSetGenerator.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_GRAILDATASETGENERATOR_HPP
30 #define CDPL_GRAIL_GRAILDATASETGENERATOR_HPP
31 
32 #include <map>
33 #include <set>
34 #include <utility>
35 #include <string>
36 #include <memory>
37 #include <functional>
38 
39 #include "CDPL/GRAIL/APIPrefix.hpp"
46 #include "CDPL/Math/Matrix.hpp"
47 #include "CDPL/Math/Vector.hpp"
48 
49 
50 namespace CDPL
51 {
52 
53  namespace GRAIL
54  {
55 
69  {
70 
71  public:
75  typedef std::shared_ptr<GRAILDataSetGenerator> SharedPointer;
76 
81 
86 
91 
95  static constexpr double DEF_GRID_STEP_SIZE = 0.5;
96 
101 
106 
113  void enableInteraction(unsigned int ftr_type, unsigned int tgt_ftr_type, bool enable);
114 
121  bool isInteractionEnabled(unsigned int ftr_type, unsigned int tgt_ftr_type) const;
122 
127 
134  void setScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type, const ScoringFunction& func);
135 
142  const ScoringFunction& getScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type) const;
143 
149  void removeScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type);
150 
157  void setGridName(unsigned int ftr_type, unsigned int tgt_ftr_type, const std::string& name);
158 
165  const std::string& getGridName(unsigned int ftr_type, unsigned int tgt_ftr_type) const;
166 
172  void removeGridName(unsigned int ftr_type, unsigned int tgt_ftr_type);
173 
179 
185 
190  void normalizeScores(bool normalize);
191 
196  bool scoresNormalized() const;
197 
202  void diminishScoresByAtomDensity(bool diminish);
203 
209 
215 
221 
226  void setEnvironmentAtomDensityGridName(const std::string& name);
227 
232  const std::string& getEnvironmentAtomDensityGridName() const;
233 
239 
245  template <typename T>
246  void setGridTransform(const T& xform)
247  {
248  gridTransform = xform;
249  }
250 
255  double getGridStepSize() const;
256 
261  void setGridStepSize(double size);
262 
267  std::size_t getGridXSize() const;
268 
273  void setGridXSize(std::size_t size);
274 
279  std::size_t getGridYSize() const;
280 
285  void setGridYSize(std::size_t size);
286 
291  std::size_t getGridZSize() const;
292 
297  void setGridZSize(std::size_t size);
298 
305  void setGridParamsForBoundingBox(const Math::Vector3D& bbox_min, const Math::Vector3D& bbox_max, double step_size = DEF_GRID_STEP_SIZE);
306 
312 
318 
324 
330 
339  Grid::DRegularGridSet& grid_set, bool append = false);
340 
350  const std::string& grid_name);
351 
352  private:
353  Grid::DRegularGrid::SharedPointer createGrid() const;
354 
355  void init();
356 
357  typedef std::pair<unsigned int, unsigned int> FeatureTypePair;
358  typedef std::map<FeatureTypePair, ScoringFunction> ScoringFuncMap;
359  typedef std::map<FeatureTypePair, std::string> GridNameMap;
360  typedef std::set<FeatureTypePair> EnabledInteractionsSet;
361 
362  ScoringFuncMap ftrInteractionScoringFuncMap;
363  GridNameMap gridNameMap;
364  EnabledInteractionsSet enabledFtrInteractions;
365  FeatureInteractionScoreGridCalculator ftrInteractionGridCalc;
366  AtomDensityGridCalculator atomDensityGridCalc;
368  PharmacophoreProcessingFunction pharmProcessingFunc;
369  Pharm::BasicPharmacophore pharmacophore;
370  double gridStepSize;
371  std::size_t gridXSize;
372  std::size_t gridYSize;
373  std::size_t gridZSize;
374  Math::Matrix4D gridTransform;
375  bool diminishByAtomDensity;
376  bool storeEnvAtomDensityGrid;
377  std::string envAtomDensityGridName;
378  };
379  } // namespace GRAIL
380 } // namespace CDPL
381 
382 #endif // CDPL_GRAIL_GRAILDATASETGENERATOR_HPP
Type declaration of a generic wrapper class for storing user-defined Chem::Atom 3D-coordinates functi...
Definition of class CDPL::GRAIL::AtomDensityGridCalculator.
Definition of class CDPL::Pharm::BasicPharmacophore.
Definition of class CDPL::Pharm::DefaultPharmacophoreGenerator.
Definition of class CDPL::GRAIL::FeatureInteractionScoreGridCalculator.
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 matrix data types.
Definition of class CDPL::Grid::RegularGridSet.
Definition of vector data types.
Common interface for data structures that support a random access to stored Chem::Atom instances.
Definition: AtomContainer.hpp:55
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Calculator that fills a spatial grid with combined per-atom density contributions.
Definition: AtomDensityGridCalculator.hpp:73
Calculator that fills a spatial grid with per-cell feature-interaction scores against a set of target...
Definition: FeatureInteractionScoreGridCalculator.hpp:73
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
Generator that pre-computes the per-cell interaction-score grids and the atom-density grid used by GR...
Definition: GRAILDataSetGenerator.hpp:69
void setScoreCombinationFunction(const ScoreCombinationFunction &func)
Sets the function used to combine per-feature scores into a single grid cell value.
void setGridXSize(std::size_t size)
Sets the grid size in the x direction.
virtual ~GRAILDataSetGenerator()
Virtual destructor.
Definition: GRAILDataSetGenerator.hpp:105
std::shared_ptr< GRAILDataSetGenerator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GRAILDataSetGenerator instances.
Definition: GRAILDataSetGenerator.hpp:75
void clearEnabledInteractions()
Disables interaction-grid generation for all feature-type pairs.
GRAILDataSetGenerator()
Constructs the GRAILDataSetGenerator instance.
std::size_t getGridYSize() const
Returns the grid size in the y direction.
std::size_t getGridZSize() const
Returns the grid size in the z direction.
void setGridParamsForBoundingBox(const Math::Vector3D &bbox_min, const Math::Vector3D &bbox_max, double step_size=DEF_GRID_STEP_SIZE)
Convenience method that configures grid size, spacing and transformation so that the grid covers the ...
bool scoresNormalized() const
Tells whether the combined per-cell scores are normalized.
void setGridZSize(std::size_t size)
Sets the grid size in the z direction.
bool scoresDiminishedByAtomDensity() const
Tells whether the interaction scores are diminished by the atom density of the target environment.
void setGridStepSize(double size)
Sets the grid spacing (isotropic).
double getGridStepSize() const
Returns the currently configured grid spacing.
const ScoreCombinationFunction & getScoreCombinationFunction() const
Returns the currently configured score-combination function.
void normalizeScores(bool normalize)
Enables or disables normalization of the combined per-cell scores to the range [0,...
const Pharm::DefaultPharmacophoreGenerator & getPharmacophoreGenerator() const
Returns the internal pharmacophore generator used for the target environment.
std::function< void(CDPL::Pharm::Pharmacophore &)> PharmacophoreProcessingFunction
Type of the generic functor used to post-process a generated pharmacophore prior to grid calculation.
Definition: GRAILDataSetGenerator.hpp:90
FeatureInteractionScoreGridCalculator::ScoringFunction ScoringFunction
Re-export of the scoring-function type used by the underlying score-grid calculator.
Definition: GRAILDataSetGenerator.hpp:80
const ScoringFunction & getScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type) const
Returns the scoring function configured for the given (ligand feature type, target feature type) pair...
void removeGridName(unsigned int ftr_type, unsigned int tgt_ftr_type)
Removes the grid name associated with the given (ligand feature type, target feature type) pair.
bool isInteractionEnabled(unsigned int ftr_type, unsigned int tgt_ftr_type) const
Tells whether interaction-grid generation is enabled for the given (ligand feature type,...
Grid::DRegularGrid::SharedPointer calcAtomDensityGrid(const Chem::AtomContainer &atoms, const Chem::Atom3DCoordinatesFunction &coords_func, const std::string &grid_name)
Calculates an atom-density grid for the given atoms.
FeatureInteractionScoreGridCalculator::ScoreCombinationFunction ScoreCombinationFunction
Re-export of the score-combination function type used by the underlying score-grid calculator.
Definition: GRAILDataSetGenerator.hpp:85
const std::string & getEnvironmentAtomDensityGridName() const
Returns the name assigned to the target environment atom-density grid.
const Math::Matrix4D & getGridTransform() const
Returns the affine transformation matrix that places the grids in the target coordinate frame.
void setGridName(unsigned int ftr_type, unsigned int tgt_ftr_type, const std::string &name)
Sets the grid name associated with the given (ligand feature type, target feature type) pair.
const std::string & getGridName(unsigned int ftr_type, unsigned int tgt_ftr_type) const
Returns the grid name associated with the given (ligand feature type, target feature type) pair.
void setEnvironmentAtomDensityGridName(const std::string &name)
Sets the name to assign to the target environment atom-density grid in the produced grid set.
std::size_t getGridXSize() const
Returns the grid size in the x direction.
const PharmacophoreProcessingFunction & getPharmacophoreProcessingFunction() const
Returns the currently configured pharmacophore processing function.
void calcInteractionGrids(const Chem::MolecularGraph &tgt_env, const Chem::Atom3DCoordinatesFunction &coords_func, Grid::DRegularGridSet &grid_set, bool append=false)
Calculates the interaction-score grids for all enabled feature-type pairs and stores them in grid_set...
bool environmentAtomDensityGridStored() const
Tells whether the target environment atom-density grid is stored in the produced grid set.
Pharm::DefaultPharmacophoreGenerator & getPharmacophoreGenerator()
Returns the internal pharmacophore generator used for the target environment.
void setGridYSize(std::size_t size)
Sets the grid size in the y direction.
void storeEnvironmentAtomDensityGrid(bool store)
Specifies whether the target environment atom-density grid shall be added to the produced grid set.
void enableInteraction(unsigned int ftr_type, unsigned int tgt_ftr_type, bool enable)
Enables or disables interaction-grid generation for the given (ligand feature type,...
void setGridTransform(const T &xform)
Sets the affine transformation matrix that places the grids in the target coordinate frame.
Definition: GRAILDataSetGenerator.hpp:246
void removeScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type)
Removes the scoring function configured for the given (ligand feature type, target feature type) pair...
void setPharmacophoreProcessingFunction(const PharmacophoreProcessingFunction &func)
Sets the function applied to the generated target pharmacophore before grid calculation (e....
void setScoringFunction(unsigned int ftr_type, unsigned int tgt_ftr_type, const ScoringFunction &func)
Sets the scoring function for the given (ligand feature type, target feature type) pair.
void diminishScoresByAtomDensity(bool diminish)
Enables or disables multiplicative diminishing of interaction scores by the (normalized) atom density...
Indirected array of dynamically allocated Grid::RegularGrid instances.
Definition: RegularGridSet.hpp:49
std::shared_ptr< RegularGrid > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated RegularGrid instances.
Definition: RegularGrid.hpp:61
Concrete Pharm::Pharmacophore implementation that owns its features as Pharm::BasicFeature instances ...
Definition: BasicPharmacophore.hpp:53
Pharmacophore generator pre-configured with the built-in default set of feature generators.
Definition: DefaultPharmacophoreGenerator.hpp:53
Abstract base class for mutable containers of Pharm::Feature instances representing a pharmacophore m...
Definition: Pharmacophore.hpp:53
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
std::function< const Math::Vector3D &(const Chem::Atom &)> Atom3DCoordinatesFunction
Generic wrapper class used to store a user-defined Chem::Atom 3D-coordinates function.
Definition: Atom3DCoordinatesFunction.hpp:43
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.