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//! A term to capture the violation of chirality at an atom center
15//!
18 public:
20
21 //! Constructor
22 /*!
23 \param owner pointer to the owning forcefield
24 \param cset a chiral set containing the four chiral atom ids (in
25 sequence)
26 and the upper and lower limits on the signed chiral volume
27 \param weight (optional) the weight to be used for this contrib
28
29 */
31 double weight = 1.0);
32
33 //! return the contribution of this contrib to the energy of a given state
34 double getEnergy(double *pos) const override;
35
36 //! calculate the contribution of this contrib to the gradient at a given
37 /// state
38 void getGrad(double *pos, double *grad) const override;
39 ChiralViolationContrib *copy() const override {
40 return new ChiralViolationContrib(*this);
41 }
42
43 static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
44 unsigned int idx3, unsigned int idx4,
45 const double *pos, unsigned int dim) {
46 // even if we are minimizing in higher dimension the chiral volume is
47 // calculated using only the first 3 dimensions
48 RDGeom::Point3D v1(pos[idx1 * dim] - pos[idx4 * dim],
49 pos[idx1 * dim + 1] - pos[idx4 * dim + 1],
50 pos[idx1 * dim + 2] - pos[idx4 * dim + 2]);
51
52 RDGeom::Point3D v2(pos[idx2 * dim] - pos[idx4 * dim],
53 pos[idx2 * dim + 1] - pos[idx4 * dim + 1],
54 pos[idx2 * dim + 2] - pos[idx4 * dim + 2]);
55
56 RDGeom::Point3D v3(pos[idx3 * dim] - pos[idx4 * dim],
57 pos[idx3 * dim + 1] - pos[idx4 * dim + 1],
58 pos[idx3 * dim + 2] - pos[idx4 * dim + 2]);
59
60 RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
61
62 double vol = v1.dotProduct(v2xv3);
63 return vol;
64 }
65 static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
66 unsigned int idx3, unsigned int idx4,
67 const RDGeom::PointPtrVect &pts) {
68 // even if we are minimizing in higher dimension the chiral volume is
69 // calculated using only the first 3 dimensions
70 RDGeom::Point3D v1((*pts[idx1])[0] - (*pts[idx4])[0],
71 (*pts[idx1])[1] - (*pts[idx4])[1],
72 (*pts[idx1])[2] - (*pts[idx4])[2]);
73
74 RDGeom::Point3D v2((*pts[idx2])[0] - (*pts[idx4])[0],
75 (*pts[idx2])[1] - (*pts[idx4])[1],
76 (*pts[idx2])[2] - (*pts[idx4])[2]);
77
78 RDGeom::Point3D v3((*pts[idx3])[0] - (*pts[idx4])[0],
79 (*pts[idx3])[1] - (*pts[idx4])[1],
80 (*pts[idx3])[2] - (*pts[idx4])[2]);
81
82 RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
83
84 double vol = v1.dotProduct(v2xv3);
85 return vol;
86 }
87
88 private:
89 unsigned int d_idx1{0}, d_idx2{0}, d_idx3{0}, d_idx4{0};
90 double d_volLower{0.0};
91 double d_volUpper{0.0};
92 double d_weight{0.0};
93};
94} // namespace DistGeom
95
96#endif
Class used to store a quartet of points and chiral volume bounds on them.
Definition ChiralSet.h:24
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:158
Point3D crossProduct(const Point3D &other) const
Cross product of this point with the another point.
Definition point.h:217
#define RDKIT_DISTGEOMETRY_EXPORT
Definition export.h:129
std::vector< RDGeom::Point * > PointPtrVect
Definition point.h:531