Chemical Data Processing Library C++ API - Version 1.3.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 
58  {
59 
60  public:
61  typedef std::shared_ptr<PatternBasedFeatureGenerator> SharedPointer;
62 
64  {
65 
66  FEATURE_ATOM_FLAG = 0x01,
67  POS_REF_ATOM_FLAG = 0x02,
68  GEOM_REF_ATOM1_FLAG = 0x04,
69  GEOM_REF_ATOM2_FLAG = 0x08
70  };
71 
76 
82 
87 
96  void addIncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
97  double tol, unsigned int geom, double length = 1.0);
98 
104 
109 
114 
121  void generate(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm);
122 
130 
132 
133  protected:
134  typedef std::vector<const Chem::Atom*> AtomList;
135 
138  bool calcCentroid(const AtomList&, Math::Vector3D&) const;
139 
140  virtual void addNonPatternFeatures(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm) {}
141 
144 
145  private:
146  struct IncludePattern
147  {
148 
149  IncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
150  double tol, unsigned int geom, double length):
151  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph)), featureType(type),
152  featureTol(tol), featureGeom(geom), vectorLength(length)
153  {}
154 
157  unsigned int featureType;
158  double featureTol;
159  unsigned int featureGeom;
160  double vectorLength;
161  };
162 
163  struct ExcludePattern
164  {
165 
166  ExcludePattern(const Chem::MolecularGraph::SharedPointer& molgraph):
167  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph))
168  {}
169 
172  };
173 
174  typedef std::vector<IncludePattern> IncludePatternList;
175  typedef std::vector<ExcludePattern> ExcludePatternList;
176  typedef Util::ObjectStack<Util::BitSet> BitSetCache;
177  typedef std::vector<Util::BitSet*> BitSetList;
178 
179  void init(const Chem::MolecularGraph& molgraph);
180 
181  void getExcludeMatches();
182 
183  void addFeature(const Chem::AtomBondMapping&, const IncludePattern&, Pharmacophore&);
184 
185  bool createMatchedAtomMask(const Chem::AtomMapping&, Util::BitSet&, bool, bool = true) const;
186  bool isContainedInList(const Util::BitSet&, const BitSetList&) const;
187 
188  const Chem::MolecularGraph* molGraph;
189  IncludePatternList includePatterns;
190  ExcludePatternList excludePatterns;
191  BitSetList includeMatches;
192  BitSetList excludeMatches;
193  AtomList posRefAtomList;
194  AtomList geomRefAtom1List;
195  AtomList geomRefAtom2List;
196  Math::Matrix<double> svdU;
197  Math::Matrix3D svdV;
198  Math::Vector3D svdW;
199  BitSetCache bitSetCache;
200  };
201  } // namespace Pharm
202 } // namespace CDPL
203 
204 #endif // CDPL_PHARM_PATTERNBASEDFEATUREGENERATOR_HPP
Definition of the class CDPL::Chem::AtomBondMapping.
Definition of the type CDPL::Util::BitSet.
Definition of the class CDPL::Pharm::FeatureGenerator.
Definition of matrix data types.
Definition of the class CDPL::Chem::MolecularGraph.
Definition of the 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 the class CDPL::Chem::SubstructureSearch.
Definition of vector data types.
MolecularGraph.
Definition: MolecularGraph.hpp:52
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
std::shared_ptr< SubstructureSearch > SharedPointer
Definition: SubstructureSearch.hpp:73
FeatureGenerator.
Definition: FeatureGenerator.hpp:57
std::shared_ptr< FeatureGenerator > SharedPointer
Definition: FeatureGenerator.hpp:60
PatternBasedFeatureGenerator.
Definition: PatternBasedFeatureGenerator.hpp:58
bool isContainedInIncMatchList(const Util::BitSet &) const
PatternAtomLabelFlag
Definition: PatternBasedFeatureGenerator.hpp:64
void clearExcludePatterns()
Clears the current set of exclude patterns.
double calcVecFeatureOrientation(const AtomList &, const AtomList &, Math::Vector3D &) const
std::shared_ptr< PatternBasedFeatureGenerator > SharedPointer
Definition: PatternBasedFeatureGenerator.hpp:61
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:134
virtual void addNonPatternFeatures(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Definition: PatternBasedFeatureGenerator.hpp:140
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
void clearIncludePatterns()
Clears the current set of include patterns.
Pharmacophore.
Definition: Pharmacophore.hpp:48
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:553
CVector< double, 3 > Vector3D
A bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:1637
CMatrix< double, 3, 3 > Matrix3D
A bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:1849
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.