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 
33  private:
34  std::string _msg;
35 };
36 
37 //! Alignment functions
38 
39 //! Compute the transformation required to align a molecule
40 /*!
41  The 3D transformation required to align the specied conformation in the probe
42  molecule
43  to a specified conformation in the reference molecule is computed so that the
44  root mean
45  squared distance between a specified set of atoms is minimized
46 
47  \param prbMol molecule that is to be aligned
48  \param refMol molecule used as the reference for the alignment
49  \param trans storage for the computed transform
50  \param prbCid ID of the conformation in the probe to be used
51  for the alignment (defaults to first conformation)
52  \param refCid ID of the conformation in the ref molecule to which
53  the alignment is computed (defaults to first conformation)
54  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
55  used to compute the alignments. If this mapping is
56  not specified an attempt is made to generate on by
57  substructure matching
58  \param weights Optionally specify weights for each of the atom pairs
59  \param reflect if true reflect the conformation of the probe molecule
60  \param maxIters maximum number of iteration used in mimizing the RMSD
61 
62  <b>Returns</b>
63  RMSD value
64 */
65 double getAlignmentTransform(const ROMol &prbMol, const ROMol &refMol,
66  RDGeom::Transform3D &trans, int prbCid = -1,
67  int refCid = -1, const MatchVectType *atomMap = 0,
68  const RDNumeric::DoubleVector *weights = 0,
69  bool reflect = false, unsigned int maxIters = 50);
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
74  molecule
75  to a specified conformation in the reference molecule is computed so that the
76  root mean
77  squared distance between a specified set of atoms is minimized. This
78  transforms is them
79  applied to the specified conformation in the probe molecule
80 
81  \param prbMol molecule that is to be aligned
82  \param refMol molecule used as the reference for the alignment
83  \param prbCid ID of the conformation in the probe to be used
84  for the alignment (defaults to first conformation)
85  \param refCid ID of the conformation in the ref molecule to which
86  the alignment is computed (defaults to first conformation)
87  \param atomMap a vector of pairs of atom IDs (probe AtomId, ref AtomId)
88  used to compute the alignments. If this mapping is
89  not specified an attempt is made to generate on by
90  substructure matching
91  \param weights Optionally specify weights for each of the atom pairs
92  \param reflect if true reflect the conformation of the probe molecule
93  \param maxIters maximum number of iteration used in mimizing the RMSD
94 
95  <b>Returns</b>
96  RMSD value
97 */
98 double alignMol(ROMol &prbMol, const ROMol &refMol, int prbCid = -1,
99  int refCid = -1, const MatchVectType *atomMap = 0,
100  const RDNumeric::DoubleVector *weights = 0,
101  bool reflect = false, unsigned int maxIters = 50);
102 
103 //! Align the conformations of a molecule using a common set of atoms. If
104 // the molecules contains queries, then the queries must also match exactly.
105 
106 /*!
107  \param mol The molecule of interest.
108  \param atomIds vector of atoms to be used to generate the alignment.
109  All atoms will be used is not specified
110  \param confIds vector of conformations to align - defaults to all
111  \param weights vector of weights to applied to particular atom pairs
112  defaults to all weights = 1
113  \param reflect toggles reflecting (about the origin) the alignment
114  \param maxIters the maximum number of iterations to attempt
115  \param RMSlist if nonzero, this will be used to return the RMS values
116  between the reference conformation and the other aligned
117  conformations
118 */
119 void alignMolConformers(ROMol &mol,
120  const std::vector<unsigned int> *atomIds = 0,
121  const std::vector<unsigned int> *confIds = 0,
122  const RDNumeric::DoubleVector *weights = 0,
123  bool reflect = false, unsigned int maxIters = 50,
124  std::vector<double> *RMSlist = 0);
125 }
126 }
127 #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. If.
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:103
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29
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