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 
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  double pickRandomDistMat(const BoundsMatrix &mmat,
38  int seed=-1);
39  //! \overload
40  double pickRandomDistMat(const BoundsMatrix &mmat,
43 
44  //! Compute an initial embedded in 3D based on a distance matrix
45  /*!
46  This function follows the embed algorithm mentioned in
47  "Distance Geometry and Molecular Conformation" by G.M.Crippen and T.F.Havel
48  (pages 312-313)
49 
50  \param distmat Distance matrix
51  \param positions A vector of pointers to Points to write out the resulting coordinates
52  \param randNegEig If set to true and if any of the eigen values are negative, we will
53  pick the corresponding components of the coordinates at random
54  \param numZeroFail Fail embedding is more this many (or more) eigen values are zero
55  \param seed the random number seed to use
56 
57  \return true if the embedding was successful
58  */
60  RDGeom::PointPtrVect &positions, bool randNegEig=false,
61  unsigned int numZeroFail=2,
62  int seed=-1);
63  //! \overload
65  RDGeom::PointPtrVect &positions,
67  bool randNegEig=false,
68  unsigned int numZeroFail=2
69  );
70 
71  //! places atoms randomly in a box
72  /*!
73  \param positions A vector of pointers to Points to write out the resulting coordinates
74  \param boxSize the side-length of the cubic box
75  \param seed the random number seed to use
76 
77  \return true if the coordinate generation was successful
78  */
79  bool computeRandomCoords(RDGeom::PointPtrVect &positions, double boxSize,
80  int seed=-1);
81  //! \overload
82  bool computeRandomCoords(RDGeom::PointPtrVect &positions, double boxSize,
84 
85  //! Setup the error function for violation of distance bounds as a forcefield
86  /*!
87  This is based on function E3 on page 311 of "Distance Geometry in Molecular
88  Modeling" Jeffrey M.Blaney and J.Scott Dixon, Review in Computational Chemistry,
89  Volume V
90 
91  \param mmat Distance bounds matrix
92  \param positions A vector of pointers to Points to write out the resulting coordinates
93  \param csets The vector of chiral points (type: ChiralSet)
94  \param weightChiral weight to be used to enforce chirality
95  \param weightFourthDim another chiral weight
96  \param extraWeights an optional set of weights for distance bounds violations
97  \param basinSizeTol Optional: any distance bound with a basin (distance between max and
98  min bounds) larger than this value will not be included in the force
99  field used to cleanup the structure.
100 
101  \return a pointer to a ForceField suitable for cleaning up the violations.
102  <b>NOTE:</b> the caller is responsible for deleting this force field.
103 
104  */
105  ForceFields::ForceField *constructForceField(const BoundsMatrix &mmat,
106  RDGeom::PointPtrVect &positions, const VECT_CHIRALSET &csets,
107  double weightChiral=1.0,
108  double weightFourthDim=0.1,
109  std::map< std::pair<int,int>,double> *extraWeights=0,
110  double basinSizeTol=5.0);
111 
112 }
113 
114 #endif
double pickRandomDistMat(const BoundsMatrix &mmat, RDNumeric::SymmMatrix< double > &distmat, RDKit::double_source_type &rng)
std::vector< RDGeom::Point * > PointPtrVect
Definition: point.h:514
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:28
std::vector< ChiralSetPtr > VECT_CHIRALSET
Definition: ChiralSet.h:52
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:36
A class to store forcefields and handle minimization.
Definition: ForceField.h:56
bool computeRandomCoords(RDGeom::PointPtrVect &positions, double boxSize, RDKit::double_source_type &rng)