Chemical Data Processing Library C++ API - Version 1.4.0
MorganNumberingCalculator.hpp
Go to the documentation of this file.
1 /*
2  * MorganNumberingCalculator.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_MORGANNUMBERINGCALCULATOR_HPP
30 #define CDPL_CHEM_MORGANNUMBERINGCALCULATOR_HPP
31 
32 #include <vector>
33 #include <string>
34 #include <utility>
35 #include <cstddef>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
38 #include "CDPL/Math/Matrix.hpp"
39 #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 
74 
76 
78 
88  void calculate(const MolecularGraph& molgraph, Util::STArray& numbering);
89 
90  private:
91  typedef std::pair<std::size_t, std::size_t> STPair;
92 
93  typedef std::vector<STPair> STPairArray;
94  typedef std::vector<std::size_t> STArray;
95  typedef std::vector<long> LArray;
96  typedef std::vector<std::string> SArray;
97 
98  class NumberingState
99  {
100 
101  public:
102  NumberingState(STPairArray* sym_class_ids, SArray* symbols,
103  LArray* charges, STArray* isotopes, Math::SparseULMatrix* bond_mtx):
104  symClassIDs(sym_class_ids),
105  atomSymbols(symbols),
106  atomCharges(charges), atomIsotopes(isotopes), bondMatrix(bond_mtx) {}
107 
108  void calculate(const MolecularGraph&, Util::STArray&);
109 
110  private:
111  NumberingState() {}
112 
113  void init(const MolecularGraph&);
114 
115  void perceiveSymClasses();
116 
117  void distributeNumbers(Util::STArray&);
118  void distributeNumbers(std::size_t);
119 
120  void getNextAtomIndices(STArray&);
121 
122  void addListEntriesForAtom(std::size_t, std::size_t);
123 
124  void copy(NumberingState&);
125 
126  typedef STPairArray::const_iterator STPairArrayIterator;
127 
128  STPairArray* symClassIDs;
129  SArray* atomSymbols;
130  LArray* atomCharges;
131  STArray* atomIsotopes;
132  Math::SparseULMatrix* bondMatrix;
133  const MolecularGraph* molGraph;
134  STPairArray atomNumbering;
135  STArray indexLookupTable;
136  STArray fromList;
137  STArray ringClosures;
138  std::string nodeValues;
139  STArray lineValues;
140  LArray modifications;
141  STPairArrayIterator lastSymClass;
142  std::size_t centerAtomNumber;
143  std::size_t nextAtomNumber;
144  bool sortRCList;
145  };
146 
147  STPairArray symClassIDs;
148  SArray atomSymbols;
149  LArray atomCharges;
150  STArray atomIsotopes;
151  Math::SparseULMatrix bondMatrix;
152  NumberingState numbering;
153  };
154  } // namespace Chem
155 } // namespace CDPL
156 
157 #endif // CDPL_CHEM_MORGANNUMBERINGCALCULATOR_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 matrix data types.
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
Computes canonical atom numberings for molecular graphs using Morgan's algorithm.
Definition: MorganNumberingCalculator.hpp:55
MorganNumberingCalculator()
Constructs the MorganNumberingCalculator instance.
MorganNumberingCalculator(const MolecularGraph &molgraph, Util::STArray &numbering)
Constructs the MorganNumberingCalculator instance and performs a canonical numbering of the atoms in ...
MorganNumberingCalculator(const MorganNumberingCalculator &)=delete
void calculate(const MolecularGraph &molgraph, Util::STArray &numbering)
Performs a canonical numbering of the atoms in the molecular graph molgraph.
MorganNumberingCalculator & operator=(const MorganNumberingCalculator &)=delete
SparseMatrix< unsigned long > SparseULMatrix
Unbounded sparse matrix holding unsigned integers of type unsigned long.
Definition: Matrix.hpp:3559
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:578
Array< long > LArray
Array storing integers of type long.
Definition: Array.hpp:583
Array< STPair > STPairArray
Array storing pairs of unsigned integers of type std::size_t.
Definition: Array.hpp:593
Array< std::string > SArray
Array storing std::string objects.
Definition: Array.hpp:603
std::pair< std::size_t, std::size_t > STPair
Pair of unsigned integers of type std::size_t.
Definition: Array.hpp:588
The namespace of the Chemical Data Processing Library.