Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OB_CONFORMERSEARCH_H
00020 #define OB_CONFORMERSEARCH_H
00021
00022 #include <openbabel/mol.h>
00023 #include <openbabel/rotor.h>
00024 #include <openbabel/rotamer.h>
00025
00026 namespace OpenBabel {
00027
00028 typedef std::vector<int> RotorKey;
00029 typedef std::vector<RotorKey> RotorKeys;
00030
00033
00035
00036
00037
00039
00052 class OBAPI OBConformerFilter
00053 {
00054 public:
00061 virtual bool IsGood(const OBMol &mol, const RotorKey &key, double *coords) = 0;
00062 };
00063
00076 class OBAPI OBConformerFilters : public OBConformerFilter
00077 {
00078 public:
00082 OBConformerFilters(const std::vector<OBConformerFilter*> &filters) : m_filters(filters)
00083 {
00084 }
00089 bool IsGood(const OBMol &mol, const RotorKey &key, double *coords)
00090 {
00091 for (unsigned int i = 0; i < m_filters.size(); ++i)
00092 if (!m_filters[i]->IsGood(mol, key, coords))
00093 return false;
00094 return true;
00095 }
00096 protected:
00097 std::vector<OBConformerFilter*> m_filters;
00098 };
00099
00109 class OBAPI OBStericConformerFilter : public OBConformerFilter
00110 {
00111 public:
00112 OBStericConformerFilter(double cutoff) : m_cutoff(cutoff) {}
00113 bool IsGood(const OBMol &mol, const RotorKey &key, double *coords);
00114 private:
00115 double m_cutoff;
00116 };
00117
00119
00120
00121
00123
00137 class OBAPI OBConformerScore
00138 {
00139 public:
00143 enum Preferred { HighScore, LowScore };
00147 virtual Preferred GetPreferred() = 0;
00151 enum Convergence { Highest, Lowest, Sum, Average };
00155 virtual Convergence GetConvergence() = 0;
00159 virtual double Score(OBMol &mol, unsigned int index, const RotorKeys &keys,
00160 const std::vector<double*> &conformers) = 0;
00161 };
00162
00171 class OBAPI OBRMSDConformerScore : public OBConformerScore
00172 {
00173 public:
00174 Preferred GetPreferred() { return HighScore; }
00175 Convergence GetConvergence() { return Average; }
00176 double Score(OBMol &mol, unsigned int index, const RotorKeys &keys,
00177 const std::vector<double*> &conformers);
00178 };
00179
00185 class OBAPI OBEnergyConformerScore : public OBConformerScore
00186 {
00187 public:
00188 Preferred GetPreferred() { return LowScore; }
00189 Convergence GetConvergence() { return Lowest; }
00190 double Score(OBMol &mol, unsigned int index, const RotorKeys &keys,
00191 const std::vector<double*> &conformers);
00192 };
00193
00194
00196
00197
00198
00200
00207 class OBAPI OBConformerSearch
00208 {
00209 public:
00210 OBConformerSearch();
00211 ~OBConformerSearch();
00225 bool Setup(const OBMol &mol, int numConformers = 30, int numChildren = 5,
00226 int mutability = 5, int convergence = 25);
00230 void SetNumConformers(int numConformers) { m_numConformers = numConformers; }
00234 void SetNumChildren(int numChildren) { m_numChildren = numChildren; }
00238 void SetMutability(int mutability) { m_mutability = mutability; }
00243 void SetConvergence(int convergence) { m_convergence = convergence; }
00247 void SetFixedBonds(const OBBitVec &fixedBonds) { m_fixedBonds = fixedBonds; }
00248
00249
00258 void SetFilter(OBConformerFilter *filter)
00259 {
00260 delete m_filter;
00261 m_filter = filter;
00262 }
00272 void SetScore(OBConformerScore *score)
00273 {
00274 delete m_score;
00275 m_score = score;
00276 }
00277
00281 void Search();
00282
00283 const RotorKeys& GetRotorKeys() const
00284 {
00285 return m_rotorKeys;
00286 }
00287
00288 void GetConformers(OBMol &mol);
00289 private:
00293 void NextGeneration();
00297 double MakeSelection();
00301 bool IsUniqueKey(const RotorKeys &keys, const RotorKey &key) const;
00305 bool IsGood(const RotorKey &key);
00306
00307 int m_numConformers;
00308 int m_numChildren;
00309 int m_mutability;
00310 int m_convergence;
00311
00312 OBBitVec m_fixedBonds;
00313 OBMol m_mol;
00314 OBRotorList m_rotorList;
00315 RotorKeys m_rotorKeys;
00316
00317 OBConformerFilter *m_filter;
00318 OBConformerScore *m_score;
00319
00320
00321 };
00322
00429
00430 };
00431
00432 #endif
00433