Chemical Data Processing Library C++ API - Version 1.4.0
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 
62  {
63 
64  public:
69  static constexpr unsigned int DEF_ATOM_PROPERTY_FLAGS =
72 
77  static constexpr unsigned int DEF_BOND_PROPERTY_FLAGS =
79 
84 
94 
96 
98 
114  void setAtomPropertyFlags(unsigned int flags);
115 
122  unsigned int getAtomPropertyFlags() const;
123 
136  void setBondPropertyFlags(unsigned int flags);
137 
144  unsigned int getBondPropertyFlags() const;
145 
152  void includeImplicitHydrogens(bool include);
153 
160 
168  void calculate(const MolecularGraph& molgraph, Util::STArray& class_ids);
169 
170  private:
171  void init(const MolecularGraph&, Util::STArray&);
172 
173  void calcSVMNumbers();
174  void perceiveSymClasses(const MolecularGraph&, Util::STArray&);
175 
176  class AtomNode;
177 
178  AtomNode* allocNode(std::uint64_t class_id);
179 
180  typedef std::vector<AtomNode*> NodeList;
181 
182  class AtomNode
183  {
184 
185  public:
186  void clear();
187 
188  void addNbrNode(AtomNode*);
189 
190  void setSVMNumber(std::uint64_t);
191 
192  void calcNextSVMNumber();
193  void updateSVMNumber();
194  void updateSVMHistory();
195 
196  void setNextSymClassID(std::uint64_t);
197 
198  void update();
199 
200  std::size_t getSymClassID() const;
201  void setSymClassID(std::uint64_t class_id);
202 
204  {
205 
206  bool operator()(const AtomNode*, const AtomNode*) const;
207  };
208 
210  {
211 
212  bool operator()(const AtomNode*, const AtomNode*) const;
213  };
214 
215  private:
216  typedef std::vector<std::uint64_t> SVMNumberList;
217 
218  std::uint64_t symClassID;
219  std::uint64_t nextSymClassID;
220  std::uint64_t nbrSymClassIDProd;
221  std::uint64_t svmNumber;
222  std::uint64_t nextSVMNumber;
223  SVMNumberList svmNumberHistory;
224  NodeList nbrNodes;
225  };
226 
228 
229  NodeCache nodeCache;
230  unsigned int atomPropertyFlags;
231  unsigned int bondPropertyFlags;
232  bool hComplete;
233  NodeList hAtomNodes;
234  NodeList atomNodes;
235  NodeList sortedAtomNodes;
236  };
237  } // namespace Chem
238 } // namespace CDPL
239 
240 #endif // CDPL_CHEM_SYMMETRYCLASSCALCULATOR_HPP
Definition of class CDPL::Util::Array.
Definition of constants in namespace CDPL::Chem::BondPropertyFlag.
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 constants in namespace CDPL::Chem::AtomPropertyFlag.
Definition of class CDPL::Util::ObjectStack.
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Perceives topological-symmetry classes of the atoms in a molecular graph.
Definition: SymmetryClassCalculator.hpp:62
bool implicitHydrogensIncluded() const
Tells whether implicit hydrogen atoms are ignored or treated in the same way as explicit ones.
void setBondPropertyFlags(unsigned int flags)
Allows to specify the set of bond properties that has to be considered in the perception of topologic...
void calculate(const MolecularGraph &molgraph, Util::STArray &class_ids)
Perceives the topological symmetry classes of the atoms in the molecular graph molgraph.
SymmetryClassCalculator()
Constructs the SymmetryClassCalculator instance.
void setAtomPropertyFlags(unsigned int flags)
Allows to specify the set of atomic properties that has to be considered in the perception of topolog...
SymmetryClassCalculator(const MolecularGraph &molgraph, Util::STArray &class_ids)
Constructs the SymmetryClassCalculator instance and perceives the topological symmetry classes of the...
SymmetryClassCalculator & operator=(const SymmetryClassCalculator &)=delete
SymmetryClassCalculator(const SymmetryClassCalculator &)=delete
unsigned int getAtomPropertyFlags() const
Returns the set of atomic properties that gets considered in the perception of topological symmetry c...
unsigned int getBondPropertyFlags() const
Returns the set of bond properties that gets considered in the perception of topological symmetry cla...
void includeImplicitHydrogens(bool include)
Allows to specify whether implicit hydrogen atoms shall be ignored or treated in the same way as expl...
constexpr unsigned int FORMAL_CHARGE
Specifies the formal charge of an atom.
Definition: Chem/AtomPropertyFlag.hpp:73
constexpr unsigned int H_COUNT
Specifies the hydrogen count of an atom.
Definition: Chem/AtomPropertyFlag.hpp:78
constexpr unsigned int AROMATICITY
Specifies the membership of an atom in aromatic rings.
Definition: Chem/AtomPropertyFlag.hpp:93
constexpr unsigned int ISOTOPE
Specifies the isotopic mass of an atom.
Definition: Chem/AtomPropertyFlag.hpp:68
constexpr unsigned int TYPE
Specifies the generic type or element of an atom.
Definition: Chem/AtomPropertyFlag.hpp:63
constexpr unsigned int AROMATICITY
Specifies the membership of a bond in aromatic rings.
Definition: BondPropertyFlag.hpp:73
constexpr unsigned int ORDER
Specifies the order of a bond.
Definition: BondPropertyFlag.hpp:63
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:575
The namespace of the Chemical Data Processing Library.
Definition: SymmetryClassCalculator.hpp:210
bool operator()(const AtomNode *, const AtomNode *) const
Definition: SymmetryClassCalculator.hpp:204
bool operator()(const AtomNode *, const AtomNode *) const