RDKit
Open-source cheminformatics and machine learning.
ShapeUtils.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-2006 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_SHAPE_UTILS_H_20050128_
11 #define _RD_SHAPE_UTILS_H_20050128_
13 #include <vector>
14 
15 namespace RDGeom {
16 class Point3D;
17 class Transform3D;
18 }
19 
20 namespace RDKit {
21 class ROMol;
22 class Conformer;
23 
24 namespace MolShapes {
25 
26 //! Compute the size of the box that can fit the conformation, and offset of the
27 // box
28 //! from the origin
29 void computeConfDimsAndOffset(const Conformer &conf, RDGeom::Point3D &dims,
30  RDGeom::Point3D &offSet,
31  const RDGeom::Transform3D *trans = 0,
32  double padding = 2.5);
33 
34 //! Compute the a box that will fit the confomer
35 /*!
36  \param conf The conformer of interest
37  \param leftBottom Storage for one extremity of the box
38  \param rightTop Storage for other extremity of the box
39  \param trans Optional transformation to be applied to the atom
40  coordinates
41  \param padding Padding added on the sides around the conformer
42 */
43 void computeConfBox(const Conformer &conf, RDGeom::Point3D &leftBottom,
44  RDGeom::Point3D &rightTop,
45  const RDGeom::Transform3D *trans = 0, double padding = 2.5);
46 
47 //! Compute the union of two boxes
48 void computeUnionBox(const RDGeom::Point3D &leftBottom1,
49  const RDGeom::Point3D &rightTop1,
50  const RDGeom::Point3D &leftBottom2,
51  const RDGeom::Point3D &rightTop2,
52  RDGeom::Point3D &uLeftBottom, RDGeom::Point3D &uRightTop);
53 
54 //! Compute dimensions of a conformer
55 /*!
56  \param conf Conformer of interest
57  \param padding Padding added to the atom coordinates on all sides
58  \param center Optionally specify the center
59  \param ignoreHs if true, ignore the hydrogen atoms in computing the centroid
60 */
61 std::vector<double> getConfDimensions(const Conformer &conf,
62  double padding = 2.5,
63  const RDGeom::Point3D *center = 0,
64  bool ignoreHs = true);
65 
66 //! Compute the shape tanimoto distance between two molecule based on a
67 // predefined alignment
68 /*!
69  \param mol1 The first molecule of interest
70  \param mol2 The second molecule of interest
71  \param confId1 Conformer in the first molecule (defaults to first
72  conformer)
73  \param confId2 Conformer in the second molecule (defaults to first
74  conformer)
75  \param gridSpacing resolution of the grid used to encode the molecular shapes
76  \param bitsPerPoint number of bit used to encode the occupancy at each grid
77  point
78  defaults to two bits per grid point
79  \param vdwScale Scaling factor for the radius of the atoms to determine
80  the base radius
81  used in the encoding - grid points inside this sphere
82  carry the maximum occupany
83  \param stepSize thickness of the each layer outside the base radius, the
84  occupancy value is decreased
85  from layer to layer from the maximum value
86  \param maxLayers the maximum number of layers - defaults to the number
87  allowed the number of bits
88  use per grid point - e.g. two bits per grid point will
89  allow 3 layers
90  \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
91  process
92  */
93 
94 double tanimotoDistance(const ROMol &mol1, const ROMol &mol2, int confId1 = -1,
95  int confId2 = -1, double gridSpacing = 0.5,
96  DiscreteValueVect::DiscreteValueType bitsPerPoint =
97  DiscreteValueVect::TWOBITVALUE,
98  double vdwScale = 0.8, double stepSize = 0.25,
99  int maxLayers = -1, bool ignoreHs = true);
100 
101 //! Compute the shape tanimoto distance between two conformers based on a
102 // predefined alignment
103 /*!
104  \param conf1 The first conformer of interest
105  \param conf2 The second conformer of interest
106  \param gridSpacing resolution of the grid used to encode the molecular shapes
107  \param bitsPerPoint number of bit used to encode the occupancy at each grid
108  point
109  \param vdwScale Scaling factor for the radius of the atoms to determine
110  the base radius
111  used in the encoding - grid points inside this sphere
112  carry the maximum occupany
113  \param stepSize thickness of the each layer outside the base radius, the
114  occupancy value is decreased
115  from layer to layer from the maximum value
116  \param maxLayers the maximum number of layers - defaults to the number
117  allowed the number of bits
118  use per grid point - e.g. two bits per grid point will
119  allow 3 layers
120  \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
121  process
122  */
123 
124 double tanimotoDistance(const Conformer &conf1, const Conformer &conf2,
125  double gridSpacing = 0.5,
126  DiscreteValueVect::DiscreteValueType bitsPerPoint =
127  DiscreteValueVect::TWOBITVALUE,
128  double vdwScale = 0.8, double stepSize = 0.25,
129  int maxLayers = -1, bool ignoreHs = true);
130 
131 //! Compute the shape protrusion distance between two molecule based on a
132 // predefined alignment
133 /*!
134  \param mol1 The first molecule of interest
135  \param mol2 The second molecule of interest
136  \param confId1 Conformer in the first molecule (defaults to first
137  conformer)
138  \param confId2 Conformer in the second molecule (defaults to first
139  conformer)
140  \param gridSpacing resolution of the grid used to encode the molecular shapes
141  \param bitsPerPoint number of bit used to encode the occupancy at each grid
142  point
143  defaults to two bits per grid point
144  \param vdwScale Scaling factor for the radius of the atoms to determine
145  the base radius
146  used in the encoding - grid points inside this sphere
147  carry the maximum occupany
148  \param stepSize thickness of the each layer outside the base radius, the
149  occupancy value is decreased
150  from layer to layer from the maximum value
151  \param maxLayers the maximum number of layers - defaults to the number
152  allowed the number of bits
153  use per grid point - e.g. two bits per grid point will
154  allow 3 layers
155  \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
156  process
157  \param allowReordering if set the order will be automatically updated so that
158  the value calculated
159  is the protrusion of the smaller shape from the larger
160  one.
161  */
162 
163 double protrudeDistance(const ROMol &mol1, const ROMol &mol2, int confId1 = -1,
164  int confId2 = -1, double gridSpacing = 0.5,
165  DiscreteValueVect::DiscreteValueType bitsPerPoint =
166  DiscreteValueVect::TWOBITVALUE,
167  double vdwScale = 0.8, double stepSize = 0.25,
168  int maxLayers = -1, bool ignoreHs = true,
169  bool allowReordering = true);
170 
171 //! Compute the shape protrusion distance between two conformers based on a
172 // predefined alignment
173 /*!
174  \param conf1 The first conformer of interest
175  \param conf2 The second conformer of interest
176  \param gridSpacing resolution of the grid used to encode the molecular shapes
177  \param bitsPerPoint number of bit used to encode the occupancy at each grid
178  point
179  \param vdwScale Scaling factor for the radius of the atoms to determine
180  the base radius
181  used in the encoding - grid points inside this sphere
182  carry the maximum occupany
183  \param stepSize thickness of the each layer outside the base radius, the
184  occupancy value is decreased
185  from layer to layer from the maximum value
186  \param maxLayers the maximum number of layers - defaults to the number
187  allowed the number of bits
188  use per grid point - e.g. two bits per grid point will
189  allow 3 layers
190  \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
191  process
192  \param allowReordering if set the order will be automatically updated so that
193  the value calculated
194  is the protrusion of the smaller shape from the larger
195  one.
196  */
197 
198 double protrudeDistance(const Conformer &conf1, const Conformer &conf2,
199  double gridSpacing = 0.5,
200  DiscreteValueVect::DiscreteValueType bitsPerPoint =
201  DiscreteValueVect::TWOBITVALUE,
202  double vdwScale = 0.8, double stepSize = 0.25,
203  int maxLayers = -1, bool ignoreHs = true,
204  bool allowReordering = true);
205 }
206 }
207 
208 #endif
void computeUnionBox(const RDGeom::Point3D &leftBottom1, const RDGeom::Point3D &rightTop1, const RDGeom::Point3D &leftBottom2, const RDGeom::Point3D &rightTop2, RDGeom::Point3D &uLeftBottom, RDGeom::Point3D &uRightTop)
Compute the union of two boxes.
std::vector< double > getConfDimensions(const Conformer &conf, double padding=2.5, const RDGeom::Point3D *center=0, bool ignoreHs=true)
Compute dimensions of a conformer.
void computeConfBox(const Conformer &conf, RDGeom::Point3D &leftBottom, RDGeom::Point3D &rightTop, const RDGeom::Transform3D *trans=0, double padding=2.5)
Compute the a box that will fit the confomer.
double tanimotoDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2)
calculate the tanimoto distance between the shapes encoded on two grids
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29
void computeConfDimsAndOffset(const Conformer &conf, RDGeom::Point3D &dims, RDGeom::Point3D &offSet, const RDGeom::Transform3D *trans=0, double padding=2.5)
Compute the size of the box that can fit the conformation, and offset of the.
double protrudeDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2)
calculate the protrude distance between the shapes encoded on two grids