File: MolTransforms.h

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (204 lines) | stat: -rw-r--r-- 8,655 bytes parent folder | download
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
//
//   Copyright (C) 2003-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_MOLTRANSFORMS_H_
#define _RD_MOLTRANSFORMS_H_

#include <Geometry/point.h>
#include <Numerics/SymmMatrix.h>

#ifdef RDK_HAS_EIGEN3
#include <Eigen/Dense>
#endif

namespace RDKit {
class ROMol;
class Atom;
class Conformer;
}

namespace RDGeom {
class Transform3D;
}

namespace MolTransforms {
RDKIT_MOLTRANSFORMS_EXPORT void transformMolsAtoms(RDKit::ROMol *mol, RDGeom::Transform3D &tform);
RDKIT_MOLTRANSFORMS_EXPORT void transformAtom(RDKit::Atom *atom, RDGeom::Transform3D &tform);

//! Compute the centroid of a conformer
/*!
  This is simple the average of the heavy atom locations in the conformer,
  not attention is paid to hydrogens or the differences in atomic radii

  \param conf     Conformer of interest
  \param ignoreHs If true, ignore hydrogen atoms
*/
RDKIT_MOLTRANSFORMS_EXPORT RDGeom::Point3D computeCentroid(const RDKit::Conformer &conf,
                                bool ignoreHs = true);

#ifdef RDK_HAS_EIGEN3
//! Compute principal axes and moments of inertia for a conformer
/*!
  These values are calculated from the inertia tensor:
    Iij = - sum_{s=1..N}(w_s * r_{si} * r_{sj}) i != j
    Iii = sum_{s=1..N} sum_{j!=i} (w_s * r_{sj} * r_{sj})
  where the coordinates are relative to the center of mass.


  \param conf       Conformer of interest
  \param axes       used to return the principal axes
  \param  moments    used to return the principal moments
  \param ignoreHs   If true, ignore hydrogen atoms
  \param force      If true, the calculation will be carried out even if a
  cached value is present
  \param weights    If present used to weight the atomic coordinates

  \returns whether or not the calculation was successful
*/
RDKIT_MOLTRANSFORMS_EXPORT bool computePrincipalAxesAndMoments(const RDKit::Conformer &conf,
                                    Eigen::Matrix3d &axes,
                                    Eigen::Vector3d &moments,
                                    bool ignoreHs = false, bool force = false,
                                    const std::vector<double> *weights = NULL);
//! Compute principal axes and moments from the gyration matrix of a conformer
/*!

  These values are calculated from the gyration matrix/tensor:
    Iij = sum_{s=1..N}(w_s * r_{si} * r_{sj}) i != j
    Iii = sum_{s=1..N} sum_{t!=s}(w_s * r_{si} * r_{ti})
  where the coordinates are relative to the center of mass.

  \param conf       Conformer of interest
  \param axes       used to return the principal axes
  \param  moments    used to return the principal moments
  \param ignoreHs   If true, ignore hydrogen atoms
  \param force      If true, the calculation will be carried out even if a
  cached value is present
  \param weights    If present used to weight the atomic coordinates

  \returns whether or not the calculation was successful
*/
RDKIT_MOLTRANSFORMS_EXPORT bool computePrincipalAxesAndMomentsFromGyrationMatrix(
    const RDKit::Conformer &conf, Eigen::Matrix3d &axes,
    Eigen::Vector3d &moments, bool ignoreHs = false, bool force = false,
    const std::vector<double> *weights = NULL);
#endif

//! Compute the transformation require to orient the conformation
//! along the principal axes about the center; i.e. center is made to coincide
// with the
//! origin, the largest princiapl axis with the x-axis, the next largest with
// the y-axis
//! and the smallest with the z-axis
/*!
  If center is not specified the the centroid of the conformer will be used
  \param conf                Conformer of interest
  \param center              Center to be used for canonicalization, defaults to
  the centroid of the
                             conformation
  \param normalizeCovar      Normalize the covariance matrix with the number of
  atoms
  \param ignoreHs            Optinally ignore hydrogens
*/
RDKIT_MOLTRANSFORMS_EXPORT RDGeom::Transform3D *computeCanonicalTransform(
    const RDKit::Conformer &conf, const RDGeom::Point3D *center = 0,
    bool normalizeCovar = false, bool ignoreHs = true);

//! Transform the conformation using the specified transformation
RDKIT_MOLTRANSFORMS_EXPORT void transformConformer(RDKit::Conformer &conf,
                        const RDGeom::Transform3D &trans);

//! Canonicalize the orientation of a conformer so that its principal axes
//! around the specified center point coincide with the x, y, z axes
/*!
  \param conf           The conformer of interest
  \param center         Optional center point about which the principal axes are
  computed
                        if not specified the centroid of the conformer will be
  used
  \param normalizeCovar Optionally normalize the covariance matrix by the number
  of atoms
  \param ignoreHs       If true, ignore hydrogen atoms

*/
RDKIT_MOLTRANSFORMS_EXPORT void canonicalizeConformer(RDKit::Conformer &conf,
                           const RDGeom::Point3D *center = 0,
                           bool normalizeCovar = false, bool ignoreHs = true);

//! Canonicalize all the conformations in a molecule
/*!
  \param mol            the molecule of interest
  \param normalizeCovar Optionally normalize the covariance matrix by the number
  of atoms
  \param ignoreHs       If true, ignore hydrogens
*/
RDKIT_MOLTRANSFORMS_EXPORT void canonicalizeMol(RDKit::ROMol &mol, bool normalizeCovar = false,
                     bool ignoreHs = true);

//! Get the bond length between the specified atoms i, j
RDKIT_MOLTRANSFORMS_EXPORT double getBondLength(const RDKit::Conformer &conf, unsigned int iAtomId,
                     unsigned int jAtomId);

//! Set the bond length between the specified atoms i, j
//! (all atoms bonded to atom j are moved)
RDKIT_MOLTRANSFORMS_EXPORT void setBondLength(RDKit::Conformer &conf, unsigned int iAtomId,
                   unsigned int jAtomId, double value);

//! Get the angle in radians among the specified atoms i, j, k
RDKIT_MOLTRANSFORMS_EXPORT double getAngleRad(const RDKit::Conformer &conf, unsigned int iAtomId,
                   unsigned int jAtomId, unsigned int kAtomId);

//! Get the angle in degrees among the specified atoms i, j, k
inline double getAngleDeg(const RDKit::Conformer &conf, unsigned int iAtomId,
                          unsigned int jAtomId, unsigned int kAtomId) {
  return (180. / M_PI * getAngleRad(conf, iAtomId, jAtomId, kAtomId));
}

//! Set the angle in radians among the specified atoms i, j, k
//! (all atoms bonded to atom k are moved)
RDKIT_MOLTRANSFORMS_EXPORT void setAngleRad(RDKit::Conformer &conf, unsigned int iAtomId,
                 unsigned int jAtomId, unsigned int kAtomId, double value);

//! Set the angle in degrees among the specified atoms i, j, k
//! (all atoms bonded to atom k are moved)
inline void setAngleDeg(RDKit::Conformer &conf, unsigned int iAtomId,
                        unsigned int jAtomId, unsigned int kAtomId,
                        double value) {
  setAngleRad(conf, iAtomId, jAtomId, kAtomId, value / 180. * M_PI);
}

//! Get the dihedral angle in radians among the specified atoms i, j, k, l
RDKIT_MOLTRANSFORMS_EXPORT double getDihedralRad(const RDKit::Conformer &conf, unsigned int iAtomId,
                      unsigned int jAtomId, unsigned int kAtomId,
                      unsigned int lAtomId);

//! Get the dihedral angle in degrees among the specified atoms i, j, k, l
inline double getDihedralDeg(const RDKit::Conformer &conf, unsigned int iAtomId,
                             unsigned int jAtomId, unsigned int kAtomId,
                             unsigned int lAtomId) {
  return (180. / M_PI *
          getDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId));
}

//! Set the dihedral angle in radians among the specified atoms i, j, k, l
//! (all atoms bonded to atom l are moved)
RDKIT_MOLTRANSFORMS_EXPORT void setDihedralRad(RDKit::Conformer &conf, unsigned int iAtomId,
                    unsigned int jAtomId, unsigned int kAtomId,
                    unsigned int lAtomId, double value);

//! Set the dihedral angle in degrees among the specified atoms i, j, k, l
//! (all atoms bonded to atom l are moved)
inline void setDihedralDeg(RDKit::Conformer &conf, unsigned int iAtomId,
                           unsigned int jAtomId, unsigned int kAtomId,
                           unsigned int lAtomId, double value) {
  setDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId, value / 180. * M_PI);
}
}
#endif