RDKit: ChiralViolationContribs.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
ChiralViolationContribs.h
Go to the documentation of this file.
1//
2// Copyright (C) 2024 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#include <RDGeneral/export.h>
11#ifndef RD_CHIRALVIOLATIONCONTRIBS_H
12#define RD_CHIRALVIOLATIONCONTRIBS_H
13
14#include <vector>
15#include <ForceField/Contrib.h>
16#include <Geometry/point.h>
17
18namespace DistGeom {
19class ChiralSet;
20
21 RDKIT_DISTGEOMETRY_EXPORT double calcChiralVolume(
22 const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
23 const unsigned int idx4, const double *pos, const unsigned int dim);
24 RDKIT_DISTGEOMETRY_EXPORT double calcChiralVolume(
25 const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
26 const unsigned int idx4, const RDGeom::PointPtrVect &pts);
27
28 struct ChiralViolationContribsParams {
29 unsigned int idx1{0}, idx2{0}, idx3{0}, idx4{0};
30 double volUpper{0.0};
31 double volLower{0.0};
32 double weight{1.0};
33 ChiralViolationContribsParams(unsigned int i1, unsigned int i2,
34 unsigned int i3, unsigned int i4, double u,
35 double l, double w = 1.0)
36 : idx1(i1),
37 idx2(i2),
38 idx3(i3),
39 idx4(i4),
40 volUpper(u),
41 volLower(l),
42 weight(w) {};
43};
44//! A term to capture the violation of chirality at atom centers
45//!
46 class RDKIT_DISTGEOMETRY_EXPORT ChiralViolationContribs
47 : public ForceFields::ForceFieldContrib {
48 public:
49 ChiralViolationContribs() = default;
50
51 //! Constructor
52 /*!
53 \param owner pointer to the owning forcefield
54 \param cset a chiral set containing the four chiral atom ids (in
55 sequence)
56 and the upper and lower limits on the signed chiral
57 volume \param weight (optional) the weight to be used for this contrib
58
59 */
60 ChiralViolationContribs(ForceFields::ForceField *owner);
61
62 //! adds a new chiral constraint
63 /*!
64 \param cset a chiral set containing the four chiral atom ids (in
65 sequence)
66 and the upper and lower limits on the signed chiral
67 volume \param weight (optional) the weight to be used for this contrib
68
69 */
70 void addContrib(const ChiralSet *cset, double weight = 1.0);
71
72 //! return the contribution of this contrib to the energy of a given state
73 double getEnergy(double *pos) const override;
74
75 //! calculate the contribution of this contrib to the gradient at a given
76 /// state
77 void getGrad(double *pos, double *grad) const override;
78 ChiralViolationContribs *copy() const override {
79 return new ChiralViolationContribs(*this);
80 }
81 bool empty() const { return d_contribs.empty(); }
82 unsigned int size() const { return d_contribs.size(); }
83
84 private:
85 std::vector<ChiralViolationContribsParams> d_contribs;
86};
87} // namespace DistGeom
88
89#endif
Contrib.h
DistGeom::ChiralSet
Class used to store a quartet of points and chiral volume bounds on them.
Definition ChiralSet.h:29
DistGeom::ChiralViolationContribs::copy
ChiralViolationContribs * copy() const override
return a copy
Definition ChiralViolationContribs.h:78
DistGeom::ChiralViolationContribs::empty
bool empty() const
Definition ChiralViolationContribs.h:81
DistGeom::ChiralViolationContribs::ChiralViolationContribs
ChiralViolationContribs()=default
DistGeom::ChiralViolationContribs::size
unsigned int size() const
Definition ChiralViolationContribs.h:82
DistGeom::ChiralViolationContribs::ChiralViolationContribs
ChiralViolationContribs(ForceFields::ForceField *owner)
Constructor.
DistGeom::ChiralViolationContribs::getGrad
void getGrad(double *pos, double *grad) const override
DistGeom::ChiralViolationContribs::getEnergy
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
DistGeom::ChiralViolationContribs::addContrib
void addContrib(const ChiralSet *cset, double weight=1.0)
adds a new chiral constraint
ForceFields::ForceFieldContrib
abstract base class for contributions to ForceFields
Definition Contrib.h:18
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition ForceField.h:79
export.h
RDKIT_DISTGEOMETRY_EXPORT
#define RDKIT_DISTGEOMETRY_EXPORT
Definition export.h:137
DistGeom
Definition BoundsMatrix.h:19
DistGeom::calcChiralVolume
RDKIT_DISTGEOMETRY_EXPORT double calcChiralVolume(const unsigned int idx1, const unsigned int idx2, const unsigned int idx3, const unsigned int idx4, const double *pos, const unsigned int dim)
RDGeom::PointPtrVect
std::vector< RDGeom::Point * > PointPtrVect
Definition point.h:537
point.h
DistGeom::ChiralViolationContribsParams::weight
double weight
Definition ChiralViolationContribs.h:32
DistGeom::ChiralViolationContribsParams::volUpper
double volUpper
Definition ChiralViolationContribs.h:30
DistGeom::ChiralViolationContribsParams::idx1
unsigned int idx1
Definition ChiralViolationContribs.h:29
DistGeom::ChiralViolationContribsParams::ChiralViolationContribsParams
ChiralViolationContribsParams(unsigned int i1, unsigned int i2, unsigned int i3, unsigned int i4, double u, double l, double w=1.0)
Definition ChiralViolationContribs.h:33
DistGeom::ChiralViolationContribsParams::idx4
unsigned int idx4
Definition ChiralViolationContribs.h:29
DistGeom::ChiralViolationContribsParams::idx2
unsigned int idx2
Definition ChiralViolationContribs.h:29
DistGeom::ChiralViolationContribsParams::volLower
double volLower
Definition ChiralViolationContribs.h:31
DistGeom::ChiralViolationContribsParams::idx3
unsigned int idx3
Definition ChiralViolationContribs.h:29