RDKit: ShapeUtils.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
ShapeUtils.h
Go to the documentation of this file.
1//
2// Copyright (C) 2005-2025 Greg Landrum and other RDKit contributors
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#pragma once
11
12#include <RDGeneral/export.h>
13#ifndef RD_SHAPE_UTILS_H_20050128
14#define RD_SHAPE_UTILS_H_20050128
15#include <DataStructs/DiscreteValueVect.h>
16#include <vector>
17
18namespace RDGeom {
19class Point3D;
20class Transform3D;
21} // namespace RDGeom
22
23namespace RDKit {
24class ROMol;
25class Conformer;
26
27namespace MolShapes {
28
29//! Compute the size of the box that can fit the conformation, and offset of the
30/// box from the origin
31 RDKIT_SHAPEHELPERS_EXPORT void computeConfDimsAndOffset(
32 const Conformer &conf, RDGeom::Point3D &dims, RDGeom::Point3D &offSet,
33 const RDGeom::Transform3D *trans = nullptr, double padding = 2.5);
34
35//! Compute the box that will fit the conformer
36/*!
37 \param conf The conformer of interest
38 \param leftBottom Storage for one extremity of the box
39 \param rightTop Storage for other extremity of the box
40 \param trans Optional transformation to be applied to the atom
41 coordinates
42 \param padding Padding added on the sides around the conformer
43*/
44 RDKIT_SHAPEHELPERS_EXPORT void computeConfBox(
45 const Conformer &conf, RDGeom::Point3D &leftBottom,
46 RDGeom::Point3D &rightTop, const RDGeom::Transform3D *trans = nullptr,
47 double padding = 2.5);
48
49//! Compute the union of two boxes
50 RDKIT_SHAPEHELPERS_EXPORT void computeUnionBox(
51 const RDGeom::Point3D &leftBottom1, const RDGeom::Point3D &rightTop1,
52 const RDGeom::Point3D &leftBottom2, const RDGeom::Point3D &rightTop2,
53 RDGeom::Point3D &uLeftBottom, RDGeom::Point3D &uRightTop);
54
55//! Compute dimensions of a conformer
56/*!
57 \param conf Conformer of interest
58 \param padding Padding added to the atom coordinates on all sides
59 \param center Optionally specify the center
60 \param ignoreHs if true, ignore the hydrogen atoms in computing the centroid
61*/
62 RDKIT_SHAPEHELPERS_EXPORT std::vector<double> getConfDimensions(
63 const Conformer &conf, double padding = 2.5,
64 const RDGeom::Point3D *center = nullptr, bool ignoreHs = true);
65
66//! Compute the shape tversky index 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 alpha
72 \param beta
73 \param confId1 Conformer in the first molecule (defaults to first
74 conformer)
75 \param confId2 Conformer in the second molecule (defaults to first
76 conformer)
77 \param gridSpacing resolution of the grid used to encode the molecular shapes
78 \param bitsPerPoint number of bit used to encode the occupancy at each grid
79 point
80 defaults to two bits per grid point
81 \param vdwScale Scaling factor for the radius of the atoms to determine
82 the base radius
83 used in the encoding - grid points inside this sphere
84 carry the maximum occupancy
85 \param stepSize thickness of the each layer outside the base radius, the
86 occupancy value is decreased
87 from layer to layer from the maximum value
88 \param maxLayers the maximum number of layers - defaults to the number
89 allowed the number of bits
90 use per grid point - e.g. two bits per grid point will
91 allow 3 layers
92 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
93 process
94 */
95
96 RDKIT_SHAPEHELPERS_EXPORT double tverskyIndex(
97 const ROMol &mol1, const ROMol &mol2, double alpha, double beta,
98 int confId1 = -1, int confId2 = -1, double gridSpacing = 0.5,
99 DiscreteValueVect::DiscreteValueType bitsPerPoint =
100 DiscreteValueVect::TWOBITVALUE,
101 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
102 bool ignoreHs = true);
103
104//! Compute the shape tversky index between two conformers based on a
105/// predefined alignment
106
107/*!
108 \param conf1 The first conformer of interest
109 \param conf2 The second conformer of interest
110 \param alpha
111 \param beta
112 \param gridSpacing resolution of the grid used to encode the molecular shapes
113 \param bitsPerPoint number of bit used to encode the occupancy at each grid
114 point
115 \param vdwScale Scaling factor for the radius of the atoms to determine
116 the base radius
117 used in the encoding - grid points inside this sphere
118 carry the maximum occupancy
119 \param stepSize thickness of the each layer outside the base radius, the
120 occupancy value is decreased
121 from layer to layer from the maximum value
122 \param maxLayers the maximum number of layers - defaults to the number
123 allowed the number of bits
124 use per grid point - e.g. two bits per grid point will
125 allow 3 layers
126 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
127 process
128 */
129
130 RDKIT_SHAPEHELPERS_EXPORT double tverskyIndex(
131 const Conformer &conf1, const Conformer &conf2, double alpha, double beta,
132 double gridSpacing = 0.5,
133 DiscreteValueVect::DiscreteValueType bitsPerPoint =
134 DiscreteValueVect::TWOBITVALUE,
135 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
136 bool ignoreHs = true);
137
138//! Compute the shape tanimoto distance between two molecule based on a
139/// predefined alignment
140/*!
141 \param mol1 The first molecule of interest
142 \param mol2 The second molecule of interest
143 \param confId1 Conformer in the first molecule (defaults to first
144 conformer)
145 \param confId2 Conformer in the second molecule (defaults to first
146 conformer)
147 \param gridSpacing resolution of the grid used to encode the molecular shapes
148 \param bitsPerPoint number of bit used to encode the occupancy at each grid
149 point
150 defaults to two bits per grid point
151 \param vdwScale Scaling factor for the radius of the atoms to determine
152 the base radius
153 used in the encoding - grid points inside this sphere
154 carry the maximum occupancy
155 \param stepSize thickness of the each layer outside the base radius, the
156 occupancy value is decreased
157 from layer to layer from the maximum value
158 \param maxLayers the maximum number of layers - defaults to the number
159 allowed the number of bits
160 use per grid point - e.g. two bits per grid point will
161 allow 3 layers
162 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
163 process
164 */
165
166 RDKIT_SHAPEHELPERS_EXPORT double tanimotoDistance(
167 const ROMol &mol1, const ROMol &mol2, int confId1 = -1, int confId2 = -1,
168 double gridSpacing = 0.5,
169 DiscreteValueVect::DiscreteValueType bitsPerPoint =
170 DiscreteValueVect::TWOBITVALUE,
171 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
172 bool ignoreHs = true);
173
174//! Compute the shape tanimoto distance between two conformers based on a
175/// predefined alignment
176/*!
177 \param conf1 The first conformer of interest
178 \param conf2 The second conformer of interest
179 \param gridSpacing resolution of the grid used to encode the molecular shapes
180 \param bitsPerPoint number of bit used to encode the occupancy at each grid
181 point
182 \param vdwScale Scaling factor for the radius of the atoms to determine
183 the base radius
184 used in the encoding - grid points inside this sphere
185 carry the maximum occupancy
186 \param stepSize thickness of the each layer outside the base radius, the
187 occupancy value is decreased
188 from layer to layer from the maximum value
189 \param maxLayers the maximum number of layers - defaults to the number
190 allowed the number of bits
191 use per grid point - e.g. two bits per grid point will
192 allow 3 layers
193 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
194 process
195 */
196
197 RDKIT_SHAPEHELPERS_EXPORT double tanimotoDistance(
198 const Conformer &conf1, const Conformer &conf2, double gridSpacing = 0.5,
199 DiscreteValueVect::DiscreteValueType bitsPerPoint =
200 DiscreteValueVect::TWOBITVALUE,
201 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
202 bool ignoreHs = true);
203
204//! Compute the shape protrusion distance between two molecule based on a
205/// predefined alignment
206/*!
207 \param mol1 The first molecule of interest
208 \param mol2 The second molecule of interest
209 \param confId1 Conformer in the first molecule (defaults to first
210 conformer)
211 \param confId2 Conformer in the second molecule (defaults to first
212 conformer)
213 \param gridSpacing resolution of the grid used to encode the molecular shapes
214 \param bitsPerPoint number of bit used to encode the occupancy at each grid
215 point
216 defaults to two bits per grid point
217 \param vdwScale Scaling factor for the radius of the atoms to determine
218 the base radius
219 used in the encoding - grid points inside this sphere
220 carry the maximum occupancy
221 \param stepSize thickness of the each layer outside the base radius, the
222 occupancy value is decreased
223 from layer to layer from the maximum value
224 \param maxLayers the maximum number of layers - defaults to the number
225 allowed the number of bits
226 use per grid point - e.g. two bits per grid point will
227 allow 3 layers
228 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
229 process
230 \param allowReordering if set the order will be automatically updated so that
231 the value calculated
232 is the protrusion of the smaller shape from the larger
233 one.
234 */
235
236 RDKIT_SHAPEHELPERS_EXPORT double protrudeDistance(
237 const ROMol &mol1, const ROMol &mol2, int confId1 = -1, int confId2 = -1,
238 double gridSpacing = 0.5,
239 DiscreteValueVect::DiscreteValueType bitsPerPoint =
240 DiscreteValueVect::TWOBITVALUE,
241 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
242 bool ignoreHs = true, bool allowReordering = true);
243
244//! Compute the shape protrusion distance between two conformers based on a
245/// predefined alignment
246/*!
247 \param conf1 The first conformer of interest
248 \param conf2 The second conformer of interest
249 \param gridSpacing resolution of the grid used to encode the molecular shapes
250 \param bitsPerPoint number of bit used to encode the occupancy at each grid
251 point
252 \param vdwScale Scaling factor for the radius of the atoms to determine
253 the base radius
254 used in the encoding - grid points inside this sphere
255 carry the maximum occupancy
256 \param stepSize thickness of the each layer outside the base radius, the
257 occupancy value is decreased
258 from layer to layer from the maximum value
259 \param maxLayers the maximum number of layers - defaults to the number
260 allowed the number of bits
261 use per grid point - e.g. two bits per grid point will
262 allow 3 layers
263 \param ignoreHs if true, ignore the hydrogen atoms in the shape encoding
264 process
265 \param allowReordering if set the order will be automatically updated so that
266 the value calculated
267 is the protrusion of the smaller shape from the larger
268 one.
269 */
270
271 RDKIT_SHAPEHELPERS_EXPORT double protrudeDistance(
272 const Conformer &conf1, const Conformer &conf2, double gridSpacing = 0.5,
273 DiscreteValueVect::DiscreteValueType bitsPerPoint =
274 DiscreteValueVect::TWOBITVALUE,
275 double vdwScale = 0.8, double stepSize = 0.25, int maxLayers = -1,
276 bool ignoreHs = true, bool allowReordering = true);
277} // namespace MolShapes
278} // namespace RDKit
279
280#endif
DiscreteValueVect.h
RDGeom::Point3D
Definition point.h:53
RDGeom::Transform3D
Definition Transform3D.h:23
RDKit::Conformer
The class for representing 2D or 3D conformation of a molecule.
Definition Conformer.h:46
RDKit::DiscreteValueVect::DiscreteValueType
DiscreteValueType
used to define the possible range of the values
Definition DiscreteValueVect.h:29
RDKit::DiscreteValueVect::TWOBITVALUE
@ TWOBITVALUE
Definition DiscreteValueVect.h:31
RDKit::ROMol
Definition ROMol.h:199
export.h
RDKIT_SHAPEHELPERS_EXPORT
#define RDKIT_SHAPEHELPERS_EXPORT
Definition export.h:521
RDGeom
Definition TorsionAngleContribs.h:17
RDKit::MolShapes
Definition ShapeEncoder.h:23
RDKit::MolShapes::computeConfBox
RDKIT_SHAPEHELPERS_EXPORT void computeConfBox(const Conformer &conf, RDGeom::Point3D &leftBottom, RDGeom::Point3D &rightTop, const RDGeom::Transform3D *trans=nullptr, double padding=2.5)
Compute the box that will fit the conformer.
RDKit::MolShapes::getConfDimensions
RDKIT_SHAPEHELPERS_EXPORT std::vector< double > getConfDimensions(const Conformer &conf, double padding=2.5, const RDGeom::Point3D *center=nullptr, bool ignoreHs=true)
Compute dimensions of a conformer.
RDKit::MolShapes::tverskyIndex
RDKIT_SHAPEHELPERS_EXPORT double tverskyIndex(const ROMol &mol1, const ROMol &mol2, double alpha, double beta, int confId1=-1, int confId2=-1, double gridSpacing=0.5, DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE, double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1, bool ignoreHs=true)
RDKit::MolShapes::tanimotoDistance
RDKIT_SHAPEHELPERS_EXPORT double tanimotoDistance(const ROMol &mol1, const ROMol &mol2, int confId1=-1, int confId2=-1, double gridSpacing=0.5, DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE, double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1, bool ignoreHs=true)
RDKit::MolShapes::computeUnionBox
RDKIT_SHAPEHELPERS_EXPORT 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.
RDKit::MolShapes::computeConfDimsAndOffset
RDKIT_SHAPEHELPERS_EXPORT void computeConfDimsAndOffset(const Conformer &conf, RDGeom::Point3D &dims, RDGeom::Point3D &offSet, const RDGeom::Transform3D *trans=nullptr, double padding=2.5)
RDKit::MolShapes::protrudeDistance
RDKIT_SHAPEHELPERS_EXPORT double protrudeDistance(const ROMol &mol1, const ROMol &mol2, int confId1=-1, int confId2=-1, double gridSpacing=0.5, DiscreteValueVect::DiscreteValueType bitsPerPoint=DiscreteValueVect::TWOBITVALUE, double vdwScale=0.8, double stepSize=0.25, int maxLayers=-1, bool ignoreHs=true, bool allowReordering=true)
RDKit
Std stuff.
Definition Abbreviations.h:19