conformersearch.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

conformersearch.h
Go to the documentation of this file.

    00001 /**********************************************************************
    00002 conformersearch.h - Conformer searching using genetic algorithm.
    00003
    00004 Copyright (C) 2010 Tim Vandermeersch
    00005
    00006 This file is part of the Open Babel project.
    00007 For more information, see <http://openbabel.org/>
    00008
    00009 This program is free software; you can redistribute it and/or modify
    00010 it under the terms of the GNU General Public License as published by
    00011 the Free Software Foundation version 2 of the License.
    00012
    00013 This program is distributed in the hope that it will be useful,
    00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016 GNU General Public License for more details.
    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   //  OBConformerFilter(s)
    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   //  OBConformerScore(s)
    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   //  OBConformerSearch
    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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines