Chemical Data Processing Library C++ API - Version 1.0.0
DGConstraintGenerator.hpp
Go to the documentation of this file.
1 /*
2  * DGConstraintGenerator.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_CONFGEN_DGCONSTRAINTGENERATOR_HPP
30 #define CDPL_CONFGEN_DGCONSTRAINTGENERATOR_HPP
31 
32 #include <utility>
33 #include <cstddef>
34 #include <unordered_map>
35 #include <tuple>
36 
41 #include "CDPL/Util/BitSet.hpp"
42 
43 
44 namespace CDPL
45 {
46 
47  namespace ForceField
48  {
49 
50  class MMFF94InteractionData;
51  }
52 
53  namespace Chem
54  {
55 
56  class FragmentList;
57  class MolecularGraph;
58  class Atom;
59  class Bond;
60  } // namespace Chem
61 
62  namespace ConfGen
63  {
64 
66  {
67 
68  public:
69  typedef std::pair<std::size_t, Chem::StereoDescriptor> StereoCenterData;
70 
71  private:
72  typedef std::vector<StereoCenterData> StereoCenterDataArray;
73 
74  public:
75  typedef StereoCenterDataArray::const_iterator ConstStereoCenterDataIterator;
76 
78 
80 
82 
83  void addAtomStereoCenter(const Chem::Atom& atom, const Chem::StereoDescriptor& descr);
84  void addBondStereoCenter(const Chem::Bond& bond, const Chem::StereoDescriptor& descr);
85 
86  void setup(const Chem::MolecularGraph& molgraph);
87  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData& ia_data);
88 
90 
91  std::size_t getNumAtomStereoCenters() const;
92  std::size_t getNumBondStereoCenters() const;
93 
94  const StereoCenterData& getAtomStereoCenterData(std::size_t idx) const;
95  const StereoCenterData& getBondStereoCenterData(std::size_t idx) const;
96 
99 
102 
107 
110 
113 
114  private:
115  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData* ia_data);
116 
117  void init(const Chem::MolecularGraph& molgraph);
118 
119  void assignBondLengths(const ForceField::MMFF94InteractionData* ia_data);
120  void assignBondAngles(const ForceField::MMFF94InteractionData* ia_data);
121 
122  void extractAtomStereoCenterData();
123  void extractBondStereoCenterData();
124 
125  void setBondLength(std::size_t atom1_idx, std::size_t atom2_idx, double length);
126  double getBondLength(std::size_t atom1_idx, std::size_t atom2_idx) const;
127 
128  void setBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx, double angle);
129  double getBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx) const;
130 
131  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, const Chem::Bond& bond1, const Chem::Bond& bond2) const;
132  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, std::size_t atom1_idx, std::size_t atom2_idx) const;
133 
134  void markAtomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx);
135  bool atomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx) const;
136 
137  double calc13AtomDistance(double bond1_len, double bond2_len, double angle) const;
138 
139  double calcCis14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
140  double angle_12, double angle_23) const;
141  double calcTrans14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
142  double angle_12, double angle_23) const;
143 
144  bool isPlanar(const Chem::Atom& atom) const;
145  bool isPlanar(const Chem::Bond& bond) const;
146 
147  typedef std::vector<std::size_t> AtomIndexList;
148 
149  std::size_t getNeighborAtoms(const Chem::Atom& atom, AtomIndexList& idx_list,
150  const Chem::Atom* x_atom = 0) const;
151 
152  typedef std::pair<std::size_t, std::size_t> BondLengthKey;
153  typedef std::tuple<std::size_t, std::size_t, std::size_t> BondAngleKey;
154 
155  struct CDPL_CONFGEN_API BondAngleKeyHash
156  {
157 
158  std::size_t operator()(const BondAngleKey& k) const;
159  };
160 
161  struct CDPL_CONFGEN_API BondLengthKeyHash
162  {
163 
164  std::size_t operator()(const BondLengthKey& k) const;
165  };
166 
167  typedef std::unordered_map<BondLengthKey, double, BondLengthKeyHash> BondLengthTable;
168  typedef std::unordered_map<BondAngleKey, double, BondAngleKeyHash> BondAngleTable;
169 
170  const Chem::MolecularGraph* molGraph;
171  Util::BitSet hAtomMask;
172  Util::BitSet procAtomPairMask;
173  Util::BitSet stereoAtomMask;
174  BondLengthTable bondLengthTable;
175  BondAngleTable bondAngleTable;
176  StereoCenterDataArray atomStereoData;
177  StereoCenterDataArray bondStereoData;
178  std::size_t numAtoms;
179  AtomIndexList atomIndexList1;
180  AtomIndexList atomIndexList2;
181  DGConstraintGeneratorSettings settings;
182  };
183  } // namespace ConfGen
184 } // namespace CDPL
185 
186 #endif // CDPL_CONFGEN_DGCONSTRAINTGENERATOR_HPP
CDPL::ForceField::MMFF94InteractionData
Definition: MMFF94InteractionData.hpp:51
CDPL::ConfGen::DGConstraintGenerator::setup
void setup(const Chem::MolecularGraph &molgraph, const ForceField::MMFF94InteractionData &ia_data)
CDPL::Chem::Bond
Bond.
Definition: Bond.hpp:50
CDPL::ConfGen::DGConstraintGenerator::getBondStereoCenterData
const StereoCenterData & getBondStereoCenterData(std::size_t idx) const
CDPL::Util::DG3DCoordinatesGenerator
DGCoordinatesGenerator< 3, double > DG3DCoordinatesGenerator
Definition: DGCoordinatesGenerator.hpp:296
CDPL::ConfGen::DGConstraintGenerator::StereoCenterData
std::pair< std::size_t, Chem::StereoDescriptor > StereoCenterData
Definition: DGConstraintGenerator.hpp:69
CDPL::ConfGen::DGConstraintGenerator::getAtomStereoCenterDataBegin
ConstStereoCenterDataIterator getAtomStereoCenterDataBegin() const
CDPL::ConfGen::DGConstraintGenerator::getAtomStereoCenterData
const StereoCenterData & getAtomStereoCenterData(std::size_t idx) const
CDPL::ConfGen::DGConstraintGenerator::getSettings
DGConstraintGeneratorSettings & getSettings()
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
CDPL::ConfGen::DGConstraintGenerator::getNumBondStereoCenters
std::size_t getNumBondStereoCenters() const
CDPL::ConfGen::DGConstraintGenerator::add14DistanceConstraints
void add14DistanceConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::ConfGen::DGConstraintGenerator::addBondConfigurationConstraints
void addBondConfigurationConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGenerator::ConstStereoCenterDataIterator
StereoCenterDataArray::const_iterator ConstStereoCenterDataIterator
Definition: DGConstraintGenerator.hpp:75
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
CDPL::ConfGen::DGConstraintGenerator::setup
void setup(const Chem::MolecularGraph &molgraph)
CDPL::ConfGen::DGConstraintGenerator::getExcludedHydrogenMask
const Util::BitSet & getExcludedHydrogenMask() const
CDPL::ConfGen::DGConstraintGenerator::addDefaultDistanceConstraints
void addDefaultDistanceConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGenerator::getNumAtomStereoCenters
std::size_t getNumAtomStereoCenters() const
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CONFGEN_API.
CDPL_CONFGEN_API
#define CDPL_CONFGEN_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::FragmentList
A data type for the storage of Chem::Fragment objects.
Definition: FragmentList.hpp:49
CDPL::ConfGen::DGConstraintGenerator::addAtomPlanarityConstraints
void addAtomPlanarityConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGenerator
Definition: DGConstraintGenerator.hpp:66
CDPL::ConfGen::DGConstraintGenerator::getSettings
const DGConstraintGeneratorSettings & getSettings() const
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::ConfGen::DGConstraintGenerator::addBondStereoCenter
void addBondStereoCenter(const Chem::Bond &bond, const Chem::StereoDescriptor &descr)
CDPL::ConfGen::DGConstraintGenerator::getBondStereoCenterDataBegin
ConstStereoCenterDataIterator getBondStereoCenterDataBegin() const
CDPL::ConfGen::DGConstraintGenerator::addBondPlanarityConstraints
void addBondPlanarityConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGenerator::getBondStereoCenterDataEnd
ConstStereoCenterDataIterator getBondStereoCenterDataEnd() const
DGConstraintGeneratorSettings.hpp
Definition of the class CDPL::ConfGen::DGConstraintGeneratorSettings.
CDPL::Chem::StereoDescriptor
A data structure for the storage and retrieval of stereochemical information about atoms and bonds.
Definition: StereoDescriptor.hpp:102
StereoDescriptor.hpp
Definition of the type CDPL::Chem::StereoDescriptor.
DGCoordinatesGenerator.hpp
Implementation of a distance geometry based coordinates generator.
CDPL::ConfGen::DGConstraintGenerator::addAtomConfigurationConstraints
void addAtomConfigurationConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGenerator::addBondAngleConstraints
void addBondAngleConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
CDPL::ConfGen::DGConstraintGeneratorSettings
Definition: DGConstraintGeneratorSettings.hpp:42
CDPL::ConfGen::DGConstraintGenerator::DGConstraintGenerator
DGConstraintGenerator()
CDPL::ConfGen::DGConstraintGenerator::addAtomStereoCenter
void addAtomStereoCenter(const Chem::Atom &atom, const Chem::StereoDescriptor &descr)
CDPL::ConfGen::DGConstraintGenerator::getAtomStereoCenterDataEnd
ConstStereoCenterDataIterator getAtomStereoCenterDataEnd() const
CDPL::Math::length
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:553
CDPL::ConfGen::DGConstraintGenerator::addBondLengthConstraints
void addBondLengthConstraints(Util::DG3DCoordinatesGenerator &coords_gen)