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  */
38  RDGeom::Point3D computeCentroid(const RDKit::Conformer &conf, bool ignoreHs=true);
39 
40  //! Compute the covariance matrix for a conformer
41  /*!
42  \param conf Conformer of interest
43  \param center Center to be used for covariance matrix calculation
44  \param normalize If true, normalize the covariance matrix by the number of atoms
45  \param ignoreHs If true, ignore hydrogen atoms
46  */
48  const RDGeom::Point3D &center,
49  bool normalize=false,
50  bool ignoreHs=true);
51 
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 with the
55  //! origin, the largest princiapl axis with the x-axis, the next largest with the y-axis
56  //! and the smallest with the z-axis
57  /*!
58  If center is not specified the the centroid of the conformer will be used
59  \param conf Conformer of interest
60  \param center Center to be used for canonicalization, defaults to the centroid of the
61  conformation
62  \param normalizeCovar Normalize the covariance matrix with the number of atoms
63  \param ignoreHs Optinally ignore hydrogens
64  */
66  const RDGeom::Point3D *center=0,
67  bool normalizeCovar=false,
68  bool ignoreHs=true);
69 
70  //! Transform the conformation using the specified transformation
72 
73  //! Canonicalize the orientation of a conformer so that its principal axes
74  //! around the specified center point coincide with the x, y, z axes
75  /*!
76  \param conf The conformer of interest
77  \param center Optional center point about which the principal axes are computed
78  if not specified the centroid of the conformer will be used
79  \param normalizeCovar Optionally normalize the covariance matrix by the number of atoms
80  \param ignoreHs If true, ignore hydrogen atoms
81 
82  */
83  void canonicalizeConformer(RDKit::Conformer &conf, const RDGeom::Point3D *center=0,
84  bool normalizeCovar=false, bool ignoreHs=true);
85 
86  //! Canonicalize all the conformations in a molecule
87  /*!
88  \param mol the molecule of interest
89  \param normalizeCovar Optionally normalize the covariance matrix by the number of atoms
90  \param ignoreHs If true, ignore hydrogens
91  */
92  void canonicalizeMol(RDKit::ROMol &mol, bool normalizeCovar=false, bool ignoreHs=true);
93 
94  //! Get the bond length between the specified atoms i, j
95  double getBondLength(RDKit::Conformer &conf,
96  unsigned int iAtomId, unsigned int jAtomId);
97 
98  //! Set the bond length between the specified atoms i, j
99  //! (all atoms bonded to atom j are moved)
100  void setBondLength(RDKit::Conformer &conf,
101  unsigned int iAtomId, unsigned int jAtomId, double value);
102 
103  //! Get the angle in radians among the specified atoms i, j, k
104  double getAngleRad(RDKit::Conformer &conf,
105  unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId);
106 
107  //! Get the angle in degrees among the specified atoms i, j, k
108  inline double getAngleDeg(RDKit::Conformer &conf,
109  unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId) {
110  return (180. / M_PI * getAngleRad(conf, iAtomId, jAtomId, kAtomId));
111  }
112 
113  //! Set the angle in radians among the specified atoms i, j, k
114  //! (all atoms bonded to atom k are moved)
115  void setAngleRad(RDKit::Conformer &conf, unsigned int iAtomId,
116  unsigned int jAtomId, unsigned int kAtomId, double value);
117 
118  //! Set the angle in degrees among the specified atoms i, j, k
119  //! (all atoms bonded to atom k are moved)
120  inline void setAngleDeg(RDKit::Conformer &conf, unsigned int iAtomId,
121  unsigned int jAtomId, unsigned int kAtomId, double value) {
122  setAngleRad(conf, iAtomId, jAtomId, kAtomId, value / 180. * M_PI);
123  }
124 
125  //! Get the dihedral angle in radians among the specified atoms i, j, k, l
126  double getDihedralRad(RDKit::Conformer &conf, unsigned int iAtomId,
127  unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId);
128 
129  //! Get the dihedral angle in degrees among the specified atoms i, j, k, l
130  inline double getDihedralDeg(RDKit::Conformer &conf, unsigned int iAtomId,
131  unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId) {
132  return (180. / M_PI * getDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId));
133  }
134 
135  //! Set the dihedral angle in radians among the specified atoms i, j, k, l
136  //! (all atoms bonded to atom l are moved)
137  void setDihedralRad(RDKit::Conformer &conf, unsigned int iAtomId,
138  unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId, double value);
139 
140  //! Set the dihedral angle in degrees among the specified atoms i, j, k, l
141  //! (all atoms bonded to atom l are moved)
142  inline void setDihedralDeg(RDKit::Conformer &conf, unsigned int iAtomId,
143  unsigned int jAtomId, unsigned int kAtomId, unsigned int lAtomId, double value) {
144  setDihedralRad(conf, iAtomId, jAtomId, kAtomId, lAtomId, value / 180. * M_PI);
145  }
146 
147 }
148 #endif
void canonicalizeConformer(RDKit::Conformer &conf, const RDGeom::Point3D *center=0, bool normalizeCovar=false, bool ignoreHs=true)
double getAngleRad(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId)
Get the angle in radians among the specified atoms i, j, k.
void transformAtom(RDKit::Atom *atom, RDGeom::Transform3D &tform)
A symmetric matrix class.
Definition: SymmMatrix.h:28
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:105
void transformConformer(RDKit::Conformer &conf, const RDGeom::Transform3D &trans)
Transform the conformation using the specified transformation.
double getDihedralRad(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 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.
void transformMolsAtoms(RDKit::ROMol *mol, RDGeom::Transform3D &tform)
double getAngleDeg(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId, unsigned int kAtomId)
Get the angle in degrees among the specified atoms i, j, k.
double getDihedralDeg(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.
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)
The class for representing atoms.
Definition: Atom.h:67
#define M_PI
Definition: MMFF/Params.h:25
double getBondLength(RDKit::Conformer &conf, unsigned int iAtomId, unsigned int jAtomId)
Get the bond length between the specified atoms i, j.