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