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:
82  typedef std::pair<std::size_t, Chem::StereoDescriptor> StereoCenterData;
83 
84  private:
85  typedef std::vector<StereoCenterData> StereoCenterDataArray;
86 
87  public:
89  typedef StereoCenterDataArray::const_iterator ConstStereoCenterDataIterator;
90 
95 
101 
107 
113  void addAtomStereoCenter(const Chem::Atom& atom, const Chem::StereoDescriptor& descr);
114 
120  void addBondStereoCenter(const Chem::Bond& bond, const Chem::StereoDescriptor& descr);
121 
126  void setup(const Chem::MolecularGraph& molgraph);
127 
133  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData& ia_data);
134 
140 
145  std::size_t getNumAtomStereoCenters() const;
146 
151  std::size_t getNumBondStereoCenters() const;
152 
159  const StereoCenterData& getAtomStereoCenterData(std::size_t idx) const;
160 
167  const StereoCenterData& getBondStereoCenterData(std::size_t idx) const;
168 
174 
180 
186 
192 
201  Util::DG3DCoordinatesGenerator& coords_gen);
202 
208 
214 
220 
227 
233 
239 
245 
251 
252  private:
253  void setup(const Chem::MolecularGraph& molgraph, const ForceField::MMFF94InteractionData* ia_data);
254 
255  void addFixedSubstructVolConstraints(const Chem::AtomContainer& atoms, const Math::Vector3DArray& coords,
256  Util::DG3DCoordinatesGenerator& coords_gen, std::size_t* ref_atom_inds,
257  std::size_t& num_vol_constr, std::size_t level);
258 
259  void init(const Chem::MolecularGraph& molgraph);
260 
261  void assignBondLengths(const ForceField::MMFF94InteractionData* ia_data);
262  void assignBondAngles(const ForceField::MMFF94InteractionData* ia_data);
263 
264  void extractAtomStereoCenterData();
265  void extractBondStereoCenterData();
266 
267  void setBondLength(std::size_t atom1_idx, std::size_t atom2_idx, double length);
268  double getBondLength(std::size_t atom1_idx, std::size_t atom2_idx) const;
269 
270  void setBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx, double angle);
271  double getBondAngle(std::size_t atom1_idx, std::size_t atom2_idx, std::size_t atom3_idx) const;
272 
273  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, const Chem::Bond& bond1, const Chem::Bond& bond2) const;
274  std::size_t getSmallestRingSize(const Chem::FragmentList& sssr, std::size_t atom1_idx, std::size_t atom2_idx) const;
275 
276  void markAtomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx);
277  bool atomPairProcessed(std::size_t atom1_idx, std::size_t atom2_idx) const;
278 
279  double calc13AtomDistance(double bond1_len, double bond2_len, double angle) const;
280 
281  double calcCis14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
282  double angle_12, double angle_23) const;
283  double calcTrans14AtomDistance(double bond1_len, double bond2_len, double bond3_len,
284  double angle_12, double angle_23) const;
285 
286  bool isPlanar(const Chem::Atom& atom) const;
287  bool isPlanar(const Chem::Bond& bond) const;
288 
289  typedef std::vector<std::size_t> AtomIndexList;
290 
291  std::size_t getNeighborAtoms(const Chem::Atom& atom, AtomIndexList& idx_list,
292  const Chem::Atom* x_atom = 0) const;
293 
294  typedef std::pair<std::size_t, std::size_t> BondLengthKey;
295  typedef std::tuple<std::size_t, std::size_t, std::size_t> BondAngleKey;
296 
297  struct CDPL_CONFGEN_API BondAngleKeyHash
298  {
299 
300  std::size_t operator()(const BondAngleKey& k) const;
301  };
302 
303  struct CDPL_CONFGEN_API BondLengthKeyHash
304  {
305 
306  std::size_t operator()(const BondLengthKey& k) const;
307  };
308 
309  typedef std::unordered_map<BondLengthKey, double, BondLengthKeyHash> BondLengthTable;
310  typedef std::unordered_map<BondAngleKey, double, BondAngleKeyHash> BondAngleTable;
311 
312  const Chem::MolecularGraph* molGraph;
313  Util::BitSet hAtomMask;
314  Util::BitSet procAtomPairMask;
315  Util::BitSet stereoAtomMask;
316  BondLengthTable bondLengthTable;
317  BondAngleTable bondAngleTable;
318  StereoCenterDataArray atomStereoData;
319  StereoCenterDataArray bondStereoData;
320  std::size_t numAtoms;
321  AtomIndexList atomIndexList1;
322  AtomIndexList atomIndexList2;
323  DGConstraintGeneratorSettings settings;
324  };
325  } // namespace ConfGen
326 } // namespace CDPL
327 
328 #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 type 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:89
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:82
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 parameters for a molecular graph.
Definition: MMFF94InteractionData.hpp:60
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:85
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Returns the length (L2 norm) of the vector expression e (alias of norm2()).
Definition: VectorExpression.hpp:979
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:544
The namespace of the Chemical Data Processing Library.