Chemical Data Processing Library C++ API - Version 1.2.0
PatternBasedTautomerizationRule.hpp
Go to the documentation of this file.
1 /*
2  * PatternBasedTautomerizationRule.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_PATTERNBASEDTAUTOMERIZATIONRULE_HPP
30 #define CDPL_CHEM_PATTERNBASEDTAUTOMERIZATIONRULE_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 #include <algorithm>
35 #include <iterator>
36 #include <memory>
37 #include <functional>
38 
39 #include "CDPL/Chem/APIPrefix.hpp"
43 #include "CDPL/Util/BitSet.hpp"
45 
46 
47 namespace CDPL
48 {
49 
50  namespace Chem
51  {
52 
57  {
58 
59  public:
60  typedef std::shared_ptr<PatternBasedTautomerizationRule> SharedPointer;
61 
63  {
64 
65  std::size_t atom1ID;
66  std::size_t atom2ID;
68  };
69 
70  PatternBasedTautomerizationRule(unsigned int rule_id);
71 
73 
75 
76  template <typename Iter>
77  void addTransformationPattern(const MolecularGraph::SharedPointer& pattern, Iter bond_chgs_beg, Iter bond_chgs_end)
78  {
79  structPatterns.push_back(pattern);
80  patternSubSearchList.push_back(SubstructureSearch::SharedPointer(new SubstructureSearch(*pattern)));
81  patternBondChangeLists.resize(patternBondChangeLists.size() + 1);
82 
83  std::copy(bond_chgs_beg, bond_chgs_end, std::back_inserter(patternBondChangeLists.back()));
84  }
85 
87 
89 
91 
92  bool setup(MolecularGraph& parent_molgraph);
93 
94  unsigned int getID() const;
95 
96  bool generate(Molecule& tautomer);
97 
99 
100  private:
101  bool applyTransformation(Molecule& tautomer);
102 
103  Atom* getTautomerAtom(Molecule& tautomer, std::size_t ptn_atom_id, const AtomMapping& mapping) const;
104 
105  void freeBitSet(Util::BitSet* bset);
106 
107  void createMatchedBondMask(const BondMapping& mapping, Util::BitSet& bond_mask) const;
108 
109  typedef std::vector<BondOrderChange> BondOrderChangeList;
110  typedef std::vector<BondOrderChangeList> BondOrderChangeListArray;
111  typedef std::vector<MolecularGraph::SharedPointer> StructPatternList;
112  typedef std::vector<SubstructureSearch::SharedPointer> SubstructureSearchList;
113  typedef std::vector<Util::BitSet*> BitSetList;
115 
116  unsigned int ruleID;
117  StructPatternList structPatterns;
118  StructPatternList excludePatterns;
119  BondOrderChangeListArray patternBondChangeLists;
120  SubstructureSearchList patternSubSearchList;
121  SubstructureSearchList excludeSubSearchList;
122  const MolecularGraph* parentMolGraph;
123  std::size_t currPatternIdx;
124  std::size_t currMappingIdx;
125  Util::BitSet bondMask;
126  BitSetList excludeMatches;
127  BitSetCache bitSetCache;
128  };
129  } // namespace Chem
130 } // namespace CDPL
131 
132 #endif // CDPL_CHEM_PATTERNBASEDTAUTOMERIZATIONRULE_HPP
Definition of the type CDPL::Util::BitSet.
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::MolecularGraph.
Definition of the class CDPL::Util::ObjectStack.
Definition of the class CDPL::Chem::SubstructureSearch.
Definition of the class CDPL::Chem::TautomerizationRule.
A data type for the storage and lookup of arbitrary atom to atom mappings.
Definition: AtomMapping.hpp:54
Atom.
Definition: Atom.hpp:52
A data type for the storage and lookup of arbitrary bond to bond mappings.
Definition: BondMapping.hpp:54
MolecularGraph.
Definition: MolecularGraph.hpp:52
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
Molecule.
Definition: Molecule.hpp:49
PatternBasedTautomerizationRule.
Definition: PatternBasedTautomerizationRule.hpp:57
PatternBasedTautomerizationRule(unsigned int rule_id)
void addExcludePattern(const MolecularGraph::SharedPointer &pattern)
void addExcludePatterns(const PatternBasedTautomerizationRule &rule)
PatternBasedTautomerizationRule(const PatternBasedTautomerizationRule &rule)
void addTransformationPattern(const MolecularGraph::SharedPointer &pattern, Iter bond_chgs_beg, Iter bond_chgs_end)
Definition: PatternBasedTautomerizationRule.hpp:77
bool setup(MolecularGraph &parent_molgraph)
std::shared_ptr< PatternBasedTautomerizationRule > SharedPointer
Definition: PatternBasedTautomerizationRule.hpp:60
TautomerizationRule::SharedPointer clone() const
PatternBasedTautomerizationRule & operator=(const PatternBasedTautomerizationRule &rule)
bool generate(Molecule &tautomer)
Generates the next tautomer.
SubstructureSearch.
Definition: SubstructureSearch.hpp:64
std::shared_ptr< SubstructureSearch > SharedPointer
Definition: SubstructureSearch.hpp:73
TautomerizationRule.
Definition: TautomerizationRule.hpp:50
std::shared_ptr< TautomerizationRule > SharedPointer
Definition: TautomerizationRule.hpp:53
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.
Definition: PatternBasedTautomerizationRule.hpp:63
std::size_t atom1ID
Definition: PatternBasedTautomerizationRule.hpp:65
std::size_t atom2ID
Definition: PatternBasedTautomerizationRule.hpp:66
long orderChange
Definition: PatternBasedTautomerizationRule.hpp:67