Chemical Data Processing Library C++ API - Version 1.2.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 
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 
89 
91 
107  void setAtomPropertyFlags(unsigned int flags);
108 
115  unsigned int getAtomPropertyFlags() const;
116 
129  void setBondPropertyFlags(unsigned int flags);
130 
137  unsigned int getBondPropertyFlags() const;
138 
145  void includeImplicitHydrogens(bool include);
146 
153 
161  void calculate(const MolecularGraph& molgraph, Util::STArray& class_ids);
162 
163  private:
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
Definition of the 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 the class CDPL::Util::ObjectStack.
MolecularGraph.
Definition: MolecularGraph.hpp:52
SymmetryClassCalculator.
Definition: SymmetryClassCalculator.hpp:55
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
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
The namespace of the Chemical Data Processing Library.
Definition: SymmetryClassCalculator.hpp:203
bool operator()(const AtomNode *, const AtomNode *) const
Definition: SymmetryClassCalculator.hpp:197
bool operator()(const AtomNode *, const AtomNode *) const