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 
96 
98 
100 
116  void setAtomPropertyFlags(unsigned int flags);
117 
124  unsigned int getAtomPropertyFlags() const;
125 
138  void setBondPropertyFlags(unsigned int flags);
139 
146  unsigned int getBondPropertyFlags() const;
147 
154  void includeImplicitHydrogens(bool include);
155 
162 
172  void calculate(const MolecularGraph& molgraph, Util::STArray& class_ids);
173 
174  private:
175  void init(const MolecularGraph&, Util::STArray&);
176 
177  void calcSVMNumbers();
178  void perceiveSymClasses(const MolecularGraph&, Util::STArray&);
179 
180  class AtomNode;
181 
182  AtomNode* allocNode(std::uint64_t class_id);
183 
184  typedef std::vector<AtomNode*> NodeList;
185 
186  class AtomNode
187  {
188 
189  public:
190  void clear();
191 
192  void addNbrNode(AtomNode*);
193 
194  void setSVMNumber(std::uint64_t);
195 
196  void calcNextSVMNumber();
197  void updateSVMNumber();
198  void updateSVMHistory();
199 
200  void setNextSymClassID(std::uint64_t);
201 
202  void update();
203 
204  std::size_t getSymClassID() const;
205  void setSymClassID(std::uint64_t class_id);
206 
208  {
209 
210  bool operator()(const AtomNode*, const AtomNode*) const;
211  };
212 
214  {
215 
216  bool operator()(const AtomNode*, const AtomNode*) const;
217  };
218 
219  private:
220  typedef std::vector<std::uint64_t> SVMNumberList;
221 
222  std::uint64_t symClassID;
223  std::uint64_t nextSymClassID;
224  std::uint64_t nbrSymClassIDProd;
225  std::uint64_t svmNumber;
226  std::uint64_t nextSVMNumber;
227  SVMNumberList svmNumberHistory;
228  NodeList nbrNodes;
229  };
230 
232 
233  NodeCache nodeCache;
234  unsigned int atomPropertyFlags;
235  unsigned int bondPropertyFlags;
236  bool hComplete;
237  NodeList hAtomNodes;
238  NodeList atomNodes;
239  NodeList sortedAtomNodes;
240  };
241  } // namespace Chem
242 } // namespace CDPL
243 
244 #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 data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
Perceives the 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:578
The namespace of the Chemical Data Processing Library.
Definition: SymmetryClassCalculator.hpp:214
bool operator()(const AtomNode *, const AtomNode *) const
Definition: SymmetryClassCalculator.hpp:208
bool operator()(const AtomNode *, const AtomNode *) const