Chemical Data Processing Library C++ API - Version 1.4.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 
78  {
79 
80  public:
84  typedef std::pair<std::size_t, Chem::StereoDescriptor> StereoCenterData;
85 
86  private:
87  typedef std::vector<StereoCenterData> StereoCenterDataArray;
88 
89  public:
93  typedef StereoCenterDataArray::const_iterator ConstStereoCenterDataIterator;
94 
99 
105 
111 
117  void addAtomStereoCenter(const Chem::Atom& atom, const Chem::StereoDescriptor& descr);
118 
124  void addBondStereoCenter(const Chem::Bond& bond, const Chem::StereoDescriptor& descr);
125 
130  void setup(const Chem::MolecularGraph& molgraph);
131 
137  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData& ia_data);
138 
144 
149  std::size_t getNumAtomStereoCenters() const;
150 
155  std::size_t getNumBondStereoCenters() const;
156 
163  const StereoCenterData& getAtomStereoCenterData(std::size_t idx) const;
164 
171  const StereoCenterData& getBondStereoCenterData(std::size_t idx) const;
172 
178 
184 
190 
196 
205  Util::DG3DCoordinatesGenerator& coords_gen);
206 
212 
218 
224 
231 
237 
243 
249 
255 
256  private:
257  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData* ia_data);
258 
259  void addFixedSubstructVolConstraints(const Chem::AtomContainer& atoms, const Math::Vector3DArray& coords,
260  Util::DG3DCoordinatesGenerator& coords_gen, std::size_t* ref_atom_inds,
261  std::size_t& num_vol_constr, std::size_t level);
262 
263  void init(const Chem::MolecularGraph& molgraph);
264 
265  void assignBondLengths(const ForceField::MMFF94InteractionData* ia_data);
266  void assignBondAngles(const ForceField::MMFF94InteractionData* ia_data);
267 
268  void extractAtomStereoCenterData();
269  void extractBondStereoCenterData();
270 
271  void setBondLength(std::size_t atom1_idx, std::size_t atom2_idx, double length);
272  double getBondLength(std::size_t atom1_idx, std::size_t atom2_idx) const;
273 
274  void setBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx, double angle);
275  double getBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx) const;
276 
277  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, const Chem::Bond& bond1, const Chem::Bond& bond2) const;
278  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, std::size_t atom1_idx, std::size_t atom2_idx) const;
279 
280  void markAtomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx);
281  bool atomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx) const;
282 
283  double calc13AtomDistance(double bond1_len, double bond2_len, double angle) const;
284 
285  double calcCis14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
286  double angle_12, double angle_23) const;
287  double calcTrans14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
288  double angle_12, double angle_23) const;
289 
290  bool isPlanar(const Chem::Atom& atom) const;
291  bool isPlanar(const Chem::Bond& bond) const;
292 
293  typedef std::vector<std::size_t> AtomIndexList;
294 
295  std::size_t getNeighborAtoms(const Chem::Atom& atom, AtomIndexList& idx_list,
296  const Chem::Atom* x_atom = 0) const;
297 
298  typedef std::pair<std::size_t, std::size_t> BondLengthKey;
299  typedef std::tuple<std::size_t, std::size_t, std::size_t> BondAngleKey;
300 
301  struct CDPL_CONFGEN_API BondAngleKeyHash
302  {
303 
304  std::size_t operator()(const BondAngleKey& k) const;
305  };
306 
307  struct CDPL_CONFGEN_API BondLengthKeyHash
308  {
309 
310  std::size_t operator()(const BondLengthKey& k) const;
311  };
312 
313  typedef std::unordered_map<BondLengthKey, double, BondLengthKeyHash> BondLengthTable;
314  typedef std::unordered_map<BondAngleKey, double, BondAngleKeyHash> BondAngleTable;
315 
316  const Chem::MolecularGraph* molGraph;
317  Util::BitSet hAtomMask;
318  Util::BitSet procAtomPairMask;
319  Util::BitSet stereoAtomMask;
320  BondLengthTable bondLengthTable;
321  BondAngleTable bondAngleTable;
322  StereoCenterDataArray atomStereoData;
323  StereoCenterDataArray bondStereoData;
324  std::size_t numAtoms;
325  AtomIndexList atomIndexList1;
326  AtomIndexList atomIndexList2;
327  DGConstraintGeneratorSettings settings;
328  };
329  } // namespace ConfGen
330 } // namespace CDPL
331 
332 #endif // CDPL_CONFGEN_DGCONSTRAINTGENERATOR_HPP
Declaration of 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 class CDPL::ConfGen::DGConstraintGeneratorSettings.
Implementation of a distance geometry based coordinates generator.
Definition of the type CDPL::Chem::StereoDescriptor.
Definition of class CDPL::Math::VectorArray.
Common interface for data structures that support a random access to stored Chem::Atom instances.
Definition: AtomContainer.hpp:55
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
Data structure for the storage of Chem::Fragment objects.
Definition: FragmentList.hpp:49
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Data structure for the storage and retrieval of stereochemical information about atoms and bonds.
Definition: StereoDescriptor.hpp:102
Bundle of configuration parameters for distance-geometry constraint generation via class ConfGen::DGC...
Definition: DGConstraintGeneratorSettings.hpp:45
Constructs geometric constraints (distance, planarity, volume) for distance-geometry-based 3D structu...
Definition: DGConstraintGenerator.hpp:78
ConstStereoCenterDataIterator getBondStereoCenterDataEnd() const
Returns a constant iterator pointing one past the last bond stereo center.
void addAtomConfigurationConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds volume constraints enforcing the registered atom stereo-center configurations to coords_gen.
void addFixedSubstructureConstraints(const Chem::AtomContainer &atoms, const Math::Vector3DArray &coords, Util::DG3DCoordinatesGenerator &coords_gen)
Adds distance and volume constraints that fix the supplied substructure to the given coordinates.
void addBondPlanarityConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds planarity (zero-volume) constraints for double and aromatic bonds to coords_gen.
void addDefaultDistanceConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds default (Van der Waals-derived) lower/upper distance constraints between all non-bonded atom pai...
void setup(const Chem::MolecularGraph &molgraph, const ForceField::MMFF94InteractionData &ia_data)
Initializes the generator for the molecular graph molgraph using bond lengths and angles obtained fro...
void add14DistanceConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds 1,4-distance constraints (cis/trans bounds) to coords_gen.
const StereoCenterData & getAtomStereoCenterData(std::size_t idx) const
Returns the stereo-center data for the atom stereo center at index idx.
void addBondLengthConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds bond-length distance constraints to coords_gen.
void addBondStereoCenter(const Chem::Bond &bond, const Chem::StereoDescriptor &descr)
Registers a bond stereo center to be constrained.
void addAtomPlanarityConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds planarity (zero-volume) constraints for sp2-hybridized / aromatic atoms to coords_gen.
StereoCenterDataArray::const_iterator ConstStereoCenterDataIterator
A constant iterator over StereoCenterData entries.
Definition: DGConstraintGenerator.hpp:93
const DGConstraintGeneratorSettings & getSettings() const
Returns a const reference to the constraint-generation settings.
std::size_t getNumBondStereoCenters() const
Returns the number of registered bond stereo centers.
ConstStereoCenterDataIterator getBondStereoCenterDataBegin() const
Returns a constant iterator pointing to the first bond stereo center.
DGConstraintGenerator()
Constructs the DGConstraintGenerator instance.
void setup(const Chem::MolecularGraph &molgraph)
Initializes the generator for the molecular graph molgraph using default geometry data.
std::pair< std::size_t, Chem::StereoDescriptor > StereoCenterData
Pair holding an atom or bond index plus the associated stereo descriptor.
Definition: DGConstraintGenerator.hpp:84
ConstStereoCenterDataIterator getAtomStereoCenterDataEnd() const
Returns a constant iterator pointing one past the last atom stereo center.
void addAtomStereoCenter(const Chem::Atom &atom, const Chem::StereoDescriptor &descr)
Registers an atom stereo center to be constrained.
const Util::BitSet & getExcludedHydrogenMask() const
Returns the bit mask of hydrogen atoms that have been excluded from constraint generation.
const StereoCenterData & getBondStereoCenterData(std::size_t idx) const
Returns the stereo-center data for the bond stereo center at index idx.
void addBondConfigurationConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds distance and volume constraints enforcing the registered bond stereo-center configurations to co...
DGConstraintGeneratorSettings & getSettings()
Returns a reference to the constraint-generation settings.
ConstStereoCenterDataIterator getAtomStereoCenterDataBegin() const
Returns a constant iterator pointing to the first atom stereo center.
std::size_t getNumAtomStereoCenters() const
Returns the number of registered atom stereo centers.
void addBondAngleConstraints(Util::DG3DCoordinatesGenerator &coords_gen)
Adds bond-angle (1,3) distance constraints to coords_gen.
Container holding the full set of MMFF94 interaction parameter records for a molecular graph.
Definition: MMFF94InteractionData.hpp:62
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:87
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Returns the length (L2 norm) of the vector expression e (alias of norm2()).
Definition: VectorExpression.hpp:1129
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
DGCoordinatesGenerator< 3, double > DG3DCoordinatesGenerator
Convenience alias for the 3D coordinates generator with double-precision values.
Definition: DGCoordinatesGenerator.hpp:581
The namespace of the Chemical Data Processing Library.