RDKit: ChiralViolationContrib.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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