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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
|
//
// Copyright (C) 2007-2012 Greg Landrum
//
// @@ 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.
//
/*! \file AtomPairs.h
*/
#ifndef __RD_ATOMPAIRS_H__
#define __RD_ATOMPAIRS_H__
#include <DataStructs/SparseIntVect.h>
#include <DataStructs/BitVects.h>
#include <boost/cstdint.hpp>
namespace RDKit {
class Atom;
namespace AtomPairs {
const std::string atomPairsVersion="1.1.0";
const unsigned int numTypeBits=4;
const unsigned int atomNumberTypes[1<<numTypeBits]={5,6,7,8,9,14,15,16,17,33,34,35,51,52,43};
const unsigned int numPiBits=2;
const unsigned int maxNumPi=(1<<numPiBits)-1;
const unsigned int numBranchBits=3;
const unsigned int maxNumBranches=(1<<numBranchBits)-1;
const unsigned int codeSize=numTypeBits+numPiBits+numBranchBits;
const unsigned int numPathBits=5;
const unsigned int maxPathLen=(1<<numPathBits)-1;
const unsigned int numAtomPairFingerprintBits=numPathBits+2*codeSize;
//! returns a numeric code for the atom (the atom's hash in the
//! atom-pair scheme)
/*!
\param atom the atom to be considered
\param branchSubtract (optional) a constant to subtract from
the number of neighbors when the hash
is calculated (used in the topological
torsions code)
*/
boost::uint32_t getAtomCode(const Atom *atom,unsigned int branchSubtract=0);
//! returns an atom pair hash based on two atom hashes and the
//! distance between the atoms.
/*!
\param codeI the hash for the first atom
\param codeJ the hash for the second atom
\param dist the distance (number of bonds) between the two
atoms
*/
boost::uint32_t getAtomPairCode(boost::uint32_t codeI,boost::uint32_t codeJ,
unsigned int dist);
//! returns the atom-pair fingerprint for a molecule
/*!
The algorithm used is described here:
R.E. Carhart, D.H. Smith, R. Venkataraghavan; "Atom Pairs as
Molecular Features in Structure-Activity Studies: Definition
and Applications" JCICS 25, 64-73 (1985).
\param mol: the molecule to be fingerprinted
\param minLength: minimum distance between atoms to be
considered in a pair. Default is 1 bond.
\param maxLength: maximum distance between atoms to be
considered in a pair.
Default is maxPathLen-1 bonds.
\param fromAtoms: if provided, only atom pairs that involve
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any atom pairs that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
SparseIntVect<boost::int32_t> *
getAtomPairFingerprint(const ROMol &mol,
unsigned int minLength,unsigned int maxLength,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0);
//! \overload
SparseIntVect<boost::int32_t> *
getAtomPairFingerprint(const ROMol &mol,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0);
//! returns the hashed atom-pair fingerprint for a molecule
/*!
\param mol: the molecule to be fingerprinted
\param nBits: the length of the fingerprint to generate
\param minLength: minimum distance between atoms to be
considered in a pair. Default is 1 bond.
\param maxLength: maximum distance between atoms to be
considered in a pair.
Default is maxPathLen-1 bonds.
\param fromAtoms: if provided, only atom pairs that involve
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any atom pairs that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
SparseIntVect<boost::int32_t> *
getHashedAtomPairFingerprint(const ROMol &mol,
unsigned int nBits=2048,
unsigned int minLength=1,
unsigned int maxLength=maxPathLen-1,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0);
//! returns the hashed atom-pair fingerprint for a molecule as a bit vector
/*!
\param mol: the molecule to be fingerprinted
\param nBits: the length of the fingerprint to generate
\param minLength: minimum distance between atoms to be
considered in a pair. Default is 1 bond.
\param maxLength: maximum distance between atoms to be
considered in a pair.
Default is maxPathLen-1 bonds.
\param fromAtoms: if provided, only atom pairs that involve
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any atom pairs that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\param nBitsPerEntry: number of bits to use in simulating counts
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
ExplicitBitVect *
getHashedAtomPairFingerprintAsBitVect(const ROMol &mol,
unsigned int nBits=2048,
unsigned int minLength=1,
unsigned int maxLength=maxPathLen-1,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0,
unsigned int nBitsPerEntry=4);
//! returns an topological torsion hash based on the atom hashes
//! passed in
/*!
\param atomCodes the vector of atom hashes
*/
boost::uint64_t getTopologicalTorsionCode(const std::vector<boost::uint32_t> &atomCodes);
//! returns the topological-torsion fingerprint for a molecule
/*!
The algorithm used is described here:
R. Nilakantan, N. Bauman, J. S. Dixon, R. Venkataraghavan;
"Topological Torsion: A New Molecular Descriptor for SAR Applications.
Comparison with Other Descriptors" JCICS 27, 82-85 (1987).
\param mol: the molecule to be fingerprinted
\param targetSize: the number of atoms to include in the "torsions"
\param fromAtoms: if provided, only torsions that start or end at
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any torsions that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
SparseIntVect<boost::int64_t > *
getTopologicalTorsionFingerprint(const ROMol &mol,
unsigned int targetSize=4,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0
);
//! returns a hashed topological-torsion fingerprint for a molecule
/*!
The algorithm used is described here:
R. Nilakantan, N. Bauman, J. S. Dixon, R. Venkataraghavan;
"Topological Torsion: A New Molecular Descriptor for SAR Applications.
Comparison with Other Descriptors" JCICS 27, 82-85 (1987).
\param mol: the molecule to be fingerprinted
\param nBits: number of bits to include in the fingerprint
\param targetSize: the number of atoms to include in the "torsions"
\param fromAtoms: if provided, only torsions that start or end at
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any torsions that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
SparseIntVect<boost::int64_t > *
getHashedTopologicalTorsionFingerprint(const ROMol &mol,
unsigned int nBits=2048,
unsigned int targetSize=4,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0);
//! returns a hashed topological-torsion fingerprint for a molecule as a bit vector
/*!
\param mol: the molecule to be fingerprinted
\param nBits: number of bits to include in the fingerprint
\param targetSize: the number of atoms to include in the "torsions"
\param fromAtoms: if provided, only torsions that start or end at
the specified atoms will be included in the
fingerprint
\param ignoreAtoms: if provided, any torsions that include
the specified atoms will not be included in the
fingerprint
\param atomInvariants: a list of invariants to use for the atom hashes
note: only the first \c codeSize bits of each
invariant are used.
\param nBitsPerEntry: number of bits to use in simulating counts
\return a pointer to the fingerprint. The client is
responsible for calling delete on this.
*/
ExplicitBitVect *
getHashedTopologicalTorsionFingerprintAsBitVect(const ROMol &mol,
unsigned int nBits=2048,
unsigned int targetSize=4,
const std::vector<boost::uint32_t> *fromAtoms=0,
const std::vector<boost::uint32_t> *ignoreAtoms=0,
const std::vector<boost::uint32_t> *atomInvariants=0,
unsigned int nBitsPerEntry=4);
}
}
#endif
|