Chemical Data Processing Library C++ API - Version 1.4.0
PatternBasedFeatureGenerator.hpp
Go to the documentation of this file.
1 /*
2  * PatternBasedFeatureGenerator.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_PHARM_PATTERNBASEDFEATUREGENERATOR_HPP
30 #define CDPL_PHARM_PATTERNBASEDFEATUREGENERATOR_HPP
31 
32 #include <vector>
33 #include <memory>
34 
35 #include "CDPL/Pharm/APIPrefix.hpp"
40 #include "CDPL/Util/BitSet.hpp"
42 #include "CDPL/Math/Vector.hpp"
43 #include "CDPL/Math/Matrix.hpp"
44 
45 
46 namespace CDPL
47 {
48 
49  namespace Pharm
50  {
51 
52  class Pharmacophore;
53 
59  {
60 
61  public:
65  typedef std::shared_ptr<PatternBasedFeatureGenerator> SharedPointer;
66 
73  {
74 
78  FEATURE_ATOM_FLAG = 0x01,
79 
83  POS_REF_ATOM_FLAG = 0x02,
84 
88  GEOM_REF_ATOM1_FLAG = 0x04,
89 
93  GEOM_REF_ATOM2_FLAG = 0x08
94  };
95 
100 
106 
111 
120  void addIncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
121  double tol, unsigned int geom, double length = 1.0);
122 
128 
133 
138 
145  void generate(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm);
146 
154 
160 
161  protected:
162  typedef std::vector<const Chem::Atom*> AtomList;
163 
166  bool calcCentroid(const AtomList&, Math::Vector3D&) const;
167 
168  virtual void addNonPatternFeatures(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm) {}
169 
172 
173  private:
174  struct IncludePattern
175  {
176 
177  IncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
178  double tol, unsigned int geom, double length):
179  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph)), featureType(type),
180  featureTol(tol), featureGeom(geom), vectorLength(length)
181  {}
182 
185  unsigned int featureType;
186  double featureTol;
187  unsigned int featureGeom;
188  double vectorLength;
189  };
190 
191  struct ExcludePattern
192  {
193 
194  ExcludePattern(const Chem::MolecularGraph::SharedPointer& molgraph):
195  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph))
196  {}
197 
200  };
201 
202  typedef std::vector<IncludePattern> IncludePatternList;
203  typedef std::vector<ExcludePattern> ExcludePatternList;
204  typedef Util::ObjectStack<Util::BitSet> BitSetCache;
205  typedef std::vector<Util::BitSet*> BitSetList;
206 
207  void init(const Chem::MolecularGraph& molgraph);
208 
209  void getExcludeMatches();
210 
211  void addFeature(const Chem::AtomBondMapping&, const IncludePattern&, Pharmacophore&);
212 
213  bool createMatchedAtomMask(const Chem::AtomMapping&, Util::BitSet&, bool, bool = true) const;
214  bool isContainedInList(const Util::BitSet&, const BitSetList&) const;
215 
216  const Chem::MolecularGraph* molGraph;
217  IncludePatternList includePatterns;
218  ExcludePatternList excludePatterns;
219  BitSetList includeMatches;
220  BitSetList excludeMatches;
221  AtomList posRefAtomList;
222  AtomList geomRefAtom1List;
223  AtomList geomRefAtom2List;
224  Math::Matrix<double> svdU;
225  Math::Matrix3D svdV;
226  Math::Vector3D svdW;
227  BitSetCache bitSetCache;
228  };
229  } // namespace Pharm
230 } // namespace CDPL
231 
232 #endif // CDPL_PHARM_PATTERNBASEDFEATUREGENERATOR_HPP
Definition of class CDPL::Chem::AtomBondMapping.
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::Pharm::FeatureGenerator.
Definition of matrix data types.
Definition of class CDPL::Chem::MolecularGraph.
Definition of class CDPL::Util::ObjectStack.
Definition of the preprocessor macro CDPL_PHARM_API.
#define CDPL_PHARM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Chem::SubstructureSearch.
Definition of vector data types.
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:63
std::shared_ptr< SubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureSearch instances.
Definition: SubstructureSearch.hpp:86
Abstract base class for generators that perceive one type of pharmacophore feature (e....
Definition: FeatureGenerator.hpp:58
std::shared_ptr< FeatureGenerator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FeatureGenerator instances.
Definition: FeatureGenerator.hpp:64
Pharm::FeatureGenerator implementation that perceives pharmacophore features by substructure pattern ...
Definition: PatternBasedFeatureGenerator.hpp:59
bool isContainedInIncMatchList(const Util::BitSet &) const
PatternAtomLabelFlag
Role-flags assigned (via the atom-mapping-ID property) to atoms of feature substructure patterns adde...
Definition: PatternBasedFeatureGenerator.hpp:73
void clearExcludePatterns()
Clears the current set of exclude patterns.
double calcVecFeatureOrientation(const AtomList &, const AtomList &, Math::Vector3D &) const
std::shared_ptr< PatternBasedFeatureGenerator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated PatternBasedFeatureGenerator inst...
Definition: PatternBasedFeatureGenerator.hpp:65
bool isContainedInExMatchList(const Util::BitSet &) const
PatternBasedFeatureGenerator()
Constructs the PatternBasedFeatureGenerator instance.
bool calcPlaneFeatureOrientation(const AtomList &, Math::Vector3D &, Math::Vector3D &)
std::vector< const Chem::Atom * > AtomList
Definition: PatternBasedFeatureGenerator.hpp:162
virtual void addNonPatternFeatures(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Definition: PatternBasedFeatureGenerator.hpp:168
void addExcludePattern(const Chem::MolecularGraph::SharedPointer &molgraph)
Appends a new feature substructure exclude pattern to the current set of patterns.
PatternBasedFeatureGenerator & operator=(const PatternBasedFeatureGenerator &gen)
Replaces the current set include/exclude patterns by the patterns in the PatternBasedFeatureGenerator...
bool calcCentroid(const AtomList &, Math::Vector3D &) const
void generate(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Perceives pharmacophore features according to the specified include/exclude patterns and adds them to...
PatternBasedFeatureGenerator(const PatternBasedFeatureGenerator &gen)
Constructs a copy of the PatternBasedFeatureGenerator instance gen.
void addIncludePattern(const Chem::MolecularGraph::SharedPointer &molgraph, unsigned int type, double tol, unsigned int geom, double length=1.0)
Appends a new feature substructure include pattern to the current set of patterns.
virtual ~PatternBasedFeatureGenerator()
Virtual destructor.
FeatureGenerator::SharedPointer clone() const
Creates a deep copy of the PatternBasedFeatureGenerator instance.
void clearIncludePatterns()
Clears the current set of include patterns.
Abstract base class for mutable containers of Pharm::Feature instances representing a pharmacophore m...
Definition: Pharmacophore.hpp:53
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Returns the length (L2 norm) of the vector expression e (alias of norm2()).
Definition: VectorExpression.hpp:1129
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating-point values of type double.
Definition: Vector.hpp:3218
CMatrix< double, 3, 3 > Matrix3D
Bounded 3×3 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3504
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.