RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
ChiralViolationContrib.h
Go to the documentation of this file.
1//
2// Created by Santosh Putta, Nov 2006
3//
4#include <RDGeneral/export.h>
5#ifndef __RD_CHIRALVIOLATIONCONTRIB_H__
6#define __RD_CHIRALVIOLATIONCONTRIB_H__
7
9#include <Geometry/point.h>
10
11namespace DistGeom {
12class ChiralSet;
13
14//! DEPRECATED: use ChiralViolationContribs instead
15//! A term to capture the violation of chirality at an atom center
16//!
19 public:
21
22 //! Constructor
23 /*!
24 \param owner pointer to the owning forcefield
25 \param cset a chiral set containing the four chiral atom ids (in
26 sequence)
27 and the upper and lower limits on the signed chiral volume
28 \param weight (optional) the weight to be used for this contrib
29
30 */
32 double weight = 1.0);
33
34 //! return the contribution of this contrib to the energy of a given state
35 double getEnergy(double *pos) const override;
36
37 //! calculate the contribution of this contrib to the gradient at a given
38 /// state
39 void getGrad(double *pos, double *grad) const override;
40 ChiralViolationContrib *copy() const override {
41 return new ChiralViolationContrib(*this);
42 }
43
44 static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
45 unsigned int idx3, unsigned int idx4,
46 const double *pos, unsigned int dim) {
47 // even if we are minimizing in higher dimension the chiral volume is
48 // calculated using only the first 3 dimensions
49 RDGeom::Point3D v1(pos[idx1 * dim] - pos[idx4 * dim],
50 pos[idx1 * dim + 1] - pos[idx4 * dim + 1],
51 pos[idx1 * dim + 2] - pos[idx4 * dim + 2]);
52
53 RDGeom::Point3D v2(pos[idx2 * dim] - pos[idx4 * dim],
54 pos[idx2 * dim + 1] - pos[idx4 * dim + 1],
55 pos[idx2 * dim + 2] - pos[idx4 * dim + 2]);
56
57 RDGeom::Point3D v3(pos[idx3 * dim] - pos[idx4 * dim],
58 pos[idx3 * dim + 1] - pos[idx4 * dim + 1],
59 pos[idx3 * dim + 2] - pos[idx4 * dim + 2]);
60
61 RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
62
63 double vol = v1.dotProduct(v2xv3);
64 return vol;
65 }
66 static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
67 unsigned int idx3, unsigned int idx4,
68 const RDGeom::PointPtrVect &pts) {
69 // even if we are minimizing in higher dimension the chiral volume is
70 // calculated using only the first 3 dimensions
71 RDGeom::Point3D v1((*pts[idx1])[0] - (*pts[idx4])[0],
72 (*pts[idx1])[1] - (*pts[idx4])[1],
73 (*pts[idx1])[2] - (*pts[idx4])[2]);
74
75 RDGeom::Point3D v2((*pts[idx2])[0] - (*pts[idx4])[0],
76 (*pts[idx2])[1] - (*pts[idx4])[1],
77 (*pts[idx2])[2] - (*pts[idx4])[2]);
78
79 RDGeom::Point3D v3((*pts[idx3])[0] - (*pts[idx4])[0],
80 (*pts[idx3])[1] - (*pts[idx4])[1],
81 (*pts[idx3])[2] - (*pts[idx4])[2]);
82
83 RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
84
85 double vol = v1.dotProduct(v2xv3);
86 return vol;
87 }
88
89 private:
90 unsigned int d_idx1{0}, d_idx2{0}, d_idx3{0}, d_idx4{0};
91 double d_volLower{0.0};
92 double d_volUpper{0.0};
93 double d_weight{0.0};
94};
95} // namespace DistGeom
96
97#endif
Class used to store a quartet of points and chiral volume bounds on them.
Definition ChiralSet.h:29
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
static double calcChiralVolume(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, const RDGeom::PointPtrVect &pts)
ChiralViolationContrib * copy() const override
return a copy
static double calcChiralVolume(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, const double *pos, unsigned int dim)
ChiralViolationContrib(ForceFields::ForceField *owner, const ChiralSet *cset, double weight=1.0)
Constructor.
void getGrad(double *pos, double *grad) const override
abstract base class for contributions to ForceFields
Definition Contrib.h:18
A class to store forcefields and handle minimization.
Definition ForceField.h:79
double dotProduct(const Point3D &other) const
Definition point.h:164
Point3D crossProduct(const Point3D &other) const
Cross product of this point with the another point.
Definition point.h:223
#define RDKIT_DISTGEOMETRY_EXPORT
Definition export.h:129
std::vector< RDGeom::Point * > PointPtrVect
Definition point.h:542