Chemical Data Processing Library C++ API - Version 1.3.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"
46 #include "CDPL/Util/ObjectPool.hpp"
47 
48 
49 namespace CDPL
50 {
51 
52  namespace Chem
53  {
54 
59  {
60 
61  public:
62  enum Mode
63  {
64 
67  EXHAUSTIVE
68  };
69 
70  typedef std::shared_ptr<TautomerGenerator> SharedPointer;
71 
72  typedef std::function<bool(MolecularGraph&)> CallbackFunction;
73  typedef std::function<void(MolecularGraph&)> CustomSetupFunction;
74 
79 
81 
82  virtual ~TautomerGenerator() {}
83 
85 
87 
89 
90  void removeTautomerizationRule(std::size_t idx);
91 
92  std::size_t getNumTautomerizationRules() const;
93 
95 
97 
98  void setMode(Mode mode);
99 
100  Mode getMode() const;
101 
102  void regardStereochemistry(bool regard);
103 
105 
106  void regardIsotopes(bool regard);
107 
108  bool isotopesRegarded() const;
109 
113  void clearCoordinates2D(bool clear);
114 
118  bool coordinates2DCleared() const;
119 
123  void clearCoordinates3D(bool clear);
124 
128  bool coordinates3DCleared() const;
129 
133  void removeResonanceDuplicates(bool remove);
134 
139 
141 
146  void generate(const MolecularGraph& molgraph);
147 
148  private:
150  typedef MoleculeCache::SharedObjectPointer MoleculePtr;
151 
152  bool init(const MolecularGraph& molgraph);
153  void initHashCalculator();
154 
155  MoleculePtr copyInputMolGraph(const MolecularGraph& molgraph);
156 
157  void extractStereoCenters(const MolecularGraph& molgraph);
158  void extractAtomStereoCenters(const MolecularGraph& molgraph);
159  void extractBondStereoCenters(const MolecularGraph& molgraph);
160 
161  bool addNewTautomer(const MoleculePtr& mol_ptr);
162  bool outputTautomer(const MoleculePtr& mol_ptr);
163 
164  std::uint64_t calcConTabHashCode(const MolecularGraph& molgraph, bool arom_bonds);
165 
166  void generateSSSR(MolecularGraph& molgraph);
167  void setAromaticityFlags(MolecularGraph& molgraph);
168  void calcCIPConfigurations(MolecularGraph& molgraph);
169 
170  typedef std::array<std::size_t, 3> BondDescriptor;
171  typedef std::vector<MoleculePtr> MoleculeList;
172  typedef std::vector<TautomerizationRule::SharedPointer> TautRuleList;
173  typedef std::vector<BondDescriptor> BondDescrArray;
174  typedef std::vector<std::size_t> SizeTArray;
175  typedef std::unordered_set<std::uint64_t> HashCodeSet;
176  typedef std::array<std::size_t, 6> StereoCenter;
177  typedef std::vector<StereoCenter> StereoCenterList;
178 
179  MoleculeCache molCache;
180  CallbackFunction callbackFunc;
181  Mode mode;
182  bool regStereo;
183  bool regIsotopes;
184  bool remResDuplicates;
185  bool clear2DCoords;
186  bool clear3DCoords;
187  CustomSetupFunction customSetupFunc;
188  TautRuleList tautRules;
189  MoleculeList currGeneration;
190  MoleculeList nextGeneration;
191  StereoCenterList atomStereoCenters;
192  StereoCenterList bondStereoCenters;
193  HashCodeSet intermTautHashCodes;
194  HashCodeSet outputTautHashCodes;
195  HashCodeCalculator hashCalculator;
196  AromaticSubstructure aromSubstruct;
197  CIPConfigurationLabeler cipLabeler;
198  BondDescrArray tautomerBonds;
199  SizeTArray shaInput;
200  const MolecularGraph* molGraph;
201  };
202  } // namespace Chem
203 } // namespace CDPL
204 
205 #endif // CDPL_CHEM_TAUTOMERGENERATOR_HPP
Definition of the class CDPL::Chem::AromaticSubstructure.
Definition of the class CDPL::Chem::BasicMolecule.
Definition of the class CDPL::Chem::CIPConfigurationLabeler.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Chem::HashCodeCalculator.
Definition of the class CDPL::Util::ObjectPool.
Definition of the class CDPL::Chem::TautomerizationRule.
Implements the perception of aromatic atoms and bonds in a molecular graph.
Definition: AromaticSubstructure.hpp:52
CIPConfigurationLabeler.
Definition: CIPConfigurationLabeler.hpp:55
HashCodeCalculator.
Definition: HashCodeCalculator.hpp:57
MolecularGraph.
Definition: MolecularGraph.hpp:52
TautomerGenerator.
Definition: TautomerGenerator.hpp:59
std::shared_ptr< TautomerGenerator > SharedPointer
Definition: TautomerGenerator.hpp:70
bool resonanceDuplicatesRemoved() const
void setCallbackFunction(const CallbackFunction &func)
TautomerGenerator()
Constructs the TautomerGenerator instance.
std::size_t getNumTautomerizationRules() const
virtual ~TautomerGenerator()
Definition: TautomerGenerator.hpp:82
bool stereochemistryRegarded() const
void clearCoordinates3D(bool clear)
void regardStereochemistry(bool regard)
TautomerGenerator(const TautomerGenerator &gen)
std::function< bool(MolecularGraph &)> CallbackFunction
Definition: TautomerGenerator.hpp:72
const TautomerizationRule::SharedPointer & getTautomerizationRule(std::size_t idx) const
void generate(const MolecularGraph &molgraph)
Generates all unique tautomers of the molecular graph molgraph.
void removeResonanceDuplicates(bool remove)
void removeTautomerizationRule(std::size_t idx)
Mode
Definition: TautomerGenerator.hpp:63
@ TOPOLOGICALLY_UNIQUE
Definition: TautomerGenerator.hpp:65
@ GEOMETRICALLY_UNIQUE
Definition: TautomerGenerator.hpp:66
void addTautomerizationRule(const TautomerizationRule::SharedPointer &rule)
void clearCoordinates2D(bool clear)
void setCustomSetupFunction(const CustomSetupFunction &func)
void regardIsotopes(bool regard)
const CallbackFunction & getCallbackFunction() const
std::function< void(MolecularGraph &)> CustomSetupFunction
Definition: TautomerGenerator.hpp:73
TautomerGenerator & operator=(const TautomerGenerator &gen)
std::shared_ptr< TautomerizationRule > SharedPointer
Definition: TautomerizationRule.hpp:53
std::shared_ptr< ObjectType > SharedObjectPointer
Definition: ObjectPool.hpp:65
CDPL_CHEM_API void setAromaticityFlags(MolecularGraph &molgraph, bool overwrite)
The namespace of the Chemical Data Processing Library.