ShapeUtils.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005-2006 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_SHAPE_UTILS_H_20050128_
00011 #define _RD_SHAPE_UTILS_H_20050128_
00012 #include <DataStructs/DiscreteValueVect.h>
00013 #include <vector>
00014 
00015 namespace RDGeom {
00016   class Point3D;
00017   class Transform3D;
00018 }
00019 
00020 namespace RDKit {
00021   class ROMol;
00022   class Conformer;
00023 
00024   namespace MolShapes {
00025 
00026     //! Compute the size of the box that can fit the conformation, and offset of the box
00027     //! from the origin
00028     void computeConfDimsAndOffset(const Conformer &conf, RDGeom::Point3D &dims, 
00029                               RDGeom::Point3D &offSet, const RDGeom::Transform3D *trans=0,
00030                               double padding=2.5);
00031     
00032     //! Compute the a box that will fit the confomer
00033     /*!
00034       \param conf            The conformer of interest
00035       \param leftBottom      Storage for one extremity of the box
00036       \param rightTop        Storage for other extremity of the box
00037       \param trans           Optional transformation to be applied to the atom coordinates
00038       \param padding         Padding added on the sides around the conformer
00039     */
00040     void computeConfBox(const Conformer &conf, RDGeom::Point3D &leftBottom, 
00041                          RDGeom::Point3D &rightTop, const RDGeom::Transform3D *trans=0,
00042                         double padding=2.5);
00043 
00044     //! Compute the union of two boxes
00045     void computeUnionBox(const RDGeom::Point3D &leftBottom1, const RDGeom::Point3D &rightTop1, 
00046                          const RDGeom::Point3D &leftBottom2, const RDGeom::Point3D &rightTop2, 
00047                          RDGeom::Point3D &uLeftBottom, RDGeom::Point3D &uRightTop);
00048 
00049     //! Compute dimensions of a conformer
00050     /*!
00051       \param conf     Conformer of interest
00052       \param padding  Padding added to the atom coordinates on all sides
00053       \param center   Optionally specify the center 
00054       \param ignoreHs if true, ignore the hydrogen atoms in computing the centroid
00055     */
00056     std::vector<double> getConfDimensions(const Conformer &conf, double padding=2.5, 
00057                                           const RDGeom::Point3D *center=0, bool ignoreHs=true);
00058 
00059     //! Compute the shape tanimoto distance between two molecule based on a predefined alignment
00060     /*!
00061       \param mol1         The first molecule of interest
00062       \param mol2         The second molecule of interest
00063       \param confId1      Conformer in the first molecule (defaults to first conformer)
00064       \param confId2      Conformer in the second molecule (defaults to first conformer)
00065       \param gridSpacing  resolution of the grid used to encode the molecular shapes
00066       \param bitsPerPoint number of bit used to encode the occupancy at each grid point
00067                           defaults to two bits per grid point
00068       \param vdwScale     Scaling factor for the radius of the atoms to determine the base radius 
00069                           used in the encoding - grid points inside this sphere carry the maximum occupany
00070       \param stepSize     thickness of the each layer outside the base radius, the occupancy value is decreased 
00071                           from layer to layer from the maximum value
00072       \param maxLayers    the maximum number of layers - defaults to the number allowed the number of bits 
00073                           use per grid point - e.g. two bits per grid point will allow 3 layers
00074       \param ignoreHs     if true, ignore the hydrogen atoms in the shape encoding process
00075      */
00076 
00077     double tanimotoDistance(const ROMol &mol1, const ROMol &mol2, int confId1=-1, int confId2=-1,
00078                             double gridSpacing=0.5, 
00079                             DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE, 
00080                             double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1,
00081                             bool ignoreHs=true);
00082 
00083 
00084     //! Compute the shape tanimoto distance between two conformers based on a predefined alignment
00085     /*!
00086       \param conf1        The first conformer of interest
00087       \param conf2        The second conformer of interest
00088       \param gridSpacing  resolution of the grid used to encode the molecular shapes
00089       \param bitsPerPoint number of bit used to encode the occupancy at each grid point
00090       \param vdwScale     Scaling factor for the radius of the atoms to determine the base radius 
00091                           used in the encoding - grid points inside this sphere carry the maximum occupany
00092       \param stepSize     thickness of the each layer outside the base radius, the occupancy value is decreased 
00093                           from layer to layer from the maximum value
00094       \param maxLayers    the maximum number of layers - defaults to the number allowed the number of bits 
00095                           use per grid point - e.g. two bits per grid point will allow 3 layers
00096       \param ignoreHs     if true, ignore the hydrogen atoms in the shape encoding process
00097      */
00098 
00099     double tanimotoDistance(const Conformer &conf1, const Conformer &conf2, double gridSpacing=0.5, 
00100                             DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE,
00101                             double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1, bool ignoreHs=true);
00102 
00103 
00104     //! Compute the shape protrusion distance between two molecule based on a predefined alignment
00105     /*!
00106       \param mol1         The first molecule of interest
00107       \param mol2         The second molecule of interest
00108       \param confId1      Conformer in the first molecule (defaults to first conformer)
00109       \param confId2      Conformer in the second molecule (defaults to first conformer)
00110       \param gridSpacing  resolution of the grid used to encode the molecular shapes
00111       \param bitsPerPoint number of bit used to encode the occupancy at each grid point
00112                           defaults to two bits per grid point
00113       \param vdwScale     Scaling factor for the radius of the atoms to determine the base radius 
00114                           used in the encoding - grid points inside this sphere carry the maximum occupany
00115       \param stepSize     thickness of the each layer outside the base radius, the occupancy value is decreased 
00116                           from layer to layer from the maximum value
00117       \param maxLayers    the maximum number of layers - defaults to the number allowed the number of bits 
00118                           use per grid point - e.g. two bits per grid point will allow 3 layers
00119       \param ignoreHs     if true, ignore the hydrogen atoms in the shape encoding process
00120       \param allowReordering  if set the order will be automatically updated so that the value calculated
00121                               is the protrusion of the smaller shape from the larger one.
00122      */
00123 
00124     double protrudeDistance(const ROMol &mol1, const ROMol &mol2, int confId1=-1, int confId2=-1,
00125                             double gridSpacing=0.5, 
00126                             DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE, 
00127                             double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1,
00128                             bool ignoreHs=true, bool allowReordering=true);
00129 
00130 
00131     //! Compute the shape protrusion distance between two conformers based on a predefined alignment
00132     /*!
00133       \param conf1        The first conformer of interest
00134       \param conf2        The second conformer of interest
00135       \param gridSpacing  resolution of the grid used to encode the molecular shapes
00136       \param bitsPerPoint number of bit used to encode the occupancy at each grid point
00137       \param vdwScale     Scaling factor for the radius of the atoms to determine the base radius 
00138                           used in the encoding - grid points inside this sphere carry the maximum occupany
00139       \param stepSize     thickness of the each layer outside the base radius, the occupancy value is decreased 
00140                           from layer to layer from the maximum value
00141       \param maxLayers    the maximum number of layers - defaults to the number allowed the number of bits 
00142                           use per grid point - e.g. two bits per grid point will allow 3 layers
00143       \param ignoreHs     if true, ignore the hydrogen atoms in the shape encoding process
00144       \param allowReordering  if set the order will be automatically updated so that the value calculated
00145                               is the protrusion of the smaller shape from the larger one.
00146      */
00147 
00148     double protrudeDistance(const Conformer &conf1, const Conformer &conf2, double gridSpacing=0.5, 
00149                             DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE,
00150                             double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1, bool ignoreHs=true,
00151                             bool allowReordering=true);
00152     
00153   }
00154 
00155 }
00156 
00157 #endif