Chemical Data Processing Library C++ API - Version 1.4.0
MolecularComplexityCalculator.hpp
Go to the documentation of this file.
1 /*
2  * MolecularComplexityCalculator.hpp
3  *
4  * Calculation of the molecular complexity
5  * (J. B. Hendrickson, P. Huang, A. G. Toczko, J. Chem. Inf. Comput. Sci. 1987, 27, 63-67)
6  *
7  * This file is part of the Chemical Data Processing Toolkit
8  *
9  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library; see the file COPYING. If not, write to
23  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  */
26 
32 #ifndef CDPL_DESCR_MOLECULARCOMPLEXITYCALCULATOR_HPP
33 #define CDPL_DESCR_MOLECULARCOMPLEXITYCALCULATOR_HPP
34 
35 #include <cstddef>
36 #include <map>
37 #include <set>
38 
39 #include "CDPL/Descr/APIPrefix.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Chem
46  {
47 
48  class MolecularGraph;
49  class Atom;
50  class Bond;
51  } // namespace Chem
52 
53  namespace Descr
54  {
55 
67  {
68 
69  public:
74  complexity(0.0) {}
75 
85 
87 
89 
95  double calculate(const Chem::MolecularGraph& molgraph);
96 
102  double getResult() const;
103 
104  private:
105  void processAtom(const Chem::Atom&);
106  void processBond(const Chem::Bond&);
107 
108  void calcAtomTypeComplexity();
109  void calcStructuralComplexity();
110 
111  class SymmetryTerm
112  {
113 
114  public:
115  SymmetryTerm(const Chem::MolecularGraph&, const Chem::Atom&);
116 
117  void incNumEquivAtoms();
118 
119  double getValue() const;
120  double getEtaContribution() const;
121  double getNumEquivAtoms() const;
122 
123  std::size_t getID() const;
124 
125  private:
126  double numEquivAtoms;
127  std::size_t id;
128  std::size_t hCount;
129  };
130 
131  typedef std::map<std::size_t, SymmetryTerm> SymmetryTermMap;
132 
133  class PiBondTerm
134  {
135 
136  public:
137  PiBondTerm(std::size_t, std::size_t, std::size_t);
138 
139  double getCorrection(const SymmetryTermMap&) const;
140 
141  bool isRelevant(const SymmetryTermMap&) const;
142 
143  bool operator<(const PiBondTerm&) const;
144 
145  private:
146  std::size_t symClassID1;
147  std::size_t symClassID2;
148  std::size_t order;
149  };
150 
151  typedef std::map<std::size_t, std::size_t> AtomTypeCountMap;
152  typedef std::set<PiBondTerm> PiBondTermSet;
153 
154  const Chem::MolecularGraph* molGraph;
155  SymmetryTermMap symmetryTerms;
156  AtomTypeCountMap atomTypeCounts;
157  PiBondTermSet piBondTerms;
158  std::size_t numHeavyAtoms;
159  std::size_t numDoubleBonds;
160  std::size_t numTripleBonds;
161  double etaTotal;
162  double atmTypeComplexity;
163  double structComplexity;
164  double complexity;
165  };
166  } // namespace Descr
167 } // namespace CDPL
168 
169 #endif // CDPL_DESCR_MOLECULARCOMPLEXITYCALCULATOR_HPP
Definition of the preprocessor macro CDPL_DESCR_API.
#define CDPL_DESCR_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Calculation of the molecular complexity of a molecular graph after Hendrickson, Huang and Toczko.
Definition: MolecularComplexityCalculator.hpp:67
MolecularComplexityCalculator()
Constructs the MolecularComplexityCalculator instance.
Definition: MolecularComplexityCalculator.hpp:73
double calculate(const Chem::MolecularGraph &molgraph)
Calculates the complexity of the molecular graph molgraph.
double getResult() const
Returns the result of the last molecular graph complexity calculation.
MolecularComplexityCalculator & operator=(const MolecularComplexityCalculator &)=delete
MolecularComplexityCalculator(const Chem::MolecularGraph &molgraph)
Constructs the MolecularComplexityCalculator instance and calculates the complexity of the molecular ...
MolecularComplexityCalculator(const MolecularComplexityCalculator &)=delete
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
The namespace of the Chemical Data Processing Library.