Chemical Data Processing Library C++ API - Version 1.1.1
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& pattern, 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& substruct, unsigned int type,
150  double tol, unsigned int geom, double length):
151  subQuery(substruct),
152  subSearch(new Chem::SubstructureSearch(*substruct)), featureType(type),
153  featureTol(tol), featureGeom(geom), vectorLength(length)
154  {
155 
156  subSearch->uniqueMappingsOnly(false);
157  }
158 
161  unsigned int featureType;
162  double featureTol;
163  unsigned int featureGeom;
164  double vectorLength;
165  };
166 
167  struct ExcludePattern
168  {
169 
170  ExcludePattern(const Chem::MolecularGraph::SharedPointer& substruct):
171  subQuery(substruct), subSearch(new Chem::SubstructureSearch(*substruct))
172  {
173 
174  subSearch->uniqueMappingsOnly(true);
175  }
176 
179  };
180 
181  typedef std::vector<IncludePattern> IncludePatternList;
182  typedef std::vector<ExcludePattern> ExcludePatternList;
183  typedef Util::ObjectStack<Util::BitSet> BitSetCache;
184  typedef std::vector<Util::BitSet*> BitSetList;
185 
186  void init(const Chem::MolecularGraph& molgraph);
187 
188  void getExcludeMatches();
189 
190  void addFeature(const Chem::AtomBondMapping&, const IncludePattern&, Pharmacophore&);
191 
192  void createMatchedAtomMask(const Chem::AtomMapping&, Util::BitSet&, bool) const;
193  bool isContainedInList(const Util::BitSet&, const BitSetList&) const;
194 
195  const Chem::MolecularGraph* molGraph;
196  IncludePatternList includePatterns;
197  ExcludePatternList excludePatterns;
198  BitSetList includeMatches;
199  BitSetList excludeMatches;
200  AtomList posRefAtomList;
201  AtomList geomRefAtom1List;
202  AtomList geomRefAtom2List;
203  Math::Matrix<double> svdU;
204  Math::Matrix3D svdV;
205  Math::Vector3D svdW;
206  BitSetCache bitSetCache;
207  };
208  } // namespace Pharm
209 } // namespace CDPL
210 
211 #endif // CDPL_PHARM_PATTERNBASEDFEATUREGENERATOR_HPP
CDPL::Chem::MolecularGraph::SharedPointer
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
APIPrefix.hpp
Definition of the preprocessor macro CDPL_PHARM_API.
CDPL_PHARM_API
#define CDPL_PHARM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
ObjectStack.hpp
Definition of the class CDPL::Util::ObjectStack.
CDPL::Pharm::PatternBasedFeatureGenerator::~PatternBasedFeatureGenerator
virtual ~PatternBasedFeatureGenerator()
Virtual destructor.
CDPL::Pharm::PatternBasedFeatureGenerator::clone
FeatureGenerator::SharedPointer clone() const
CDPL::Pharm::FeatureGenerator::SharedPointer
std::shared_ptr< FeatureGenerator > SharedPointer
Definition: FeatureGenerator.hpp:60
CDPL::Pharm::PatternBasedFeatureGenerator::AtomList
std::vector< const Chem::Atom * > AtomList
Definition: PatternBasedFeatureGenerator.hpp:134
CDPL::Math::Vector3D
CVector< double, 3 > Vector3D
A bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:1637
CDPL::Pharm::PatternBasedFeatureGenerator::calcVecFeatureOrientation
double calcVecFeatureOrientation(const AtomList &, const AtomList &, Math::Vector3D &) const
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
CDPL::Pharm::PatternBasedFeatureGenerator::PatternBasedFeatureGenerator
PatternBasedFeatureGenerator(const PatternBasedFeatureGenerator &gen)
Constructs a copy of the PatternBasedFeatureGenerator instance gen.
CDPL::Pharm::PatternBasedFeatureGenerator::operator=
PatternBasedFeatureGenerator & operator=(const PatternBasedFeatureGenerator &gen)
Replaces the current set include/exclude patterns by the patterns in the PatternBasedFeatureGenerator...
CDPL::Pharm::PatternBasedFeatureGenerator::generate
void generate(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Perceives pharmacophore features according to the specified include/exclude patterns and adds them to...
CDPL::Pharm::PatternBasedFeatureGenerator::PatternAtomLabelFlag
PatternAtomLabelFlag
Definition: PatternBasedFeatureGenerator.hpp:64
CDPL::Pharm::PatternBasedFeatureGenerator::addNonPatternFeatures
virtual void addNonPatternFeatures(const Chem::MolecularGraph &molgraph, Pharmacophore &pharm)
Definition: PatternBasedFeatureGenerator.hpp:140
CDPL::Pharm::FeatureGenerator
FeatureGenerator.
Definition: FeatureGenerator.hpp:57
CDPL::Pharm::PatternBasedFeatureGenerator
PatternBasedFeatureGenerator.
Definition: PatternBasedFeatureGenerator.hpp:58
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
CDPL::Pharm::PatternBasedFeatureGenerator::addIncludePattern
void addIncludePattern(const Chem::MolecularGraph::SharedPointer &pattern, unsigned int type, double tol, unsigned int geom, double length=1.0)
Appends a new feature include pattern to the current set of patterns.
CDPL::Pharm::PatternBasedFeatureGenerator::clearExcludePatterns
void clearExcludePatterns()
Clears the current set of exclude patterns.
CDPL::Pharm::PatternBasedFeatureGenerator::SharedPointer
std::shared_ptr< PatternBasedFeatureGenerator > SharedPointer
Definition: PatternBasedFeatureGenerator.hpp:61
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
CDPL::Pharm::Pharmacophore
Pharmacophore.
Definition: Pharmacophore.hpp:48
AtomBondMapping.hpp
Definition of the class CDPL::Chem::AtomBondMapping.
CDPL::Math::Matrix3D
CMatrix< double, 3, 3 > Matrix3D
A bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:1849
CDPL::Pharm::PatternBasedFeatureGenerator::PatternBasedFeatureGenerator
PatternBasedFeatureGenerator()
Constructs the PatternBasedFeatureGenerator instance.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Pharm::PatternBasedFeatureGenerator::isContainedInIncMatchList
bool isContainedInIncMatchList(const Util::BitSet &) const
CDPL::Pharm::PatternBasedFeatureGenerator::calcPlaneFeatureOrientation
bool calcPlaneFeatureOrientation(const AtomList &, Math::Vector3D &, Math::Vector3D &)
SubstructureSearch.hpp
Definition of the class CDPL::Chem::SubstructureSearch.
Matrix.hpp
Definition of matrix data types.
CDPL::Pharm::PatternBasedFeatureGenerator::calcCentroid
bool calcCentroid(const AtomList &, Math::Vector3D &) const
CDPL::Pharm::PatternBasedFeatureGenerator::clearIncludePatterns
void clearIncludePatterns()
Clears the current set of include patterns.
CDPL::Pharm::PatternBasedFeatureGenerator::isContainedInExMatchList
bool isContainedInExMatchList(const Util::BitSet &) const
CDPL::Chem::SubstructureSearch::SharedPointer
std::shared_ptr< SubstructureSearch > SharedPointer
Definition: SubstructureSearch.hpp:73
FeatureGenerator.hpp
Definition of the class CDPL::Pharm::FeatureGenerator.
CDPL::Pharm::PatternBasedFeatureGenerator::addExcludePattern
void addExcludePattern(const Chem::MolecularGraph::SharedPointer &pattern)
Appends a new feature include pattern to the current set of patterns.
Vector.hpp
Definition of vector data types.
CDPL::Math::length
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:553