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:
63  typedef std::shared_ptr<PatternBasedFeatureGenerator> SharedPointer;
64 
71  {
72 
74  FEATURE_ATOM_FLAG = 0x01,
76  POS_REF_ATOM_FLAG = 0x02,
78  GEOM_REF_ATOM1_FLAG = 0x04,
80  GEOM_REF_ATOM2_FLAG = 0x08
81  };
82 
87 
93 
98 
107  void addIncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
108  double tol, unsigned int geom, double length = 1.0);
109 
115 
120 
125 
132  void generate(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm);
133 
141 
147 
148  protected:
149  typedef std::vector<const Chem::Atom*> AtomList;
150 
153  bool calcCentroid(const AtomList&, Math::Vector3D&) const;
154 
155  virtual void addNonPatternFeatures(const Chem::MolecularGraph& molgraph, Pharmacophore& pharm) {}
156 
159 
160  private:
161  struct IncludePattern
162  {
163 
164  IncludePattern(const Chem::MolecularGraph::SharedPointer& molgraph, unsigned int type,
165  double tol, unsigned int geom, double length):
166  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph)), featureType(type),
167  featureTol(tol), featureGeom(geom), vectorLength(length)
168  {}
169 
172  unsigned int featureType;
173  double featureTol;
174  unsigned int featureGeom;
175  double vectorLength;
176  };
177 
178  struct ExcludePattern
179  {
180 
181  ExcludePattern(const Chem::MolecularGraph::SharedPointer& molgraph):
182  molGraph(molgraph), subSearch(new Chem::SubstructureSearch(*molgraph))
183  {}
184 
187  };
188 
189  typedef std::vector<IncludePattern> IncludePatternList;
190  typedef std::vector<ExcludePattern> ExcludePatternList;
191  typedef Util::ObjectStack<Util::BitSet> BitSetCache;
192  typedef std::vector<Util::BitSet*> BitSetList;
193 
194  void init(const Chem::MolecularGraph& molgraph);
195 
196  void getExcludeMatches();
197 
198  void addFeature(const Chem::AtomBondMapping&, const IncludePattern&, Pharmacophore&);
199 
200  bool createMatchedAtomMask(const Chem::AtomMapping&, Util::BitSet&, bool, bool = true) const;
201  bool isContainedInList(const Util::BitSet&, const BitSetList&) const;
202 
203  const Chem::MolecularGraph* molGraph;
204  IncludePatternList includePatterns;
205  ExcludePatternList excludePatterns;
206  BitSetList includeMatches;
207  BitSetList excludeMatches;
208  AtomList posRefAtomList;
209  AtomList geomRefAtom1List;
210  AtomList geomRefAtom2List;
211  Math::Matrix<double> svdU;
212  Math::Matrix3D svdV;
213  Math::Vector3D svdW;
214  BitSetCache bitSetCache;
215  };
216  } // namespace Pharm
217 } // namespace CDPL
218 
219 #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:62
Pharm::FeatureGenerator implementation that perceives pharmacophore features by SMARTS-like substruct...
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:71
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:63
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:149
virtual void addNonPatternFeatures(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Definition: PatternBasedFeatureGenerator.hpp:155
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:979
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:2937
CMatrix< double, 3, 3 > Matrix3D
Bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:3180
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.