Chemical Data Processing Library C++ API - Version 1.1.1
PatternAtomTyper.hpp
Go to the documentation of this file.
1 /*
2  * PatternAtomTyper.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_PATTERNATOMTYPER_HPP
30 #define CDPL_CHEM_PATTERNATOMTYPER_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 #include <memory>
35 
36 #include "CDPL/Chem/APIPrefix.hpp"
39 #include "CDPL/Util/BitSet.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Chem
46  {
47 
52  {
53 
54  public:
55  class Pattern;
56 
57  private:
58  typedef std::vector<Pattern> PatternList;
59  typedef std::vector<std::size_t> SizeTypeArray;
60 
61  public:
62  typedef std::shared_ptr<PatternAtomTyper> SharedPointer;
63 
64  typedef PatternList::const_iterator ConstPatternIterator;
65  typedef PatternList::iterator PatternIterator;
66 
68  {
69 
70  friend class PatternAtomTyper;
71 
72  public:
73  Pattern(const MolecularGraph::SharedPointer& structure, std::size_t atom_label = 0, std::size_t priority = 0,
74  bool all_matches = true, bool unique_matches = false);
75 
77 
78  std::size_t getPriority() const;
79 
80  std::size_t getAtomLabel() const;
81 
82  bool processAllMatches() const;
83 
85 
86  private:
87  typedef std::pair<const Atom*, std::size_t> AtomLabelPair;
88  typedef std::vector<AtomLabelPair> LabeledAtomList;
89 
90  const LabeledAtomList& getLabeledAtoms() const;
91 
93  std::size_t priority;
94  std::size_t atomLabel;
95  bool allMatches;
96  bool uniqueMatches;
97  LabeledAtomList labeledAtoms;
98  };
99 
101 
103 
104  void addPattern(const MolecularGraph::SharedPointer& structure, std::size_t atom_label = 0, std::size_t priority = 0,
105  bool all_matches = true, bool unique_matches = false);
106 
107  void addPattern(const Pattern& ptn);
108 
109  const Pattern& getPattern(std::size_t idx) const;
110 
111  void removePattern(std::size_t idx);
112 
113  void removePattern(const PatternIterator& ptn_it);
114 
115  void clear();
116 
117  std::size_t getNumPatterns() const;
118 
121 
124 
127 
130 
131  bool hasAtomLabel(std::size_t idx) const;
132 
133  std::size_t getAtomLabel(std::size_t idx) const;
134 
135  std::size_t getPatternIndex(std::size_t idx) const;
136 
137  void execute(const MolecularGraph& molgraph);
138 
140 
141  private:
142  void init(const MolecularGraph& molgraph);
143 
144  void processPattern(const Pattern& ptn, std::size_t ptn_idx);
145  bool processMatch(const AtomMapping& mapping, const Pattern& ptn, std::size_t ptn_idx);
146 
147  const MolecularGraph* molGraph;
148  PatternList patterns;
149  SizeTypeArray atomLabeling;
150  SizeTypeArray matchingPatternIndices;
151  SubstructureSearch substructSearch;
152  Util::BitSet labeledAtomMask;
153  };
154  } // namespace Chem
155 } // namespace CDPL
156 
157 #endif // CDPL_CHEM_PATTERNATOMTYPER_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::PatternAtomTyper::end
ConstPatternIterator end() const
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::PatternAtomTyper::operator=
PatternAtomTyper & operator=(const PatternAtomTyper &typer)
CDPL::Chem::PatternAtomTyper::Pattern::getStructure
const MolecularGraph::SharedPointer & getStructure() 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::SubstructureSearch
SubstructureSearch.
Definition: SubstructureSearch.hpp:64
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
CDPL::Chem::PatternAtomTyper::removePattern
void removePattern(std::size_t idx)
CDPL::Chem::PatternAtomTyper::PatternAtomTyper
PatternAtomTyper()
CDPL::Chem::PatternAtomTyper::Pattern::processAllMatches
bool processAllMatches() const
CDPL::Chem::PatternAtomTyper::PatternIterator
PatternList::iterator PatternIterator
Definition: PatternAtomTyper.hpp:65
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
CDPL::Chem::PatternAtomTyper::getPatternsBegin
ConstPatternIterator getPatternsBegin() const
CDPL::Chem::PatternAtomTyper::getPatternIndex
std::size_t getPatternIndex(std::size_t idx) const
CDPL::Chem::PatternAtomTyper::Pattern::getAtomLabel
std::size_t getAtomLabel() const
CDPL::Chem::AtomMapping
A data type for the storage and lookup of arbitrary atom to atom mappings.
Definition: AtomMapping.hpp:54
CDPL::Chem::PatternAtomTyper::Pattern::getPriority
std::size_t getPriority() const
CDPL::Chem::PatternAtomTyper::ConstPatternIterator
PatternList::const_iterator ConstPatternIterator
Definition: PatternAtomTyper.hpp:64
CDPL::Chem::PatternAtomTyper::addPattern
void addPattern(const MolecularGraph::SharedPointer &structure, std::size_t atom_label=0, std::size_t priority=0, bool all_matches=true, bool unique_matches=false)
CDPL::Chem::PatternAtomTyper::getAtomLabel
std::size_t getAtomLabel(std::size_t idx) const
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
CDPL::Chem::PatternAtomTyper::execute
void execute(const MolecularGraph &molgraph)
CDPL::Chem::PatternAtomTyper
PatternAtomTyper.
Definition: PatternAtomTyper.hpp:52
CDPL::Chem::PatternAtomTyper::addPattern
void addPattern(const Pattern &ptn)
CDPL::Chem::PatternAtomTyper::Pattern::processUniqueMatchesOnly
bool processUniqueMatchesOnly() const
CDPL::Chem::PatternAtomTyper::hasAtomLabel
bool hasAtomLabel(std::size_t idx) const
CDPL::Chem::PatternAtomTyper::begin
PatternIterator begin()
CDPL::Chem::PatternAtomTyper::end
PatternIterator end()
CDPL::Chem::PatternAtomTyper::PatternAtomTyper
PatternAtomTyper(const PatternAtomTyper &typer)
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::PatternAtomTyper::Pattern
Definition: PatternAtomTyper.hpp:68
CDPL::Chem::PatternAtomTyper::getPatternsEnd
PatternIterator getPatternsEnd()
CDPL::Chem::PatternAtomTyper::SharedPointer
std::shared_ptr< PatternAtomTyper > SharedPointer
Definition: PatternAtomTyper.hpp:62
CDPL::Chem::PatternAtomTyper::begin
ConstPatternIterator begin() const
SubstructureSearch.hpp
Definition of the class CDPL::Chem::SubstructureSearch.
CDPL::Chem::PatternAtomTyper::clear
void clear()
CDPL::Chem::PatternAtomTyper::getPattern
const Pattern & getPattern(std::size_t idx) const
CDPL::Chem::PatternAtomTyper::removePattern
void removePattern(const PatternIterator &ptn_it)
CDPL::Chem::PatternAtomTyper::getNumPatterns
std::size_t getNumPatterns() const
CDPL::Chem::PatternAtomTyper::Pattern::Pattern
Pattern(const MolecularGraph::SharedPointer &structure, std::size_t atom_label=0, std::size_t priority=0, bool all_matches=true, bool unique_matches=false)
CDPL::Chem::PatternAtomTyper::getPatternsBegin
PatternIterator getPatternsBegin()
CDPL::Chem::PatternAtomTyper::getPatternsEnd
ConstPatternIterator getPatternsEnd() const