Chemical Data Processing Library C++ API - Version 1.1.1
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
CDPL::Chem::MolecularGraph::SharedPointer
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
CDPL::Chem::TautomerizationRule::SharedPointer
std::shared_ptr< TautomerizationRule > SharedPointer
Definition: TautomerizationRule.hpp:53
ObjectStack.hpp
Definition of the class CDPL::Util::ObjectStack.
TautomerizationRule.hpp
Definition of the class CDPL::Chem::TautomerizationRule.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::PatternBasedTautomerizationRule::addExcludePatterns
void addExcludePatterns(const PatternBasedTautomerizationRule &rule)
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::PatternBasedTautomerizationRule::clone
TautomerizationRule::SharedPointer clone() const
CDPL::Chem::SubstructureSearch
SubstructureSearch.
Definition: SubstructureSearch.hpp:64
CDPL::Chem::PatternBasedTautomerizationRule::BondOrderChange::atom1ID
std::size_t atom1ID
Definition: PatternBasedTautomerizationRule.hpp:65
CDPL::Chem::PatternBasedTautomerizationRule::PatternBasedTautomerizationRule
PatternBasedTautomerizationRule(const PatternBasedTautomerizationRule &rule)
CDPL::Chem::PatternBasedTautomerizationRule::PatternBasedTautomerizationRule
PatternBasedTautomerizationRule(unsigned int rule_id)
CDPL::Chem::PatternBasedTautomerizationRule::clearExcludePatterns
void clearExcludePatterns()
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
CDPL::Chem::PatternBasedTautomerizationRule::BondOrderChange::orderChange
long orderChange
Definition: PatternBasedTautomerizationRule.hpp:67
CDPL::Chem::PatternBasedTautomerizationRule::setup
bool setup(MolecularGraph &parent_molgraph)
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::PatternBasedTautomerizationRule::BondOrderChange::atom2ID
std::size_t atom2ID
Definition: PatternBasedTautomerizationRule.hpp:66
CDPL::Chem::PatternBasedTautomerizationRule::SharedPointer
std::shared_ptr< PatternBasedTautomerizationRule > SharedPointer
Definition: PatternBasedTautomerizationRule.hpp:60
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
CDPL::Chem::Molecule
Molecule.
Definition: Molecule.hpp:49
CDPL::Chem::AtomMapping
A data type for the storage and lookup of arbitrary atom to atom mappings.
Definition: AtomMapping.hpp:54
CDPL::Chem::PatternBasedTautomerizationRule
PatternBasedTautomerizationRule.
Definition: PatternBasedTautomerizationRule.hpp:57
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
CDPL::Chem::BondMapping
A data type for the storage and lookup of arbitrary bond to bond mappings.
Definition: BondMapping.hpp:54
CDPL::Chem::PatternBasedTautomerizationRule::generate
bool generate(Molecule &tautomer)
Generates the next tautomer.
CDPL::Chem::PatternBasedTautomerizationRule::operator=
PatternBasedTautomerizationRule & operator=(const PatternBasedTautomerizationRule &rule)
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::PatternBasedTautomerizationRule::BondOrderChange
Definition: PatternBasedTautomerizationRule.hpp:63
SubstructureSearch.hpp
Definition of the class CDPL::Chem::SubstructureSearch.
CDPL::Util::ObjectStack< Util::BitSet >
CDPL::Chem::SubstructureSearch::SharedPointer
std::shared_ptr< SubstructureSearch > SharedPointer
Definition: SubstructureSearch.hpp:73
CDPL::Chem::TautomerizationRule
TautomerizationRule.
Definition: TautomerizationRule.hpp:50
CDPL::Chem::PatternBasedTautomerizationRule::addTransformationPattern
void addTransformationPattern(const MolecularGraph::SharedPointer &pattern, Iter bond_chgs_beg, Iter bond_chgs_end)
Definition: PatternBasedTautomerizationRule.hpp:77
CDPL::Chem::PatternBasedTautomerizationRule::getID
unsigned int getID() const
CDPL::Chem::PatternBasedTautomerizationRule::addExcludePattern
void addExcludePattern(const MolecularGraph::SharedPointer &pattern)