Chemical Data Processing Library C++ API - Version 1.4.0
CIPPriorityCalculator.hpp
Go to the documentation of this file.
1 /*
2  * CIPPriorityCalculator.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_CIPPRIORITYCALCULATOR_HPP
30 #define CDPL_CHEM_CIPPRIORITYCALCULATOR_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 
35 #include "CDPL/Chem/APIPrefix.hpp"
36 #include "CDPL/Util/Array.hpp"
38 
39 
40 namespace CDPL
41 {
42 
43  namespace Chem
44  {
45 
46  class MolecularGraph;
47  class Atom;
48 
59  {
60 
61  public:
66 
75  CIPPriorityCalculator(const MolecularGraph& molgraph, Util::STArray& priorities);
76 
78 
80 
88  void calculate(const MolecularGraph& molgraph, Util::STArray& priorities);
89 
90  private:
91  class AtomNode;
92 
93  void init(const MolecularGraph&, Util::STArray&);
94  void determinePriorities(Util::STArray&);
95 
96  AtomNode* allocNode(std::size_t p);
97 
98  typedef std::vector<AtomNode*> NodeList;
99 
100  class AtomNode
101  {
102 
103  public:
104  void clear();
105 
106  void addNbrNode(AtomNode*);
107 
108  void setNewPriority(std::size_t);
109 
110  void updateNbrList();
111  void updatePriority();
112 
113  void setPriority(std::size_t p);
114 
115  std::size_t getPriority() const;
116 
117  struct LessCmpFunc
118  {
119 
120  bool operator()(const AtomNode*, const AtomNode*) const;
121  };
122 
124  {
125 
126  bool operator()(const AtomNode*, const AtomNode*) const;
127  };
128 
130  {
131 
132  bool operator()(const AtomNode*, const AtomNode*) const;
133  };
134 
135  private:
136  std::size_t priority;
137  std::size_t newPriority;
138  NodeList nbrNodes;
139  };
140 
142 
143  NodeCache nodeCache;
144  NodeList expAtomNodes;
145  NodeList atomNodes;
146  };
147  } // namespace Chem
148 } // namespace CDPL
149 
150 #endif // CDPL_CHEM_CIPPRIORITYCALCULATOR_HPP
Definition of class CDPL::Util::Array.
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 class CDPL::Util::ObjectStack.
Computes a topological approximation of CIP (Cahn-Ingold-Prelog) priorities for the atoms of a molecu...
Definition: CIPPriorityCalculator.hpp:59
CIPPriorityCalculator & operator=(const CIPPriorityCalculator &)=delete
CIPPriorityCalculator(const CIPPriorityCalculator &)=delete
CIPPriorityCalculator()
Constructs the CIPPriorityCalculator instance.
CIPPriorityCalculator(const MolecularGraph &molgraph, Util::STArray &priorities)
Constructs the CIPPriorityCalculator instance and calculates the topological CIP priorities of the at...
void calculate(const MolecularGraph &molgraph, Util::STArray &priorities)
Calculates the topological CIP priorities of the atoms in the molecular graph molgraph.
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
constexpr unsigned int p
Specifies that the stereocenter has p configuration.
Definition: CIPDescriptor.hpp:121
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: CIPPriorityCalculator.hpp:118
bool operator()(const AtomNode *, const AtomNode *) const
bool operator()(const AtomNode *, const AtomNode *) const
bool operator()(const AtomNode *, const AtomNode *) const