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