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