RDKit: AlignMolecules.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 //! Returns the optimal RMS for aligning two molecules, taking
104 // symmetry into account. As a side-effect, the probe molecule is
105 // left in the aligned state.
106 /*!
107 This function will attempt to align all permutations of matching atom
108 orders in both molecules, for some molecules it will lead to 'combinatorial
109 explosion' especially if hydrogens are present.
110 Use 'RDKit::MolAlign::alignMol' to align molecules without changing the
111 atom order.
112
113 \param probeMol the molecule to be aligned to the reference
114 \param refMol the reference molecule
115 \param probeId (optional) probe conformation to use
116 \param refId (optional) reference conformation to use
117 \param map (optional) a vector of vectors of pairs of atom IDs
118 (probe AtomId, ref AtomId) used to compute the alignments.
119 If not provided, these will be generated using a
120 substructure search.
121 \param maxMatches (optional) if map is empty, this will be the max number of
122 matches found in a SubstructMatch().
123
124 <b>Returns</b>
125 Best RMSD value found
126 */
127 double getBestRMS(ROMol& probeMol, ROMol& refMol,
128 int probeId = -1, int refId = -1,
129 const std::vector<MatchVectType>& map =
130 std::vector<MatchVectType>(),
131 int maxMatches = 1e6);
132
133 //! Align the conformations of a molecule using a common set of atoms. If
134 // the molecules contains queries, then the queries must also match exactly.
135
136 /*!
137 \param mol The molecule of interest.
138 \param atomIds vector of atoms to be used to generate the alignment.
139 All atoms will be used is not specified
140 \param confIds vector of conformations to align - defaults to all
141 \param weights vector of weights to applied to particular atom pairs
142 defaults to all weights = 1
143 \param reflect toggles reflecting (about the origin) the alignment
144 \param maxIters the maximum number of iterations to attempt
145 \param RMSlist if nonzero, this will be used to return the RMS values
146 between the reference conformation and the other aligned
147 conformations
148 */
149 void alignMolConformers(ROMol &mol,
150 const std::vector<unsigned int> *atomIds = 0,
151 const std::vector<unsigned int> *confIds = 0,
152 const RDNumeric::DoubleVector *weights = 0,
153 bool reflect = false, unsigned int maxIters = 50,
154 std::vector<double> *RMSlist = 0);
155 }
156 }
157 #endif
RDKit::MolAlign::getBestRMS
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::MolAlign::alignMolConformers
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.
RDKit::MolAlign::MolAlignException::message
const char * message() const
get the error message
Definition: AlignMolecules.h:30
RDKit::MolAlign::MolAlignException::MolAlignException
MolAlignException(const char *msg)
construct with an error message
Definition: AlignMolecules.h:26
RDKit::MatchVectType
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
Definition: FragFPGenerator.h:23
RDKit::MolAlign::reflect
const RDGeom::POINT3D_VECT * reflect(const Conformer &conf)
RDKit::MolAlign::MolAlignException::MolAlignException
MolAlignException(const std::string msg)
construct with an error message
Definition: AlignMolecules.h:28
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
RDKit
Std stuff.
Definition: Atom.h:29
Transform3D.h
Vector.h
RDKit::MolAlign::MolAlignException
Definition: AlignMolecules.h:23
RDGeom::Transform3D
Definition: Transform3D.h:21
RDKit::MolAlign::alignMol
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.
RDKit::MolAlign::getAlignmentTransform
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.
RDNumeric::Vector
A class to represent vectors of numbers.
Definition: Vector.h:28
RDKit::MolAlign::MolAlignException::~MolAlignException
~MolAlignException()
Definition: AlignMolecules.h:31