1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
//
// Copyright (C) 2004-2019 Greg Landrum and 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_DISTGEOMUTILS_H_
#define _RD_DISTGEOMUTILS_H_
#include "BoundsMatrix.h"
#include <Numerics/SymmMatrix.h>
#include <map>
#include <Geometry/point.h>
#include <GraphMol/ForceFieldHelpers/CrystalFF/TorsionPreferences.h>
#include "ChiralSet.h"
#include <RDGeneral/utils.h>
#include <boost/dynamic_bitset.hpp>
namespace ForceFields {
class ForceField;
} // namespace ForceFields
namespace DistGeom {
//! Pick a distance matrix at random such that the
//! distance satisfy the bounds in the BoundsMatrix
/*!
\param mmat Bounds matrix
\param distmat Storage for randomly chosen distances
\param seed the random number seed to use
\return the largest element of the distance matrix
*/
RDKIT_DISTGEOMETRY_EXPORT double pickRandomDistMat(
const BoundsMatrix &mmat, RDNumeric::SymmMatrix<double> &distmat,
int seed = -1);
//! \overload
RDKIT_DISTGEOMETRY_EXPORT double pickRandomDistMat(
const BoundsMatrix &mmat, RDNumeric::SymmMatrix<double> &distmat,
RDKit::double_source_type &rng);
//! Compute an initial embedded in 3D based on a distance matrix
/*!
This function follows the embed algorithm mentioned in
"Distance Geometry and Molecular Conformation" by G.M.Crippen and T.F.Havel
(pages 312-313)
\param distmat Distance matrix
\param positions A vector of pointers to Points to write out the resulting
coordinates
\param randNegEig If set to true and if any of the eigen values are negative,
we will
pick the corresponding components of the coordinates at
random
\param numZeroFail Fail embedding is more this many (or more) eigen values are
zero
\param seed the random number seed to use
\return true if the embedding was successful
*/
RDKIT_DISTGEOMETRY_EXPORT bool computeInitialCoords(
const RDNumeric::SymmMatrix<double> &distmat,
RDGeom::PointPtrVect &positions, bool randNegEig = false,
unsigned int numZeroFail = 2, int seed = -1);
//! \overload
RDKIT_DISTGEOMETRY_EXPORT bool computeInitialCoords(
const RDNumeric::SymmMatrix<double> &distmat,
RDGeom::PointPtrVect &positions, RDKit::double_source_type &rng,
bool randNegEig = false, unsigned int numZeroFail = 2);
//! places atoms randomly in a box
/*!
\param positions A vector of pointers to Points to write out the resulting
coordinates
\param boxSize the side-length of the cubic box
\param seed the random number seed to use
\return true if the coordinate generation was successful
*/
RDKIT_DISTGEOMETRY_EXPORT bool computeRandomCoords(
RDGeom::PointPtrVect &positions, double boxSize, int seed = -1);
//! \overload
RDKIT_DISTGEOMETRY_EXPORT bool computeRandomCoords(
RDGeom::PointPtrVect &positions, double boxSize,
RDKit::double_source_type &rng);
//! Setup the error function for violation of distance bounds as a forcefield
/*!
This is based on function E3 on page 311 of "Distance Geometry in Molecular
Modeling" Jeffrey M.Blaney and J.Scott Dixon, Review in Computational
Chemistry,
Volume V
\param mmat Distance bounds matrix
\param positions A vector of pointers to Points to write out the
resulting coordinates
\param csets The vector of chiral points (type: ChiralSet)
\param weightChiral weight to be used to enforce chirality
\param weightFourthDim another chiral weight
\param extraWeights an optional set of weights for distance bounds
violations
\param basinSizeTol Optional: any distance bound with a basin (distance
between max and
min bounds) larger than this value will not be included
in the force
field used to cleanup the structure.
\return a pointer to a ForceField suitable for cleaning up the violations.
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField *constructForceField(
const BoundsMatrix &mmat, RDGeom::PointPtrVect &positions,
const VECT_CHIRALSET &csets, double weightChiral = 1.0,
double weightFourthDim = 0.1,
std::map<std::pair<int, int>, double> *extraWeights = nullptr,
double basinSizeTol = 5.0, boost::dynamic_bitset<> *fixedPts = nullptr);
//! Force field with experimental torsion angle preferences and 1-2/1-3 distance
/// constraints
/*!
\param mmat Distance bounds matrix
\param positions A vector of pointers to 3D Points to write out the
resulting coordinates
\param etkdgDetails Contains information about the ETKDG force field
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField *construct3DForceField(
const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails);
//! Force field with experimental torsion angle preferences and 1-2/1-3 distance
/// constraints, as well as atom pairwise Columbic interactions
/*!
\param mmat Distance bounds matrix
\param positions A vector of pointers to 3D Points to write out the
resulting coordinates
\param etkdgDetails Contains information about the ETKDG force field
\param CPCI Contains which atom pair(s) have what strength of
attractive/repulsive electrostatic interaction(s)
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField *construct3DForceField(
const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails,
const std::map<std::pair<unsigned int, unsigned int>, double> &CPCI);
//! Force field with experimental torsion angle preferences and 1-2/1-3 distance
/// constraints
/*!
\param mmat Distance bounds matrix
\param positions A vector of pointers to 3D Points to write out the
resulting coordinates
\param etkdgDetails Contains information about the ETKDG force field
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField *constructPlain3DForceField(
const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails);
//! Force field with improper terms and SP linearity contributions
/*!
\param mmat Distance bounds matrix
\param positions A vector of pointers to 3D Points to write out the
resulting coordinates
\param improperAtoms A list of groups of 4 atom indices for inversion terms
\param angles List of lists with the three angle indices and whether
the center atom in the angle is SP hybridized for every angle in the molecule.
\param atomNums A list of atomic numbers for all atoms in the molecule,
no longer used.
\return a pointer to a ForceField with improper terms
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
RDKIT_DISTGEOMETRY_EXPORT ForceFields::ForceField *
construct3DImproperForceField(
const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
const std::vector<std::vector<int>> &improperAtoms,
const std::vector<std::vector<int>> &angles,
const std::vector<int> &atomNums);
//! Force field with improper terms and SP linearity contributions
/*!
\param mmat Distance bounds matrix
\param positions A vector of pointers to 3D Points to write out the
resulting coordinates
\param etkdgDetails Contains information about the ETKDG force field
\return a pointer to a ForceField with improper terms
<b>NOTE:</b> the caller is responsible for deleting this force field.
*/
//! \overload
inline ForceFields::ForceField *construct3DImproperForceField(
const BoundsMatrix &mmat, RDGeom::Point3DPtrVect &positions,
const ForceFields::CrystalFF::CrystalFFDetails &etkdgDetails) {
return construct3DImproperForceField(
mmat, positions, etkdgDetails.improperAtoms, etkdgDetails.angles,
etkdgDetails.atomNums);
}
} // namespace DistGeom
#endif
|