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 #ifndef _RD_ALIGNMOLECULES_H_
11 #define _RD_ALIGNMOLECULES_H_
12 
13 #include <Geometry/Transform3D.h>
14 #include <Numerics/Vector.h>
15 #include <vector>
16 
17 namespace RDKit {
18  typedef std::vector< std::pair<int,int> > MatchVectType;
19 
20  class Conformer;
21  class ROMol;
22  namespace MolAlign {
23  class MolAlignException : public std::exception {
24  public:
25  //! construct with an error message
26  MolAlignException(const char *msg) : _msg(msg) {};
27  //! construct with an error message
28  MolAlignException(const std::string msg) : _msg(msg) {};
29  //! get the error message
30  const char *message () const { return _msg.c_str(); };
31  ~MolAlignException () throw () {};
32  private:
33  std::string _msg;
34  };
35 
36  //! Alignment functions
37 
38  //! Compute the transformation required to align a molecule
39  /*!
40  The 3D transformation required to align the specied conformation in the probe molecule
41  to a specified conformation in the reference molecule is computed so that the root mean
42  squared distance between a specified set of atoms is minimized
43 
44  \param prbMol molecule that is to be aligned
45  \param refMol molecule used as the reference for the alignment
46  \param trans storage for the computed transform
47  \param prbCid ID of the conformation in the probe to be used
48  for the alignment (defaults to first conformation)
49  \param refCid ID of the conformation in the ref molecule to which
50  the alignment is computed (defaults to first conformation)
51  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
52  used to compute the alignments. If this mapping is
53  not specified an attempt is made to generate on by
54  substructure matching
55  \param weights Optionally specify weights for each of the atom pairs
56  \param reflect if true reflect the conformation of the probe molecule
57  \param maxIters maximum number of iteration used in mimizing the RMSD
58 
59  <b>Returns</b>
60  RMSD value
61  */
62  double getAlignmentTransform(const ROMol &prbMol, const ROMol &refMol,
63  RDGeom::Transform3D &trans,
64  int prbCid=-1, int refCid=-1,
65  const MatchVectType *atomMap=0,
66  const RDNumeric::DoubleVector *weights=0,
67  bool reflect=false,
68  unsigned int maxIters=50);
69 
70 
71  //! Optimally (minimum RMSD) align a molecule to another molecule
72  /*!
73  The 3D transformation required to align the specied conformation in the probe molecule
74  to a specified conformation in the reference molecule is computed so that the root mean
75  squared distance between a specified set of atoms is minimized. This transforms is them
76  applied to the specified conformation in the probe molecule
77 
78  \param prbMol molecule that is to be aligned
79  \param refMol molecule used as the reference for the alignment
80  \param prbCid ID of the conformation in the probe to be used
81  for the alignment (defaults to first conformation)
82  \param refCid ID of the conformation in the ref molecule to which
83  the alignment is computed (defaults to first conformation)
84  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
85  used to compute the alignments. If this mapping is
86  not specified an attempt is made to generate on by
87  substructure matching
88  \param weights Optionally specify weights for each of the atom pairs
89  \param reflect if true reflect the conformation of the probe molecule
90  \param maxIters maximum number of iteration used in mimizing the RMSD
91 
92  <b>Returns</b>
93  RMSD value
94  */
95  double alignMol(ROMol &prbMol, const ROMol &refMol,
96  int prbCid=-1, int refCid=-1,
97  const MatchVectType *atomMap=0,
98  const RDNumeric::DoubleVector *weights=0,
99  bool reflect=false, unsigned int maxIters=50);
100 
101  //! Align the conformations of a molecule using a common set of atoms
102  /*!
103  \param mol The molecule of interest
104  \param atomIds vector of atoms to be used to generate the alignment.
105  All atoms will be used is not specified
106  \param confIds vector of conformations to align - defaults to all
107  \param weights vector of weights to applied to particular atom pairs
108  defaults to all weights = 1
109  \param reflect toggles reflecting (about the origin) the alignment
110  \param maxIters the maximum number of iterations to attempt
111  \param RMSlist if nonzero, this will be used to return the RMS values
112  between the reference conformation and the other aligned
113  conformations
114  */
115  void alignMolConformers(ROMol &mol, const std::vector<unsigned int> *atomIds=0,
116  const std::vector<unsigned int> *confIds=0,
117  const RDNumeric::DoubleVector *weights=0,
118  bool reflect=false, unsigned int maxIters=50,
119  std::vector<double> *RMSlist=0);
120  }
121 }
122 #endif
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.
const char * message() const
get the error message
MolAlignException(const char *msg)
construct with an error message
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
const RDGeom::POINT3D_VECT * reflect(const Conformer &conf)
MolAlignException(const std::string msg)
construct with an error message
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:105
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
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.
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.
A class to represent vectors of numbers.
Definition: Vector.h:28