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