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