Chemical Data Processing Library C++ API - Version 1.1.1
SymmetryClassCalculator.hpp
Go to the documentation of this file.
1 /*
2  * SymmetryClassCalculator.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_SYMMETRYCLASSCALCULATOR_HPP
30 #define CDPL_CHEM_SYMMETRYCLASSCALCULATOR_HPP
31 
32 #include <vector>
33 #include <cstdint>
34 
35 #include "CDPL/Chem/APIPrefix.hpp"
38 #include "CDPL/Util/Array.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Chem
46  {
47 
48  class MolecularGraph;
49 
55  {
56 
57  public:
62  static constexpr unsigned int DEF_ATOM_PROPERTY_FLAGS =
65 
70  static constexpr unsigned int DEF_BOND_PROPERTY_FLAGS =
72 
77 
87 
103  void setAtomPropertyFlags(unsigned int flags);
104 
111  unsigned int getAtomPropertyFlags() const;
112 
125  void setBondPropertyFlags(unsigned int flags);
126 
133  unsigned int getBondPropertyFlags() const;
134 
141  void includeImplicitHydrogens(bool include);
142 
149 
157  void calculate(const MolecularGraph& molgraph, Util::STArray& class_ids);
158 
159  private:
161 
163 
164  void init(const MolecularGraph&, Util::STArray&);
165 
166  void calcSVMNumbers();
167  void perceiveSymClasses(const MolecularGraph&, Util::STArray&);
168 
169  class AtomNode;
170 
171  AtomNode* allocNode(std::uint64_t class_id);
172 
173  typedef std::vector<AtomNode*> NodeList;
174 
175  class AtomNode
176  {
177 
178  public:
179  void clear();
180 
181  void addNbrNode(AtomNode*);
182 
183  void setSVMNumber(std::uint64_t);
184 
185  void calcNextSVMNumber();
186  void updateSVMNumber();
187  void updateSVMHistory();
188 
189  void setNextSymClassID(std::uint64_t);
190 
191  void update();
192 
193  std::size_t getSymClassID() const;
194  void setSymClassID(std::uint64_t class_id);
195 
197  {
198 
199  bool operator()(const AtomNode*, const AtomNode*) const;
200  };
201 
203  {
204 
205  bool operator()(const AtomNode*, const AtomNode*) const;
206  };
207 
208  private:
209  typedef std::vector<std::uint64_t> SVMNumberList;
210 
211  std::uint64_t symClassID;
212  std::uint64_t nextSymClassID;
213  std::uint64_t nbrSymClassIDProd;
214  std::uint64_t svmNumber;
215  std::uint64_t nextSVMNumber;
216  SVMNumberList svmNumberHistory;
217  NodeList nbrNodes;
218  };
219 
221 
222  NodeCache nodeCache;
223  unsigned int atomPropertyFlags;
224  unsigned int bondPropertyFlags;
225  bool hComplete;
226  NodeList hAtomNodes;
227  NodeList atomNodes;
228  NodeList sortedAtomNodes;
229  };
230  } // namespace Chem
231 } // namespace CDPL
232 
233 #endif // CDPL_CHEM_SYMMETRYCLASSCALCULATOR_HPP
ObjectStack.hpp
Definition of the class CDPL::Util::ObjectStack.
CDPL::Chem::SymmetryClassCalculator::AtomNode::SymClassCmpFunc
Definition: SymmetryClassCalculator.hpp:197
CDPL::Chem::AtomPropertyFlag::FORMAL_CHARGE
const unsigned int FORMAL_CHARGE
Specifies the formal charge of an atom.
Definition: Chem/AtomPropertyFlag.hpp:73
CDPL::Chem::BondPropertyFlag::AROMATICITY
const unsigned int AROMATICITY
Specifies the membership of a bond in aromatic rings.
Definition: BondPropertyFlag.hpp:73
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::SymmetryClassCalculator::calculate
void calculate(const MolecularGraph &molgraph, Util::STArray &class_ids)
Perceives the topological symmetry classes of the atoms in the molecular graph molgraph.
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::SymmetryClassCalculator::AtomNode::SVMNumberCmpFunc
Definition: SymmetryClassCalculator.hpp:203
CDPL::Chem::SymmetryClassCalculator::includeImplicitHydrogens
void includeImplicitHydrogens(bool include)
Allows to specify whether implicit hydrogen atoms shall be ignored or treated in the same way as expl...
CDPL::Chem::SymmetryClassCalculator::SymmetryClassCalculator
SymmetryClassCalculator()
Constructs the SymmetryClassCalculator instance.
CDPL::Chem::SymmetryClassCalculator::getAtomPropertyFlags
unsigned int getAtomPropertyFlags() const
Returns the set of atomic properties that gets considered in the perception of topological symmetry c...
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
Array.hpp
Definition of the class CDPL::Util::Array.
AtomPropertyFlag.hpp
Definition of constants in namespace CDPL::Chem::AtomPropertyFlag.
CDPL::Chem::SymmetryClassCalculator::AtomNode::SVMNumberCmpFunc::operator()
bool operator()(const AtomNode *, const AtomNode *) const
CDPL::Chem::SymmetryClassCalculator::getBondPropertyFlags
unsigned int getBondPropertyFlags() const
Returns the set of bond properties that gets considered in the perception of topological symmetry cla...
CDPL::Chem::BondPropertyFlag::ORDER
const unsigned int ORDER
Specifies the order of a bond.
Definition: BondPropertyFlag.hpp:63
CDPL::Chem::SymmetryClassCalculator::AtomNode::SymClassCmpFunc::operator()
bool operator()(const AtomNode *, const AtomNode *) const
CDPL::Chem::AtomPropertyFlag::TYPE
const unsigned int TYPE
Specifies the generic type or element of an atom.
Definition: Chem/AtomPropertyFlag.hpp:63
CDPL::Chem::AtomPropertyFlag::ISOTOPE
const unsigned int ISOTOPE
Specifies the isotopic mass of an atom.
Definition: Chem/AtomPropertyFlag.hpp:68
CDPL::Chem::SymmetryClassCalculator::setAtomPropertyFlags
void setAtomPropertyFlags(unsigned int flags)
Allows to specify the set of atomic properties that has to be considered in the perception of topolog...
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Util::STArray
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
CDPL::Chem::SymmetryClassCalculator::implicitHydrogensIncluded
bool implicitHydrogensIncluded() const
Tells whether implicit hydrogen atoms are ignored or treated in the same way as explicit ones.
CDPL::Chem::SymmetryClassCalculator::SymmetryClassCalculator
SymmetryClassCalculator(const MolecularGraph &molgraph, Util::STArray &class_ids)
Constructs the SymmetryClassCalculator instance and perceives the topological symmetry classes of the...
CDPL::Chem::AtomPropertyFlag::AROMATICITY
const unsigned int AROMATICITY
Specifies the membership of an atom in aromatic rings.
Definition: Chem/AtomPropertyFlag.hpp:93
CDPL::Chem::SymmetryClassCalculator::setBondPropertyFlags
void setBondPropertyFlags(unsigned int flags)
Allows to specify the set of bond properties that has to be considered in the perception of topologic...
CDPL::Chem::AtomPropertyFlag::H_COUNT
const unsigned int H_COUNT
Specifies the hydrogen count of an atom.
Definition: Chem/AtomPropertyFlag.hpp:78
BondPropertyFlag.hpp
Definition of constants in namespace CDPL::Chem::BondPropertyFlag.
CDPL::Util::ObjectStack< AtomNode >
CDPL::Chem::SymmetryClassCalculator
SymmetryClassCalculator.
Definition: SymmetryClassCalculator.hpp:55