RDKit
Open-source cheminformatics and machine learning.
AlignMolecules.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-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 #include <RDGeneral/export.h>
11 #ifndef _RD_ALIGNMOLECULES_H_
12 #define _RD_ALIGNMOLECULES_H_
13 
14 #include <Geometry/Transform3D.h>
15 #include <Numerics/Vector.h>
16 #include <vector>
17 
18 namespace RDKit {
19 typedef std::vector<std::pair<int, int>> MatchVectType;
20 
21 class Conformer;
22 class ROMol;
23 namespace MolAlign {
24 class RDKIT_MOLALIGN_EXPORT MolAlignException : public std::exception {
25  public:
26  //! construct with an error message
27  MolAlignException(const char *msg) : _msg(msg){};
28  //! construct with an error message
29  MolAlignException(const std::string msg) : _msg(msg){};
30  //! get the error message
31  const char *message() const { return _msg.c_str(); };
32  ~MolAlignException() throw(){};
33 
34  private:
35  std::string _msg;
36 };
37 
38 //! Alignment functions
39 
40 //! Compute the transformation required to align a molecule
41 /*!
42  The 3D transformation required to align the specied conformation in the probe
43  molecule
44  to a specified conformation in the reference molecule is computed so that the
45  root mean
46  squared distance between a specified set of atoms is minimized
47 
48  \param prbMol molecule that is to be aligned
49  \param refMol molecule used as the reference for the alignment
50  \param trans storage for the computed transform
51  \param prbCid ID of the conformation in the probe to be used
52  for the alignment (defaults to first conformation)
53  \param refCid ID of the conformation in the ref molecule to which
54  the alignment is computed (defaults to first conformation)
55  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
56  used to compute the alignments. If this mapping is
57  not specified an attempt is made to generate on by
58  substructure matching
59  \param weights Optionally specify weights for each of the atom pairs
60  \param reflect if true reflect the conformation of the probe molecule
61  \param maxIters maximum number of iteration used in mimizing the RMSD
62 
63  <b>Returns</b>
64  RMSD value
65 */
67  const ROMol &prbMol, const ROMol &refMol, RDGeom::Transform3D &trans,
68  int prbCid = -1, int refCid = -1, const MatchVectType *atomMap = 0,
69  const RDNumeric::DoubleVector *weights = 0, bool reflect = false,
70  unsigned int maxIters = 50);
71 
72 //! Optimally (minimum RMSD) align a molecule to another molecule
73 /*!
74  The 3D transformation required to align the specied conformation in the probe
75  molecule
76  to a specified conformation in the reference molecule is computed so that the
77  root mean
78  squared distance between a specified set of atoms is minimized. This
79  transforms is them
80  applied to the specified conformation in the probe molecule
81 
82  \param prbMol molecule that is to be aligned
83  \param refMol molecule used as the reference for the alignment
84  \param prbCid ID of the conformation in the probe to be used
85  for the alignment (defaults to first conformation)
86  \param refCid ID of the conformation in the ref molecule to which
87  the alignment is computed (defaults to first conformation)
88  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
89  used to compute the alignments. If this mapping is
90  not specified an attempt is made to generate on by
91  substructure matching
92  \param weights Optionally specify weights for each of the atom pairs
93  \param reflect if true reflect the conformation of the probe molecule
94  \param maxIters maximum number of iteration used in mimizing the RMSD
95 
96  <b>Returns</b>
97  RMSD value
98 */
100  ROMol &prbMol, const ROMol &refMol, int prbCid = -1, int refCid = -1,
101  const MatchVectType *atomMap = 0,
102  const RDNumeric::DoubleVector *weights = 0, bool reflect = false,
103  unsigned int maxIters = 50);
104 
105 //! Returns the optimal RMS for aligning two molecules, taking
106 // symmetry into account. As a side-effect, the probe molecule is
107 // left in the aligned state.
108 /*!
109  This function will attempt to align all permutations of matching atom
110  orders in both molecules, for some molecules it will lead to 'combinatorial
111  explosion' especially if hydrogens are present.
112  Use 'RDKit::MolAlign::alignMol' to align molecules without changing the
113  atom order.
114 
115  \param probeMol the molecule to be aligned to the reference
116  \param refMol the reference molecule
117  \param probeId (optional) probe conformation to use
118  \param refId (optional) reference conformation to use
119  \param map (optional) a vector of vectors of pairs of atom IDs
120  (probe AtomId, ref AtomId) used to compute the alignments.
121  If not provided, these will be generated using a
122  substructure search.
123  \param maxMatches (optional) if map is empty, this will be the max number of
124  matches found in a SubstructMatch().
125 
126  <b>Returns</b>
127  Best RMSD value found
128 */
130  ROMol &probeMol, ROMol &refMol, int probeId = -1, int refId = -1,
131  const std::vector<MatchVectType> &map = std::vector<MatchVectType>(),
132  int maxMatches = 1e6);
133 
134 //! Align the conformations of a molecule using a common set of atoms. If
135 // the molecules contains queries, then the queries must also match exactly.
136 
137 /*!
138  \param mol The molecule of interest.
139  \param atomIds vector of atoms to be used to generate the alignment.
140  All atoms will be used is not specified
141  \param confIds vector of conformations to align - defaults to all
142  \param weights vector of weights to applied to particular atom pairs
143  defaults to all weights = 1
144  \param reflect toggles reflecting (about the origin) the alignment
145  \param maxIters the maximum number of iterations to attempt
146  \param RMSlist if nonzero, this will be used to return the RMS values
147  between the reference conformation and the other aligned
148  conformations
149 */
151  ROMol &mol, const std::vector<unsigned int> *atomIds = 0,
152  const std::vector<unsigned int> *confIds = 0,
153  const RDNumeric::DoubleVector *weights = 0, bool reflect = false,
154  unsigned int maxIters = 50, std::vector<double> *RMSlist = 0);
155 } // namespace MolAlign
156 } // namespace RDKit
157 #endif
RDKit::MolAlign::MolAlignException::message
const char * message() const
get the error message
Definition: AlignMolecules.h:31
RDKit::MolAlign::MolAlignException::MolAlignException
MolAlignException(const char *msg)
construct with an error message
Definition: AlignMolecules.h:27
RDKit::MolAlign::alignMol
RDKIT_MOLALIGN_EXPORT double alignMol(ROMol &prbMol, const ROMol &refMol, int prbCid=-1, int refCid=-1, const MatchVectType *atomMap=0, const RDNumeric::DoubleVector *weights=0, bool reflect=false, unsigned int maxIters=50)
Optimally (minimum RMSD) align a molecule to another molecule.
Vector.h
RDKIT_MOLALIGN_EXPORT
#define RDKIT_MOLALIGN_EXPORT
Definition: export.h:359
RDKit::MolAlign::MolAlignException::MolAlignException
MolAlignException(const std::string msg)
construct with an error message
Definition: AlignMolecules.h:29
RDKit::MolAlign::MolAlignException
Definition: AlignMolecules.h:24
RDKit::MolAlign::reflect
const RDKIT_MOLALIGN_EXPORT RDGeom::POINT3D_VECT * reflect(const Conformer &conf)
RDNumeric::Vector
A class to represent vectors of numbers.
Definition: Vector.h:29
RDKit::ROMol
Definition: ROMol.h:171
RDKit::MolAlign::MolAlignException::~MolAlignException
~MolAlignException()
Definition: AlignMolecules.h:32
RDKit::MolAlign::alignMolConformers
RDKIT_MOLALIGN_EXPORT void alignMolConformers(ROMol &mol, const std::vector< unsigned int > *atomIds=0, const std::vector< unsigned int > *confIds=0, const RDNumeric::DoubleVector *weights=0, bool reflect=false, unsigned int maxIters=50, std::vector< double > *RMSlist=0)
Align the conformations of a molecule using a common set of atoms. If.
Transform3D.h
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::MolAlign::getAlignmentTransform
RDKIT_MOLALIGN_EXPORT double getAlignmentTransform(const ROMol &prbMol, const ROMol &refMol, RDGeom::Transform3D &trans, int prbCid=-1, int refCid=-1, const MatchVectType *atomMap=0, const RDNumeric::DoubleVector *weights=0, bool reflect=false, unsigned int maxIters=50)
Alignment functions.
RDGeom::Transform3D
Definition: Transform3D.h:22
RDKit::MolAlign::getBestRMS
RDKIT_MOLALIGN_EXPORT double getBestRMS(ROMol &probeMol, ROMol &refMol, int probeId=-1, int refId=-1, const std::vector< MatchVectType > &map=std::vector< MatchVectType >(), int maxMatches=1e6)
Returns the optimal RMS for aligning two molecules, taking.
RDKit::MatchVectType
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx)
Definition: FragFPGenerator.h:24
export.h