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