RDKit
Open-source cheminformatics and machine learning.
DistGeomUtils.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2019 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #include <RDGeneral/export.h>
11 #ifndef _RD_DISTGEOMUTILS_H_
12 #define _RD_DISTGEOMUTILS_H_
13 
14 #include "BoundsMatrix.h"
15 #include <Numerics/SymmMatrix.h>
16 #include <map>
17 #include <Geometry/point.h>
18 #include "ChiralSet.h"
19 #include <RDGeneral/utils.h>
20 #include <boost/dynamic_bitset.hpp>
21 
22 namespace ForceFields {
23 class ForceField;
24 namespace CrystalFF {
25 struct CrystalFFDetails;
26 }
27 } // namespace ForceFields
28 
29 namespace DistGeom {
30 
31 //! Pick a distance matrix at random such that the
32 //! distance satisfy the bounds in the BoundsMatrix
33 /*!
34  \param mmat Bounds matrix
35  \param distmat Storage for randomly chosen distances
36  \param seed the random number seed to use
37 
38  \return the largest element of the distance matrix
39  */
41  const BoundsMatrix &mmat, RDNumeric::SymmMatrix<double> &distmat,
42  int seed = -1);
43 //! \overload
45  const BoundsMatrix &mmat, RDNumeric::SymmMatrix<double> &distmat,
47 
48 //! Compute an initial embedded in 3D based on a distance matrix
49 /*!
50  This function follows the embed algorithm mentioned in
51  "Distance Geometry and Molecular Conformation" by G.M.Crippen and T.F.Havel
52  (pages 312-313)
53 
54  \param distmat Distance matrix
55  \param positions A vector of pointers to Points to write out the resulting
56  coordinates
57  \param randNegEig If set to true and if any of the eigen values are negative,
58  we will
59  pick the corresponding components of the coordinates at
60  random
61  \param numZeroFail Fail embedding is more this many (or more) eigen values are
62  zero
63  \param seed the random number seed to use
64 
65  \return true if the embedding was successful
66 */
68  const RDNumeric::SymmMatrix<double> &distmat,
69  RDGeom::PointPtrVect &positions, bool randNegEig = false,
70  unsigned int numZeroFail = 2, int seed = -1);
71 //! \overload
73  const RDNumeric::SymmMatrix<double> &distmat,
75  bool randNegEig = false, unsigned int numZeroFail = 2);
76 
77 //! places atoms randomly in a box
78 /*!
79  \param positions A vector of pointers to Points to write out the resulting
80  coordinates
81  \param boxSize the side-length of the cubic box
82  \param seed the random number seed to use
83 
84  \return true if the coordinate generation was successful
85 */
87  RDGeom::PointPtrVect &positions, double boxSize, int seed = -1);
88 //! \overload
90  RDGeom::PointPtrVect &positions, double boxSize,
92 
93 //! Setup the error function for violation of distance bounds as a forcefield
94 /*!
95  This is based on function E3 on page 311 of "Distance Geometry in Molecular
96  Modeling" Jeffrey M.Blaney and J.Scott Dixon, Review in Computational
97  Chemistry,
98  Volume V
99 
100  \param mmat Distance bounds matrix
101  \param positions A vector of pointers to Points to write out the
102  resulting coordinates
103  \param csets The vector of chiral points (type: ChiralSet)
104  \param weightChiral weight to be used to enforce chirality
105  \param weightFourthDim another chiral weight
106  \param extraWeights an optional set of weights for distance bounds
107  violations
108  \param basinSizeTol Optional: any distance bound with a basin (distance
109  between max and
110  min bounds) larger than this value will not be included
111  in the force
112  field used to cleanup the structure.
113 
114  \return a pointer to a ForceField suitable for cleaning up the violations.
115  <b>NOTE:</b> the caller is responsible for deleting this force field.
116 
117 */
119  const BoundsMatrix &mmat, RDGeom::PointPtrVect &positions,
120  const VECT_CHIRALSET &csets, double weightChiral = 1.0,
121  double weightFourthDim = 0.1,
122  std::map<std::pair<int, int>, double> *extraWeights = 0,
123  double basinSizeTol = 5.0, boost::dynamic_bitset<> *fixedPts = nullptr);
124 
125 //! Force field with experimental torsion angle preferences and 1-2/1-3 distance
126 // constraints
127 /*!
128 
129  \param mmat Distance bounds matrix
130  \param positions A vector of pointers to 3D Points to write out the
131  resulting coordinates
132  \param etkdgDetails Contains information about the ETKDG force field
133 
134  <b>NOTE:</b> the caller is responsible for deleting this force field.
135 
136 */
138  const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
139  const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails);
140 //! Force field with experimental torsion angle preferences and 1-2/1-3 distance
141 // constraints
142 /*!
143 
144  \param mmat Distance bounds matrix
145  \param positions A vector of pointers to 3D Points to write out the
146  resulting coordinates
147  \param etkdgDetails Contains information about the ETKDG force field
148 
149  <b>NOTE:</b> the caller is responsible for deleting this force field.
150 
151 */
153  const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
154  const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails);
155 
156 //! Force field with only improper terms
157 /*!
158 
159  \param mmat Distance bounds matrix
160  \param positions A vector of pointers to 3D Points to write out the
161  resulting coordinates \param improperAtoms A list of groups of 4 atom
162  indices for inversion terms \param atomNums A list of atomic numbers
163  for all atoms in the molecule
164 
165  \return a pointer to a ForceField with improper terms
166  <b>NOTE:</b> the caller is responsible for deleting this force field.
167 
168 */
171  const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
172  const std::vector<std::vector<int>> &improperAtoms,
173  const std::vector<int> &atomNums);
174 
175 } // namespace DistGeom
176 
177 #endif
BoundsMatrix.h
RDGeom::Point3DPtrVect
std::vector< RDGeom::Point3D * > Point3DPtrVect
Definition: point.h:503
DistGeom::construct3DImproperForceField
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField * construct3DImproperForceField(const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions, const std::vector< std::vector< int >> &improperAtoms, const std::vector< int > &atomNums)
Force field with only improper terms.
point.h
ChiralSet.h
RDNumeric::SymmMatrix
A symmetric matrix class.
Definition: SymmMatrix.h:30
RDKIT_DISTGEOMETRY_EXPORT
#define RDKIT_DISTGEOMETRY_EXPORT
Definition: export.h:164
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition: ForceField.h:79
utils.h
DistGeom::construct3DForceField
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField * construct3DForceField(const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions, const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails)
Force field with experimental torsion angle preferences and 1-2/1-3 distance.
DistGeom::constructPlain3DForceField
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField * constructPlain3DForceField(const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions, const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails)
Force field with experimental torsion angle preferences and 1-2/1-3 distance.
ForceFields
Definition: TorsionAngleM6.h:24
ForceFields::CrystalFF::CrystalFFDetails
Definition: TorsionPreferences.h:21
DistGeom
Definition: BoundsMatrix.h:20
RDKit::double_source_type
boost::variate_generator< rng_type &, uniform_double > double_source_type
Definition: utils.h:42
DistGeom::constructForceField
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField * constructForceField(const BoundsMatrix &mmat, RDGeom::PointPtrVect &positions, const VECT_CHIRALSET &csets, double weightChiral=1.0, double weightFourthDim=0.1, std::map< std::pair< int, int >, double > *extraWeights=0, double basinSizeTol=5.0, boost::dynamic_bitset<> *fixedPts=nullptr)
Setup the error function for violation of distance bounds as a forcefield.
DistGeom::computeRandomCoords
RDKIT_DISTGEOMETRY_EXPORT bool computeRandomCoords(RDGeom::PointPtrVect &positions, double boxSize, int seed=-1)
places atoms randomly in a box
DistGeom::VECT_CHIRALSET
std::vector< ChiralSetPtr > VECT_CHIRALSET
Definition: ChiralSet.h:55
SymmMatrix.h
DistGeom::pickRandomDistMat
RDKIT_DISTGEOMETRY_EXPORT double pickRandomDistMat(const BoundsMatrix &mmat, RDNumeric::SymmMatrix< double > &distmat, int seed=-1)
RDGeom::PointPtrVect
std::vector< RDGeom::Point * > PointPtrVect
Definition: point.h:499
export.h
DistGeom::computeInitialCoords
RDKIT_DISTGEOMETRY_EXPORT bool computeInitialCoords(const RDNumeric::SymmMatrix< double > &distmat, RDGeom::PointPtrVect &positions, bool randNegEig=false, unsigned int numZeroFail=2, int seed=-1)
Compute an initial embedded in 3D based on a distance matrix.