Chemical Data Processing Library C++ API - Version 1.1.1
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 
61  {
62 
63  public:
68  complexity(0.0) {}
69 
79 
85  double calculate(const Chem::MolecularGraph& molgraph);
86 
92  double getResult() const;
93 
94  private:
96 
98 
99  void processAtom(const Chem::Atom&);
100  void processBond(const Chem::Bond&);
101 
102  void calcAtomTypeComplexity();
103  void calcStructuralComplexity();
104 
105  class SymmetryTerm
106  {
107 
108  public:
109  SymmetryTerm(const Chem::MolecularGraph&, const Chem::Atom&);
110 
111  void incNumEquivAtoms();
112 
113  double getValue() const;
114  double getEtaContribution() const;
115  double getNumEquivAtoms() const;
116 
117  std::size_t getID() const;
118 
119  private:
120  double numEquivAtoms;
121  std::size_t id;
122  std::size_t hCount;
123  };
124 
125  typedef std::map<std::size_t, SymmetryTerm> SymmetryTermMap;
126 
127  class PiBondTerm
128  {
129 
130  public:
131  PiBondTerm(std::size_t, std::size_t, std::size_t);
132 
133  double getCorrection(const SymmetryTermMap&) const;
134 
135  bool isRelevant(const SymmetryTermMap&) const;
136 
137  bool operator<(const PiBondTerm&) const;
138 
139  private:
140  std::size_t symClassID1;
141  std::size_t symClassID2;
142  std::size_t order;
143  };
144 
145  typedef std::map<std::size_t, std::size_t> AtomTypeCountMap;
146  typedef std::set<PiBondTerm> PiBondTermSet;
147 
148  const Chem::MolecularGraph* molGraph;
149  SymmetryTermMap symmetryTerms;
150  AtomTypeCountMap atomTypeCounts;
151  PiBondTermSet piBondTerms;
152  std::size_t numHeavyAtoms;
153  std::size_t numDoubleBonds;
154  std::size_t numTripleBonds;
155  double etaTotal;
156  double atmTypeComplexity;
157  double structComplexity;
158  double complexity;
159  };
160  } // namespace Descr
161 } // namespace CDPL
162 
163 #endif // CDPL_DESCR_MOLECULARCOMPLEXITYCALCULATOR_HPP
CDPL::Descr::MolecularComplexityCalculator::MolecularComplexityCalculator
MolecularComplexityCalculator()
Constructs the MolecularComplexityCalculator instance.
Definition: MolecularComplexityCalculator.hpp:67
CDPL::Chem::Bond
Bond.
Definition: Bond.hpp:50
CDPL::Descr::MolecularComplexityCalculator::calculate
double calculate(const Chem::MolecularGraph &molgraph)
Calculates the complexity of the molecular graph molgraph.
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Util::operator<
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
CDPL::Descr::MolecularComplexityCalculator::getResult
double getResult() const
Returns the result of the last molecular graph complexity calculation.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Descr::MolecularComplexityCalculator::MolecularComplexityCalculator
MolecularComplexityCalculator(const Chem::MolecularGraph &molgraph)
Constructs the MolecularComplexityCalculator instance and calculates the complexity of the molecular ...
CDPL::Descr::MolecularComplexityCalculator
MolecularComplexityCalculator.
Definition: MolecularComplexityCalculator.hpp:61
APIPrefix.hpp
Definition of the preprocessor macro CDPL_DESCR_API.
CDPL_DESCR_API
#define CDPL_DESCR_API
Tells the compiler/linker which classes, functions and variables are part of the library API.