RDKit
Open-source cheminformatics and machine learning.
MolTransforms.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2006 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 #ifndef _RD_MOLTRANSFORMS_H_
11 #define _RD_MOLTRANSFORMS_H_
12 
13 #include <Geometry/point.h>
14 #include <Numerics/SymmMatrix.h>
15 
16 namespace RDKit {
17 class ROMol;
18 class Atom;
19 class Conformer;
20 }
21 
22 namespace RDGeom {
23 class Transform3D;
24 }
25 
26 namespace MolTransforms {
29 
30 //! Compute the centroid of a conformer
31 /*!
32  This is simple the average of the heavy atom locations in the conformer,
33  not attention is paid to hydrogens or the differences in atomic radii
34 
35  \param conf Conformer of interest
36  \param ignoreHs If true, ignore hydrogen atoms
37 */
39  bool ignoreHs = true);
40 
41 //! Compute the covariance matrix for a conformer
42 /*!
43  \param conf Conformer of interest
44  \param center Center to be used for covariance matrix calculation
45  \param normalize If true, normalize the covariance matrix by the number of
46  atoms
47  \param ignoreHs If true, ignore hydrogen atoms
48 */
50  const RDKit::Conformer &conf, const RDGeom::Point3D &center,
51  bool normalize = false, bool ignoreHs = true);
52 
53 //! Compute the transformation require to orient the conformation
54 //! along the principal axes about the center; i.e. center is made to coincide
55 // with the
56 //! origin, the largest princiapl axis with the x-axis, the next largest with
57 // the y-axis
58 //! and the smallest with the z-axis
59 /*!
60  If center is not specified the the centroid of the conformer will be used
61  \param conf Conformer of interest
62  \param center Center to be used for canonicalization, defaults to
63  the centroid of the
64  conformation
65  \param normalizeCovar Normalize the covariance matrix with the number of
66  atoms
67  \param ignoreHs Optinally ignore hydrogens
68 */
70  const RDKit::Conformer &conf, const RDGeom::Point3D *center = 0,
71  bool normalizeCovar = false, bool ignoreHs = true);
72 
73 //! Transform the conformation using the specified transformation
75  const RDGeom::Transform3D &trans);
76 
77 //! Canonicalize the orientation of a conformer so that its principal axes
78 //! around the specified center point coincide with the x, y, z axes
79 /*!
80  \param conf The conformer of interest
81  \param center Optional center point about which the principal axes are
82  computed
83  if not specified the centroid of the conformer will be
84  used
85  \param normalizeCovar Optionally normalize the covariance matrix by the number
86  of atoms
87  \param ignoreHs If true, ignore hydrogen atoms
88 
89 */
91  const RDGeom::Point3D *center = 0,
92  bool normalizeCovar = false, bool ignoreHs = true);
93 
94 //! Canonicalize all the conformations in a molecule
95 /*!
96  \param mol the molecule of interest
97  \param normalizeCovar Optionally normalize the covariance matrix by the number
98  of atoms
99  \param ignoreHs If true, ignore hydrogens
100 */
101 void canonicalizeMol(RDKit::ROMol &mol, bool normalizeCovar = false,
102  bool ignoreHs = true);
103 
104 //! Get the bond length between the specified atoms i, j
105 double getBondLength(const RDKit::Conformer &conf, unsigned int iAtomId,
106  unsigned int jAtomId);
107 
108 //! Set the bond length between the specified atoms i, j
109 //! (all atoms bonded to atom j are moved)
110 void setBondLength(RDKit::Conformer &conf, unsigned int iAtomId,
111  unsigned int jAtomId, double value);
112 
113 //! Get the angle in radians among the specified atoms i, j, k
114 double getAngleRad(const RDKit::Conformer &conf, unsigned int iAtomId,
115  unsigned int jAtomId, unsigned int kAtomId);
116 
117 //! Get the angle in degrees among the specified atoms i, j, k
118 inline double getAngleDeg(const RDKit::Conformer &conf, unsigned int iAtomId,
119  unsigned int jAtomId, unsigned int kAtomId) {
120  return (180. / M_PI * getAngleRad(conf, iAtomId, jAtomId, kAtomId));
121 }
122 
123 //! Set the angle in radians among the specified atoms i, j, k
124 //! (all atoms bonded to atom k are moved)
125 void setAngleRad(RDKit::Conformer &conf, unsigned int iAtomId,
126  unsigned int jAtomId, unsigned int kAtomId, double value);
127 
128 //! Set the angle in degrees among the specified atoms i, j, k
129 //! (all atoms bonded to atom k are moved)
130 inline void setAngleDeg(RDKit::Conformer &conf, unsigned int iAtomId,
131  unsigned int jAtomId, unsigned int kAtomId,
132  double value) {
133  setAngleRad(conf, iAtomId, jAtomId, kAtomId, value / 180. * M_PI);
134 }
135 
136 //! Get the dihedral angle in radians among the specified atoms i, j, k, l
137 double getDihedralRad(const RDKit::Conformer &conf, unsigned int iAtomId,
138  unsigned int jAtomId, unsigned int kAtomId,
139  unsigned int lAtomId);
140 
141 //! Get the dihedral angle in degrees among the specified atoms i, j, k, l
142 inline double getDihedralDeg(const RDKit::Conformer &conf, unsigned int iAtomId,
143  unsigned int jAtomId, unsigned int kAtomId,
144  unsigned int lAtomId) {
145  return (180. / M_PI *
146  getDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId));
147 }
148 
149 //! Set the dihedral angle in radians among the specified atoms i, j, k, l
150 //! (all atoms bonded to atom l are moved)
151 void setDihedralRad(RDKit::Conformer &conf, unsigned int iAtomId,
152  unsigned int jAtomId, unsigned int kAtomId,
153  unsigned int lAtomId, double value);
154 
155 //! Set the dihedral angle in degrees among the specified atoms i, j, k, l
156 //! (all atoms bonded to atom l are moved)
157 inline void setDihedralDeg(RDKit::Conformer &conf, unsigned int iAtomId,
158  unsigned int jAtomId, unsigned int kAtomId,
159  unsigned int lAtomId, double value) {
160  setDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId, value / 180. * M_PI);
161 }
162 }
163 #endif
double getDihedralDeg(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.
void canonicalizeConformer(RDKit::Conformer &conf, const RDGeom::Point3D *center=0, bool normalizeCovar=false, bool ignoreHs=true)
void transformAtom(RDKit::Atom *atom, RDGeom::Transform3D &tform)
double getAngleRad(const RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId)
Get the angle in radians among the specified atoms i, j, k.
A symmetric matrix class.
Definition: SymmMatrix.h:29
double getDihedralRad(const RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId)
Get the dihedral angle in radians among the specified atoms i, j, k, l.
void canonicalizeMol(RDKit::ROMol &mol, bool normalizeCovar=false, bool ignoreHs=true)
Canonicalize all the conformations in a molecule.
RDNumeric::DoubleSymmMatrix * computeCovarianceMatrix(const RDKit::Conformer &conf, const RDGeom::Point3D &center, bool normalize=false, bool ignoreHs=true)
Compute the covariance matrix for a conformer.
void setDihedralDeg(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId, double value)
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:102
void transformConformer(RDKit::Conformer &conf, const RDGeom::Transform3D &trans)
Transform the conformation using the specified transformation.
double getAngleDeg(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.
void setAngleDeg(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId, double value)
void setAngleRad(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId, double value)
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDGeom::Point3D computeCentroid(const RDKit::Conformer &conf, bool ignoreHs=true)
Compute the centroid of a conformer.
double getBondLength(const RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId)
Get the bond length between the specified atoms i, j.
void transformMolsAtoms(RDKit::ROMol *mol, RDGeom::Transform3D &tform)
The class for representing 2D or 3D conformation of a molecule.
Definition: Conformer.h:41
void setBondLength(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, double value)
void setDihedralRad(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId, double value)
RDGeom::Transform3D * computeCanonicalTransform(const RDKit::Conformer &conf, const RDGeom::Point3D *center=0, bool normalizeCovar=false, bool ignoreHs=true)
origin, the largest princiapl axis with the x-axis, the next largest with
The class for representing atoms.
Definition: Atom.h:67
#define M_PI
Definition: MMFF/Params.h:25