Chemical Data Processing Library C++ API - Version 1.1.1
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 removeResonanceDuplicates(bool remove);
114 
119 
121 
126  void generate(const MolecularGraph& molgraph);
127 
128  private:
130  typedef MoleculeCache::SharedObjectPointer MoleculePtr;
131 
132  bool init(const MolecularGraph& molgraph);
133  void initHashCalculator();
134 
135  MoleculePtr copyInputMolGraph(const MolecularGraph& molgraph);
136 
137  void extractStereoCenters(const MolecularGraph& molgraph);
138  void extractAtomStereoCenters(const MolecularGraph& molgraph);
139  void extractBondStereoCenters(const MolecularGraph& molgraph);
140 
141  bool addNewTautomer(const MoleculePtr& mol_ptr);
142  bool outputTautomer(const MoleculePtr& mol_ptr);
143 
144  std::uint64_t calcConTabHashCode(const MolecularGraph& molgraph, bool arom_bonds);
145 
146  void generateSSSR(MolecularGraph& molgraph);
147  void setAromaticityFlags(MolecularGraph& molgraph);
148  void calcCIPConfigurations(MolecularGraph& molgraph);
149 
150  typedef std::array<std::size_t, 3> BondDescriptor;
151  typedef std::vector<MoleculePtr> MoleculeList;
152  typedef std::vector<TautomerizationRule::SharedPointer> TautRuleList;
153  typedef std::vector<BondDescriptor> BondDescrArray;
154  typedef std::vector<std::size_t> SizeTArray;
155  typedef std::unordered_set<std::uint64_t> HashCodeSet;
156  typedef std::array<std::size_t, 6> StereoCenter;
157  typedef std::vector<StereoCenter> StereoCenterList;
158 
159  MoleculeCache molCache;
160  CallbackFunction callbackFunc;
161  Mode mode;
162  bool regStereo;
163  bool regIsotopes;
164  bool remResDuplicates;
165  CustomSetupFunction customSetupFunc;
166  TautRuleList tautRules;
167  MoleculeList currGeneration;
168  MoleculeList nextGeneration;
169  StereoCenterList atomStereoCenters;
170  StereoCenterList bondStereoCenters;
171  HashCodeSet intermTautHashCodes;
172  HashCodeSet outputTautHashCodes;
173  HashCodeCalculator hashCalculator;
174  AromaticSubstructure aromSubstruct;
175  CIPConfigurationLabeler cipLabeler;
176  BondDescrArray tautomerBonds;
177  SizeTArray shaInput;
178  const MolecularGraph* molGraph;
179  };
180  } // namespace Chem
181 } // namespace CDPL
182 
183 #endif // CDPL_CHEM_TAUTOMERGENERATOR_HPP
CDPL::Chem::TautomerGenerator::removeResonanceDuplicates
void removeResonanceDuplicates(bool remove)
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::resonanceDuplicatesRemoved
bool resonanceDuplicatesRemoved() const
CDPL::Chem::TautomerGenerator
TautomerGenerator.
Definition: TautomerGenerator.hpp:59
CDPL::Chem::TautomerGenerator::Mode
Mode
Definition: TautomerGenerator.hpp:63
CDPL::Chem::TautomerGenerator::isotopesRegarded
bool isotopesRegarded() const
HashCodeCalculator.hpp
Definition of the class CDPL::Chem::HashCodeCalculator.
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:72
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:65
CDPL::Util::ObjectPool< BasicMolecule >
CDPL::Chem::TautomerGenerator::SharedPointer
std::shared_ptr< TautomerGenerator > SharedPointer
Definition: TautomerGenerator.hpp:70
CDPL::Chem::TautomerGenerator::getTautomerizationRule
const TautomerizationRule::SharedPointer & getTautomerizationRule(std::size_t idx) const
CDPL::Chem::TautomerGenerator::GEOMETRICALLY_UNIQUE
@ GEOMETRICALLY_UNIQUE
Definition: TautomerGenerator.hpp:66
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::TautomerGenerator::CustomSetupFunction
std::function< void(MolecularGraph &)> CustomSetupFunction
Definition: TautomerGenerator.hpp:73
CDPL::Chem::CIPConfigurationLabeler
CIPConfigurationLabeler.
Definition: CIPConfigurationLabeler.hpp:55
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.
CIPConfigurationLabeler.hpp
Definition of the class CDPL::Chem::CIPConfigurationLabeler.
AromaticSubstructure.hpp
Definition of the class CDPL::Chem::AromaticSubstructure.
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::setAromaticityFlags
CDPL_CHEM_API void setAromaticityFlags(MolecularGraph &molgraph, bool overwrite)
CDPL::Chem::AromaticSubstructure
Implements the perception of aromatic atoms and bonds in a molecular graph.
Definition: AromaticSubstructure.hpp:52
CDPL::Chem::TautomerGenerator::~TautomerGenerator
virtual ~TautomerGenerator()
Definition: TautomerGenerator.hpp:82
BasicMolecule.hpp
Definition of the class CDPL::Chem::BasicMolecule.
CDPL::Chem::TautomerGenerator::regardIsotopes
void regardIsotopes(bool regard)