Chemical Data Processing Library C++ API - Version 1.2.0
AromaticSubstructure.hpp
Go to the documentation of this file.
1 /*
2  * AromaticSubstructure.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_AROMATICSUBSTRUCTURE_HPP
30 #define CDPL_CHEM_AROMATICSUBSTRUCTURE_HPP
31 
32 #include <vector>
33 #include <set>
34 #include <utility>
35 #include <memory>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
38 #include "CDPL/Chem/Fragment.hpp"
39 #include "CDPL/Util/BitSet.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Chem
46  {
47 
52  {
53 
54  public:
58  typedef std::shared_ptr<AromaticSubstructure> SharedPointer;
59 
64 
71 
73 
75 
81  void perceive(const MolecularGraph& molgraph);
82 
83  private:
84  class RingDescriptor
85  {
86 
87  public:
88  typedef std::shared_ptr<RingDescriptor> SharedPointer;
89 
90  RingDescriptor(const Fragment::SharedPointer&, const MolecularGraph&);
91  RingDescriptor(const Fragment::SharedPointer&, Util::BitSet&, const RingDescriptor&, const RingDescriptor&);
92 
93  const Fragment& getRing() const;
94 
95  const Util::BitSet& getBondMask() const;
96 
97  bool containsSubRing(const RingDescriptor&) const;
98 
99  private:
100  Fragment::SharedPointer ringPtr;
101  const RingDescriptor* subRing1;
102  const RingDescriptor* subRing2;
103  Util::BitSet bondMask;
104  };
105 
106  void freeMemory();
107 
108  typedef std::vector<RingDescriptor::SharedPointer> RingDescriptorList;
109  typedef std::vector<std::pair<RingDescriptorList, std::size_t> > RingDescriptorListTable;
110  typedef std::set<Util::BitSet> BondMaskSet;
111 
112  void init(const MolecularGraph&);
113 
114  void findAromaticSubstructure();
115  bool findAromaticRings(RingDescriptorListTable::value_type&);
116 
117  void fuseRings();
118  void fuseRings(const RingDescriptor&, const RingDescriptor&, RingDescriptorList&);
119 
120  bool isAromatic(const RingDescriptor::SharedPointer&);
121 
122  Util::BitSet aromBondMask;
123  Util::BitSet ringBondMask;
124  Util::BitSet tmpBondMask;
125  const MolecularGraph* molGraph;
126  RingDescriptorListTable ringDescrListTable;
127  BondMaskSet uniqueRingSet;
128  bool finished;
129  };
130  } // namespace Chem
131 } // namespace CDPL
132 
133 #endif // CDPL_CHEM_AROMATICSUBSTRUCTURE_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::Fragment.
Implements the perception of aromatic atoms and bonds in a molecular graph.
Definition: AromaticSubstructure.hpp:52
void perceive(const MolecularGraph &molgraph)
Replaces the currently stored atoms and bonds by the set of aromatic atoms and bonds of the molecular...
AromaticSubstructure()
Constructs an empty AromaticSubstructure instance.
Definition: AromaticSubstructure.hpp:63
AromaticSubstructure(const MolecularGraph &molgraph)
Construct a AromaticSubstructure instance that consists of the aromatic atoms and bonds of the molecu...
std::shared_ptr< AromaticSubstructure > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated AromaticSubstructure instances.
Definition: AromaticSubstructure.hpp:58
AromaticSubstructure & operator=(const AromaticSubstructure &)=delete
AromaticSubstructure(const AromaticSubstructure &)=delete
Fragment.
Definition: Fragment.hpp:52
std::shared_ptr< Fragment > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Fragment instances.
Definition: Fragment.hpp:61
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL_CHEM_API bool isAromatic(const Fragment &ring, const MolecularGraph &molgraph, const Util::BitSet &arom_bond_mask)
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.