Chemical Data Processing Library C++ API - Version 1.0.0
TautomerGenerator.hpp
Go to the documentation of this file.
1 /*
2  * TautomerGenerator.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_CHEM_TAUTOMERGENERATOR_HPP
30 #define CDPL_CHEM_TAUTOMERGENERATOR_HPP
31 
32 #include <vector>
33 #include <cstddef>
34 #include <cstdint>
35 #include <unordered_set>
36 #include <array>
37 #include <memory>
38 #include <functional>
39 
40 #include "CDPL/Chem/APIPrefix.hpp"
44 #include "CDPL/Util/ObjectPool.hpp"
45 
46 
47 namespace CDPL
48 {
49 
50  namespace Chem
51  {
52 
57  {
58 
59  public:
60  enum Mode
61  {
62 
65  EXHAUSTIVE
66  };
67 
68  typedef std::shared_ptr<TautomerGenerator> SharedPointer;
69 
70  typedef std::function<bool(MolecularGraph&)> CallbackFunction;
71  typedef std::function<void(MolecularGraph&)> CustomSetupFunction;
72 
77 
79 
80  virtual ~TautomerGenerator() {}
81 
83 
85 
87 
88  void removeTautomerizationRule(std::size_t idx);
89 
90  std::size_t getNumTautomerizationRules() const;
91 
93 
95 
96  void setMode(Mode mode);
97 
98  Mode getMode() const;
99 
100  void regardStereochemistry(bool regard);
101 
103 
104  void regardIsotopes(bool regard);
105 
106  bool isotopesRegarded() const;
107 
109 
114  void generate(const MolecularGraph& molgraph);
115 
116  private:
118  typedef MoleculeCache::SharedObjectPointer MoleculePtr;
119 
120  bool init(const MolecularGraph& molgraph);
121  void initHashCalculator();
122 
123  MoleculePtr copyInputMolGraph(const MolecularGraph& molgraph);
124 
125  void extractStereoCenters(const MolecularGraph& molgraph);
126  void extractAtomStereoCenters(const MolecularGraph& molgraph);
127  void extractBondStereoCenters(const MolecularGraph& molgraph);
128 
129  bool addNewTautomer(const MoleculePtr& mol);
130 
131  std::uint64_t calcTautomerHashCode(const BasicMolecule& tautomer);
132 
133  typedef std::array<std::size_t, 3> BondDescriptor;
134  typedef std::vector<MoleculePtr> MoleculeList;
135  typedef std::vector<TautomerizationRule::SharedPointer> TautRuleList;
136  typedef std::vector<BondDescriptor> BondDescrArray;
137  typedef std::vector<std::size_t> SizeTArray;
138  typedef std::unordered_set<std::uint64_t> HashCodeSet;
139  typedef std::array<std::size_t, 6> StereoCenter;
140  typedef std::vector<StereoCenter> StereoCenterList;
141 
142  MoleculeCache molCache;
143  CallbackFunction callbackFunc;
144  Mode mode;
145  bool regStereo;
146  bool regIsotopes;
147  CustomSetupFunction customSetupFunc;
148  TautRuleList tautRules;
149  MoleculeList currGeneration;
150  MoleculeList nextGeneration;
151  StereoCenterList atomStereoCenters;
152  StereoCenterList bondStereoCenters;
153  HashCodeSet tautHashCodes;
154  HashCodeCalculator hashCalculator;
155  BondDescrArray tautomerBonds;
156  SizeTArray shaInput;
157  };
158  } // namespace Chem
159 } // namespace CDPL
160 
161 #endif // CDPL_CHEM_TAUTOMERGENERATOR_HPP
CDPL::Chem::TautomerizationRule::SharedPointer
std::shared_ptr< TautomerizationRule > SharedPointer
Definition: TautomerizationRule.hpp:53
ObjectPool.hpp
Definition of the class CDPL::Util::ObjectPool.
CDPL::Chem::TautomerGenerator::regardStereochemistry
void regardStereochemistry(bool regard)
TautomerizationRule.hpp
Definition of the class CDPL::Chem::TautomerizationRule.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::TautomerGenerator::getCallbackFunction
const CallbackFunction & getCallbackFunction() const
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::TautomerGenerator
TautomerGenerator.
Definition: TautomerGenerator.hpp:57
CDPL::Chem::TautomerGenerator::Mode
Mode
Definition: TautomerGenerator.hpp:61
CDPL::Chem::TautomerGenerator::isotopesRegarded
bool isotopesRegarded() const
HashCodeCalculator.hpp
Definition of the class CDPL::Chem::HashCodeCalculator.
CDPL::Chem::BasicMolecule
BasicMolecule.
Definition: BasicMolecule.hpp:54
CDPL::Chem::TautomerGenerator::addTautomerizationRule
void addTautomerizationRule(const TautomerizationRule::SharedPointer &rule)
CDPL::Chem::TautomerGenerator::operator=
TautomerGenerator & operator=(const TautomerGenerator &gen)
CDPL::Chem::TautomerGenerator::TautomerGenerator
TautomerGenerator()
Constructs the TautomerGenerator instance.
CDPL::Chem::TautomerGenerator::TautomerGenerator
TautomerGenerator(const TautomerGenerator &gen)
CDPL::Chem::TautomerGenerator::getNumTautomerizationRules
std::size_t getNumTautomerizationRules() const
bool
CDPL::Chem::TautomerGenerator::setMode
void setMode(Mode mode)
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Chem::TautomerGenerator::CallbackFunction
std::function< bool(MolecularGraph &)> CallbackFunction
Definition: TautomerGenerator.hpp:70
CDPL::Chem::TautomerGenerator::removeTautomerizationRule
void removeTautomerizationRule(std::size_t idx)
CDPL::Chem::TautomerGenerator::stereochemistryRegarded
bool stereochemistryRegarded() const
CDPL::Chem::TautomerGenerator::TOPOLOGICALLY_UNIQUE
@ TOPOLOGICALLY_UNIQUE
Definition: TautomerGenerator.hpp:63
CDPL::Util::ObjectPool< BasicMolecule >
CDPL::Chem::TautomerGenerator::SharedPointer
std::shared_ptr< TautomerGenerator > SharedPointer
Definition: TautomerGenerator.hpp:68
CDPL::Chem::TautomerGenerator::getTautomerizationRule
const TautomerizationRule::SharedPointer & getTautomerizationRule(std::size_t idx) const
CDPL::Chem::TautomerGenerator::GEOMETRICALLY_UNIQUE
@ GEOMETRICALLY_UNIQUE
Definition: TautomerGenerator.hpp:64
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::TautomerGenerator::CustomSetupFunction
std::function< void(MolecularGraph &)> CustomSetupFunction
Definition: TautomerGenerator.hpp:71
CDPL::Chem::TautomerGenerator::setCallbackFunction
void setCallbackFunction(const CallbackFunction &func)
CDPL::Chem::TautomerGenerator::generate
void generate(const MolecularGraph &molgraph)
Generates all unique tautomers of the molecular graph molgraph.
CDPL::Chem::HashCodeCalculator
HashCodeCalculator.
Definition: HashCodeCalculator.hpp:57
CDPL::Chem::TautomerGenerator::setCustomSetupFunction
void setCustomSetupFunction(const CustomSetupFunction &func)
CDPL::Chem::TautomerGenerator::getMode
Mode getMode() const
CDPL::Chem::TautomerGenerator::~TautomerGenerator
virtual ~TautomerGenerator()
Definition: TautomerGenerator.hpp:80
BasicMolecule.hpp
Definition of the class CDPL::Chem::BasicMolecule.
CDPL::Chem::TautomerGenerator::regardIsotopes
void regardIsotopes(bool regard)