Do the announced deprecations (#7910)

* remove MMFF:setMMFFAromaticity()

* remove AtomPairs.Utils.NumPiElectrons()

* remove the deprecated DistGeom contrib files

* document removed stuff
This commit is contained in:
Greg Landrum
2024-10-11 06:42:18 +02:00
committed by GitHub
parent 875596eb12
commit a7404cdd91
13 changed files with 36 additions and 473 deletions

View File

@@ -2,19 +2,16 @@
### to avoid a target name clash in ./Wrap
rdkit_library(DistGeometry
DistGeomUtils.cpp TriangleSmooth.cpp DistViolationContrib.cpp DistViolationContribs.cpp
ChiralViolationContrib.cpp ChiralViolationContribs.cpp
DistGeomUtils.cpp TriangleSmooth.cpp DistViolationContribs.cpp
ChiralViolationContribs.cpp
LINK_LIBRARIES EigenSolvers ForceField ForceFieldHelpers)
target_compile_definitions(DistGeometry PRIVATE RDKIT_DISTGEOMETRY_BUILD)
rdkit_headers(BoundsMatrix.h
ChiralSet.h
ChiralViolationContrib.h
ChiralViolationContribs.h
DistGeomUtils.h
DistViolationContrib.h
DistViolationContribs.h
FourthDimContrib.h
FourthDimContribs.h
TriangleSmooth.h DEST DistGeom)

View File

@@ -1,122 +0,0 @@
// $Id$
//
// Created by Santosh Putta, Nov 2006
//
#include "ChiralViolationContrib.h"
#include "ChiralSet.h"
#include <ForceField/ForceField.h>
namespace DistGeom {
ChiralViolationContrib::ChiralViolationContrib(ForceFields::ForceField *owner,
const ChiralSet *cset,
double weight) {
PRECONDITION(owner, "bad owner");
PRECONDITION(cset, "bad chiral set")
URANGE_CHECK(cset->d_idx1, owner->positions().size());
URANGE_CHECK(cset->d_idx2, owner->positions().size());
URANGE_CHECK(cset->d_idx3, owner->positions().size());
URANGE_CHECK(cset->d_idx4, owner->positions().size());
dp_forceField = owner;
d_idx1 = cset->d_idx1;
d_idx2 = cset->d_idx2;
d_idx3 = cset->d_idx3;
d_idx4 = cset->d_idx4;
d_volLower = cset->getLowerVolumeBound();
d_volUpper = cset->getUpperVolumeBound();
d_weight = weight;
}
double ChiralViolationContrib::getEnergy(double *pos) const {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(pos, "bad vector");
unsigned int dim = dp_forceField->dimension();
double vol = calcChiralVolume(d_idx1, d_idx2, d_idx3, d_idx4, pos, dim);
double res = 0.0;
if (vol < d_volLower) {
res = d_weight * (vol - d_volLower) * (vol - d_volLower);
} else if (vol > d_volUpper) {
res = d_weight * (vol - d_volUpper) * (vol - d_volUpper);
}
// std::cerr<<"Chiral Violation vol: "<<vol<<" E: "<<res<<std::endl;
return res;
}
void ChiralViolationContrib::getGrad(double *pos, double *grad) const {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(pos, "bad vector");
unsigned int dim = dp_forceField->dimension();
// even if we are minimizing in higher dimension the chiral volume is
// calculated using only the first 3 dimensions
RDGeom::Point3D v1(pos[d_idx1 * dim] - pos[d_idx4 * dim],
pos[d_idx1 * dim + 1] - pos[d_idx4 * dim + 1],
pos[d_idx1 * dim + 2] - pos[d_idx4 * dim + 2]);
RDGeom::Point3D v2(pos[d_idx2 * dim] - pos[d_idx4 * dim],
pos[d_idx2 * dim + 1] - pos[d_idx4 * dim + 1],
pos[d_idx2 * dim + 2] - pos[d_idx4 * dim + 2]);
RDGeom::Point3D v3(pos[d_idx3 * dim] - pos[d_idx4 * dim],
pos[d_idx3 * dim + 1] - pos[d_idx4 * dim + 1],
pos[d_idx3 * dim + 2] - pos[d_idx4 * dim + 2]);
RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
double vol = v1.dotProduct(v2xv3);
double preFactor;
// std::cerr << "Chiral Violation grad: " << " " << vol << " "
// << "idxs: " << d_idx1 << " " << d_idx2 << " " << d_idx3 << " "
// << d_idx4 << " " << d_volLower << " - " << d_volUpper <<
// std::endl;
if (vol < d_volLower) {
preFactor = d_weight * (vol - d_volLower);
} else if (vol > d_volUpper) {
preFactor = d_weight * (vol - d_volUpper);
} else {
return;
}
// now comes the hard part - there are a total of 12 variables involved
// 4 x 3 - four points and 3 dimensions
//
grad[dim * d_idx1] += preFactor * ((v2.y) * (v3.z) - (v3.y) * (v2.z));
grad[dim * d_idx1 + 1] += preFactor * ((v3.x) * (v2.z) - (v2.x) * (v3.z));
grad[dim * d_idx1 + 2] += preFactor * ((v2.x) * (v3.y) - (v3.x) * (v2.y));
grad[dim * d_idx2] += preFactor * ((v3.y) * (v1.z) - (v3.z) * (v1.y));
grad[dim * d_idx2 + 1] += preFactor * ((v3.z) * (v1.x) - (v3.x) * (v1.z));
grad[dim * d_idx2 + 2] += preFactor * ((v3.x) * (v1.y) - (v3.y) * (v1.x));
grad[dim * d_idx3] += preFactor * ((v2.z) * (v1.y) - (v2.y) * (v1.z));
grad[dim * d_idx3 + 1] += preFactor * ((v2.x) * (v1.z) - (v2.z) * (v1.x));
grad[dim * d_idx3 + 2] += preFactor * ((v2.y) * (v1.x) - (v2.x) * (v1.y));
grad[dim * d_idx4] +=
preFactor *
(pos[d_idx1 * dim + 2] * (pos[d_idx2 * dim + 1] - pos[d_idx3 * dim + 1]) +
pos[d_idx2 * dim + 2] * (pos[d_idx3 * dim + 1] - pos[d_idx1 * dim + 1]) +
pos[d_idx3 * dim + 2] * (pos[d_idx1 * dim + 1] - pos[d_idx2 * dim + 1]));
grad[dim * d_idx4 + 1] +=
preFactor *
(pos[d_idx1 * dim] * (pos[d_idx2 * dim + 2] - pos[d_idx3 * dim + 2]) +
pos[d_idx2 * dim] * (pos[d_idx3 * dim + 2] - pos[d_idx1 * dim + 2]) +
pos[d_idx3 * dim] * (pos[d_idx1 * dim + 2] - pos[d_idx2 * dim + 2]));
grad[dim * d_idx4 + 2] +=
preFactor *
(pos[d_idx1 * dim + 1] * (pos[d_idx2 * dim] - pos[d_idx3 * dim]) +
pos[d_idx2 * dim + 1] * (pos[d_idx3 * dim] - pos[d_idx1 * dim]) +
pos[d_idx3 * dim + 1] * (pos[d_idx1 * dim] - pos[d_idx2 * dim]));
// std::cerr << " " << preFactor << std::endl;
}
} // namespace DistGeom

View File

@@ -1,97 +0,0 @@
//
// Created by Santosh Putta, Nov 2006
//
#include <RDGeneral/export.h>
#ifndef __RD_CHIRALVIOLATIONCONTRIB_H__
#define __RD_CHIRALVIOLATIONCONTRIB_H__
#include <ForceField/Contrib.h>
#include <Geometry/point.h>
namespace DistGeom {
class ChiralSet;
//! DEPRECATED: use ChiralViolationContribs instead
//! A term to capture the violation of chirality at an atom center
//!
class RDKIT_DISTGEOMETRY_EXPORT ChiralViolationContrib
: public ForceFields::ForceFieldContrib {
public:
ChiralViolationContrib() {}
//! Constructor
/*!
\param owner pointer to the owning forcefield
\param cset a chiral set containing the four chiral atom ids (in
sequence)
and the upper and lower limits on the signed chiral volume
\param weight (optional) the weight to be used for this contrib
*/
ChiralViolationContrib(ForceFields::ForceField *owner, const ChiralSet *cset,
double weight = 1.0);
//! return the contribution of this contrib to the energy of a given state
double getEnergy(double *pos) const override;
//! calculate the contribution of this contrib to the gradient at a given
/// state
void getGrad(double *pos, double *grad) const override;
ChiralViolationContrib *copy() const override {
return new ChiralViolationContrib(*this);
}
static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
unsigned int idx3, unsigned int idx4,
const double *pos, unsigned int dim) {
// even if we are minimizing in higher dimension the chiral volume is
// calculated using only the first 3 dimensions
RDGeom::Point3D v1(pos[idx1 * dim] - pos[idx4 * dim],
pos[idx1 * dim + 1] - pos[idx4 * dim + 1],
pos[idx1 * dim + 2] - pos[idx4 * dim + 2]);
RDGeom::Point3D v2(pos[idx2 * dim] - pos[idx4 * dim],
pos[idx2 * dim + 1] - pos[idx4 * dim + 1],
pos[idx2 * dim + 2] - pos[idx4 * dim + 2]);
RDGeom::Point3D v3(pos[idx3 * dim] - pos[idx4 * dim],
pos[idx3 * dim + 1] - pos[idx4 * dim + 1],
pos[idx3 * dim + 2] - pos[idx4 * dim + 2]);
RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
double vol = v1.dotProduct(v2xv3);
return vol;
}
static double calcChiralVolume(unsigned int idx1, unsigned int idx2,
unsigned int idx3, unsigned int idx4,
const RDGeom::PointPtrVect &pts) {
// even if we are minimizing in higher dimension the chiral volume is
// calculated using only the first 3 dimensions
RDGeom::Point3D v1((*pts[idx1])[0] - (*pts[idx4])[0],
(*pts[idx1])[1] - (*pts[idx4])[1],
(*pts[idx1])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v2((*pts[idx2])[0] - (*pts[idx4])[0],
(*pts[idx2])[1] - (*pts[idx4])[1],
(*pts[idx2])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v3((*pts[idx3])[0] - (*pts[idx4])[0],
(*pts[idx3])[1] - (*pts[idx4])[1],
(*pts[idx3])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
double vol = v1.dotProduct(v2xv3);
return vol;
}
private:
unsigned int d_idx1{0}, d_idx2{0}, d_idx3{0}, d_idx4{0};
double d_volLower{0.0};
double d_volUpper{0.0};
double d_weight{0.0};
};
} // namespace DistGeom
#endif

View File

@@ -35,7 +35,28 @@ double calcChiralVolume(const unsigned int idx1, const unsigned int idx2,
double vol = v1.dotProduct(v2xv3);
return vol;
}
double calcChiralVolume(const unsigned int idx1, const unsigned int idx2,
const unsigned int idx3, const unsigned int idx4,
const RDGeom::PointPtrVect &pts) {
// even if we are minimizing in higher dimension the chiral volume is
// calculated using only the first 3 dimensions
RDGeom::Point3D v1((*pts[idx1])[0] - (*pts[idx4])[0],
(*pts[idx1])[1] - (*pts[idx4])[1],
(*pts[idx1])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v2((*pts[idx2])[0] - (*pts[idx4])[0],
(*pts[idx2])[1] - (*pts[idx4])[1],
(*pts[idx2])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v3((*pts[idx3])[0] - (*pts[idx4])[0],
(*pts[idx3])[1] - (*pts[idx4])[1],
(*pts[idx3])[2] - (*pts[idx4])[2]);
RDGeom::Point3D v2xv3 = v2.crossProduct(v3);
double vol = v1.dotProduct(v2xv3);
return vol;
}
ChiralViolationContribs::ChiralViolationContribs(
ForceFields::ForceField *owner) {
PRECONDITION(owner, "bad owner");

View File

@@ -18,6 +18,13 @@
namespace DistGeom {
class ChiralSet;
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);
RDKIT_DISTGEOMETRY_EXPORT double calcChiralVolume(
const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
const unsigned int idx4, const RDGeom::PointPtrVect &pts);
struct ChiralViolationContribsParams {
unsigned int idx1{0}, idx2{0}, idx3{0}, idx4{0};
double volUpper{0.0};

View File

@@ -1,97 +0,0 @@
// $Id$
//
// Copyright (C) 2004-2006 Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include "DistViolationContrib.h"
#include <ForceField/ForceField.h>
#include <RDGeneral/Invariant.h>
namespace DistGeom {
DistViolationContrib::DistViolationContrib(ForceFields::ForceField *owner,
unsigned int idx1, unsigned int idx2,
double ub, double lb,
double weight) {
PRECONDITION(owner, "bad owner");
URANGE_CHECK(idx1, owner->positions().size());
URANGE_CHECK(idx2, owner->positions().size());
dp_forceField = owner;
d_end1Idx = idx1;
d_end2Idx = idx2;
d_ub = ub;
d_lb = lb;
d_weight = weight;
}
double DistViolationContrib::getEnergy(double *pos) const {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(pos, "bad vector");
double d =
this->dp_forceField->distance(this->d_end1Idx, this->d_end2Idx, pos);
double val = 0.0;
if (d > d_ub) {
val = ((d * d) / (d_ub * d_ub)) - 1.0;
} else if (d < d_lb) {
val = ((2 * d_lb * d_lb) / (d_lb * d_lb + d * d)) - 1.0;
}
double res;
if (val > 0.0) {
res = d_weight * val * val;
} else {
res = 0;
}
// if (res > 0.1) {
// std::cerr << "dvc:getEnergy: " << this->d_end1Idx << "-" <<
// this->d_end2Idx
// << ": " << d_lb << "-" << d_ub << " " << d << " => " << res
// << std::endl;
// }
return res;
}
void DistViolationContrib::getGrad(double *pos, double *grad) const {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(pos, "bad vector");
PRECONDITION(grad, "bad vector");
unsigned int dim = this->dp_forceField->dimension();
double d =
this->dp_forceField->distance(this->d_end1Idx, this->d_end2Idx, pos);
double preFactor = 0.0;
if (d > d_ub) {
double u2 = d_ub * d_ub;
preFactor = 4. * (((d * d) / u2) - 1.0) * (d / u2);
} else if (d < d_lb) {
double d2 = d * d;
double l2 = d_lb * d_lb;
double l2d2 = d2 + l2;
preFactor = 8. * l2 * d * (1. - 2 * l2 / l2d2) / (l2d2 * l2d2);
// preFactor = -8.*((l2-d2)/pow(l2+d2,3))*d*l2;
} else {
return;
}
double *end1Coords = &(pos[dim * this->d_end1Idx]);
double *end2Coords = &(pos[dim * this->d_end2Idx]);
for (unsigned int i = 0; i < dim; i++) {
double dGrad;
if (d > 0.0) {
dGrad = d_weight * preFactor * (end1Coords[i] - end2Coords[i]) / d;
} else {
// FIX: this likely isn't right
dGrad = d_weight * preFactor * (end1Coords[i] - end2Coords[i]);
}
grad[dim * this->d_end1Idx + i] += dGrad;
grad[dim * this->d_end2Idx + i] -= dGrad;
}
}
} // namespace DistGeom

View File

@@ -1,55 +0,0 @@
//
// Copyright (C) 2004-2006 Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef __RD_DISTVIOLATIONCONTRIB_H__
#define __RD_DISTVIOLATIONCONTRIB_H__
#include <ForceField/Contrib.h>
namespace DistGeom {
//! DEPRECATED: use DistViolationContribs instead
//! A term to capture the violation of the upper and lower bounds by
//! distance between two points
class RDKIT_DISTGEOMETRY_EXPORT DistViolationContrib
: public ForceFields::ForceFieldContrib {
public:
DistViolationContrib() {}
//! Constructor
/*!
\param owner pointer to the owning ForceField
\param idx1 index of end1 in the ForceField's positions
\param idx2 index of end2 in the ForceField's positions
\param ub Upper bound on the distance
\param lb Lower bound on the distance
\param weight optional weight for this contribution
*/
DistViolationContrib(ForceFields::ForceField *owner, unsigned int idx1,
unsigned int idx2, double ub, double lb,
double weight = 1.0);
double getEnergy(double *pos) const override;
void getGrad(double *pos, double *grad) const override;
DistViolationContrib *copy() const override {
return new DistViolationContrib(*this);
}
private:
unsigned int d_end1Idx{0}, d_end2Idx{0}; //!< indices of end points
double d_ub{
1000.0}; //!< upper bound on the distance between d_end1Idx, d_end2Idx
double d_lb{
0.0}; //!< lower bound on the distance between d_end1Idx, d_end2Idx
double d_weight{1.0}; //!< used to adjust relative contribution weights
};
} // namespace DistGeom
#endif

View File

@@ -1,66 +0,0 @@
//
// Created by Santosh Putta, Nov 2006
//
#include <RDGeneral/export.h>
#ifndef __RD_FOURTHDIMCONTRIB_H__
#define __RD_FOURTHDIMCONTRIB_H__
#include <RDGeneral/Invariant.h>
#include <ForceField/Contrib.h>
#include <ForceField/ForceField.h>
namespace DistGeom {
//! DEPRECATED: use FourthDimContribs instead
//! A term used in penalizing chirality violations
//!
class RDKIT_DISTGEOMETRY_EXPORT FourthDimContrib
: public ForceFields::ForceFieldContrib {
public:
FourthDimContrib() {}
//! Constructor
/*!
\param owner pointer to the owning ForceField
\param idx the index of the atom to be considered
\param weight (optional) the weight to be used for this contrib
*/
FourthDimContrib(ForceFields::ForceField *owner, unsigned int idx,
double weight)
: d_idx(idx), d_weight(weight) {
PRECONDITION(owner, "bad force field");
PRECONDITION(owner->dimension() == 4, "force field has wrong dimension");
dp_forceField = owner;
}
//! return the contribution of this contrib to the energy of a given state
double getEnergy(double *pos) const override {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(dp_forceField->dimension() == 4,
"force field has wrong dimension");
PRECONDITION(pos, "bad vector");
unsigned int pid = d_idx * dp_forceField->dimension() + 3;
return d_weight * pos[pid] * pos[pid];
}
//! calculate the contribution of this contrib to the gradient at a given
/// state
void getGrad(double *pos, double *grad) const override {
PRECONDITION(dp_forceField, "no owner");
PRECONDITION(dp_forceField->dimension() == 4,
"force field has wrong dimension");
PRECONDITION(pos, "bad vector");
unsigned int pid = d_idx * dp_forceField->dimension() + 3;
grad[pid] += d_weight * pos[pid];
}
FourthDimContrib *copy() const override {
return new FourthDimContrib(*this);
}
private:
unsigned int d_idx{0};
double d_weight{0.0};
};
} // namespace DistGeom
#endif