DistGeomUtils.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2007 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef _RD_DISTGEOMUTILS_H_
00011 #define _RD_DISTGEOMUTILS_H_
00012 
00013 #include "BoundsMatrix.h"
00014 #include <Numerics/SymmMatrix.h>
00015 #include <map>
00016 #include <Geometry/point.h>
00017 #include "ChiralSet.h"
00018 
00019 namespace ForceFields {
00020   class ForceField;
00021 }
00022 
00023 namespace DistGeom {
00024 
00025   //! Pick a distance matrix at random such that the
00026   //!  distance satisfy the bounds in the BoundsMatrix
00027   /*!
00028     \param mmat     Bounds matrix
00029     \param distmat  Storage for randomly chosen distances
00030     \param seed     Optional value to seed the random number generator
00031 
00032     \return the largest element of the distance matrix
00033    */
00034   double pickRandomDistMat(const BoundsMatrix &mmat, 
00035                            RDNumeric::SymmMatrix<double> &distmat, int seed=-1);
00036 
00037   //! Compute an initial embedded in 3D based on a distance matrix
00038   /*! 
00039     This function follows the embed algorithm mentioned in 
00040     "Distance Geometry and Molecular Conformation" by G.M.Crippen and T.F.Havel
00041     (pages 312-313) 
00042 
00043     \param distmat     Distance matrix
00044     \param positions     A vector of pointers to Points to write out the resulting coordinates
00045     \param randNegEig  If set to true and if any of the eigen values are negative, we will
00046                        pick the corresponding components of the coordinates at random
00047     \param numZeroFail Fail embedding is more this many (or more) eigen values are zero
00048 
00049     \return true if the embedding was successful
00050   */
00051   bool computeInitialCoords(const RDNumeric::SymmMatrix<double> &distmat,  
00052                             RDGeom::PointPtrVect &positions, bool randNegEig=false, 
00053                             unsigned int numZeroFail=2);
00054 
00055   //! places atoms randomly in a box
00056   /*! 
00057     \param positions     A vector of pointers to Points to write out the resulting coordinates
00058     \param boxSize     If set to true and if any of the eigen values are negative, we will
00059                        pick the corresponding components of the coordinates at random
00060 
00061     \return true if the embedding was successful
00062   */
00063   bool computeRandomCoords(RDGeom::PointPtrVect &positions, double boxSize);
00064 
00065   //! Setup the error function for violation of distance bounds as a forcefield
00066   /*! 
00067     This is based on function E3 on page 311 of "Distance Geometry in Molecular
00068     Modeling" Jeffrey M.Blaney and J.Scott Dixon, Review in Computational Chemistry,
00069     Volume V
00070 
00071     \param mmat            Distance bounds matrix
00072     \param positions       A vector of pointers to Points to write out the resulting coordinates
00073     \param csets           The vector of chiral points (type: ChiralSet)
00074     \param weightChiral    weight to be used to enforce chirality
00075     \param weightFourthDim another chiral weight
00076     \param extraWeights    an optional set of weights for distance bounds violations
00077     \param basinSizeTol  Optional: any distance bound with a basin (distance between max and
00078                          min bounds) larger than this value will not be included in the force
00079                          field used to cleanup the structure.
00080 
00081     \return a pointer to a ForceField suitable for cleaning up the violations.
00082       <b>NOTE:</b> the caller is responsible for deleting this force field.
00083 
00084   */
00085   ForceFields::ForceField *constructForceField(const BoundsMatrix &mmat,
00086                                                RDGeom::PointPtrVect &positions, const VECT_CHIRALSET &csets,
00087                                                double weightChiral=1.0,
00088                                                double weightFourthDim=0.1,
00089                                                std::map< std::pair<int,int>,double> *extraWeights=0,
00090                                                double basinSizeTol=5.0);
00091 
00092 }
00093     
00094 #endif