RDKit
Open-source cheminformatics and machine learning.
MMFF/AtomTyper.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2013 Paolo Tosco
3 //
4 // Copyright (C) 2004-2006 Rational Discovery LLC
5 //
6 // @@ All Rights Reserved @@
7 // This file is part of the RDKit.
8 // The contents are covered by the terms of the BSD license
9 // which is included in the file license.txt, found at the root
10 // of the RDKit source tree.
11 //
12 #ifndef _RD_MMFFATOMTYPER_H__
13 #define _RD_MMFFATOMTYPER_H__
14 
15 #include <vector>
16 #include <string>
17 #include <iostream>
18 #include <ForceField/MMFF/Params.h>
19 #include <boost/cstdint.hpp>
20 
21 
22 namespace RDKit {
23  class ROMol;
24  class RWMol;
25  class Atom;
26  class Bond;
27 
28  namespace MMFF {
29  using namespace ForceFields::MMFF;
31  public:
33  mmffAtomType(0),
34  mmffFormalCharge(0.0),
35  mmffPartialCharge(0.0) {};
37  boost::uint8_t mmffAtomType;
40  };
41 
42  typedef boost::shared_ptr<MMFFAtomProperties> MMFFAtomPropertiesPtr;
43  enum {
44  CONSTANT = 1,
46  };
47  enum {
51  };
53  public:
54  MMFFMolProperties(ROMol &mol, std::string mmffVariant = "MMFF94",
55  boost::uint8_t verbosity = MMFF_VERBOSITY_NONE,
56  std::ostream &oStream = std::cout);
58  unsigned int getMMFFBondType(const Bond *bond);
59  unsigned int getMMFFAngleType(const ROMol &mol,
60  const unsigned int idx1, const unsigned int idx2,
61  const unsigned int idx3);
62  const std::pair<unsigned int, unsigned int> getMMFFTorsionType
63  (const ROMol &mol, const unsigned int idx1, const unsigned int idx2,
64  const unsigned int idx3, const unsigned int idx4);
65  void computeMMFFCharges(const ROMol &mol);
66  const ForceFields::MMFF::MMFFTor *getMMFFTorsionEmpiricalRuleParams
67  (const ROMol &mol, unsigned int idx2, unsigned int idx3);
68  const ForceFields::MMFF::MMFFBond *getMMFFBondStretchEmpiricalRuleParams
69  (const ROMol &mol, const Bond *bond);
70  boost::uint8_t getMMFFAtomType(const unsigned int idx)
71  {
72  RANGE_CHECK(0, idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
73 
74  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffAtomType;
75  };
76  double getMMFFFormalCharge(const unsigned int idx)
77  {
78  RANGE_CHECK(0, idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
79 
80  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffFormalCharge;
81  };
82  double getMMFFPartialCharge(const unsigned int idx)
83  {
84  RANGE_CHECK(0, idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
85 
86  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffPartialCharge;
87  };
88  void setMMFFBondTerm(const bool state)
89  {
90  this->d_bondTerm = state;
91  };
93  {
94  return this->d_bondTerm;
95  };
96  void setMMFFAngleTerm(const bool state)
97  {
98  this->d_angleTerm = state;
99  };
101  {
102  return this->d_angleTerm;
103  };
104  void setMMFFStretchBendTerm(const bool state)
105  {
106  this->d_stretchBendTerm = state;
107  };
109  {
110  return this->d_stretchBendTerm;
111  };
112  void setMMFFOopTerm(const bool state)
113  {
114  this->d_oopTerm = state;
115  };
117  {
118  return this->d_oopTerm;
119  };
120  void setMMFFTorsionTerm(const bool state)
121  {
122  this->d_torsionTerm = state;
123  };
125  {
126  return this->d_torsionTerm;
127  };
128  void setMMFFVdWTerm(const bool state)
129  {
130  this->d_vdWTerm = state;
131  };
133  {
134  return this->d_vdWTerm;
135  };
136  void setMMFFEleTerm(const bool state)
137  {
138  this->d_eleTerm = state;
139  };
141  {
142  return this->d_eleTerm;
143  };
144  void setMMFFVariant(const std::string mmffVariant)
145  {
146  PRECONDITION((mmffVariant == "MMFF94")
147  || (mmffVariant == "MMFF94s"), "bad MMFF variant");
148 
149  this->d_mmffs = ((mmffVariant == "MMFF94s") ? true : false);
150  };
151  const std::string getMMFFVariant()
152  {
153  return (this->d_mmffs ? "MMFF94s" : "MMFF94");
154  };
155  void setMMFFDielectricConstant(const double dielConst)
156  {
157  PRECONDITION(dielConst > 0.0, "bad dielectric constant");
158 
159  this->d_dielConst = dielConst;
160  };
162  {
163  return this->d_dielConst;
164  };
165  void setMMFFDielectricModel(boost::uint8_t dielModel)
166  {
167  this->d_dielModel = dielModel;
168  };
169  boost::uint8_t getMMFFDielectricModel()
170  {
171  return this->d_dielModel;
172  };
173  void setMMFFVerbosity(boost::uint8_t verbosity)
174  {
175  this->d_verbosity = verbosity;
176  };
177  boost::uint8_t getMMFFVerbosity()
178  {
179  return this->d_verbosity;
180  };
181  void setMMFFOStream(std::ostream *oStream)
182  {
183  this->d_oStream = oStream;
184  };
185  std::ostream& getMMFFOStream()
186  {
187  return *(this->d_oStream);
188  };
189  bool isValid()
190  {
191  return d_valid;
192  };
193  bool getMMFFBondStretchParams(const ROMol &mol,
194  const unsigned int idx1, const unsigned int idx2,
195  unsigned int &bondType, MMFFBond &mmffBondStretchParams);
196  bool getMMFFAngleBendParams(const ROMol &mol,
197  const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
198  unsigned int &angleType, MMFFAngle &mmffAngleBendParams);
199  bool getMMFFStretchBendParams(const ROMol &mol,
200  const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
201  unsigned int &stretchBendType, MMFFStbn &mmffStretchBendParams,
202  MMFFBond mmffBondStretchParams[2], MMFFAngle &mmffAngleBendParams);
203  bool getMMFFTorsionParams(const ROMol &mol,
204  const unsigned int idx1, const unsigned int idx2,
205  const unsigned int idx3, const unsigned int idx4,
206  unsigned int &torsionType, MMFFTor &mmffTorsionParams);
207  bool getMMFFOopBendParams(const ROMol &mol,
208  const unsigned int idx1, const unsigned int idx2, const unsigned int idx3,
209  const unsigned int idx4, MMFFOop &mmffOopBendParams);
210  bool getMMFFVdWParams(const unsigned int idx1,
211  const unsigned int idx2, MMFFVdWRijstarEps &mmffVdWParams);
212  private:
213  void setMMFFHeavyAtomType(const Atom *atom);
214  void setMMFFHydrogenType(const Atom *atom);
215  void setMMFFFormalCharge(const unsigned int idx, const double fChg)
216  {
217  RANGE_CHECK(0, idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
218 
219  this->d_MMFFAtomPropertiesPtrVect[idx]->mmffFormalCharge = fChg;
220  };
221  void setMMFFPartialCharge(const unsigned int idx, const double pChg)
222  {
223  RANGE_CHECK(0, idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
224 
225  this->d_MMFFAtomPropertiesPtrVect[idx]->mmffPartialCharge = pChg;
226  };
227  bool d_valid;
228  bool d_mmffs;
229  bool d_bondTerm;
230  bool d_angleTerm;
231  bool d_stretchBendTerm;
232  bool d_oopTerm;
233  bool d_torsionTerm;
234  bool d_vdWTerm;
235  bool d_eleTerm;
236  double d_dielConst; //!< the dielectric constant
237  boost::uint8_t d_dielModel; //!< the dielectric model (1 = constant, 2 = distance-dependent)
238  boost::uint8_t d_verbosity;
239  std::ostream *d_oStream;
240  std::vector<MMFFAtomPropertiesPtr> d_MMFFAtomPropertiesPtrVect;
241  };
242  unsigned int isAngleInRingOfSize3or4(const ROMol &mol, const unsigned int idx1,
243  const unsigned int idx2, const unsigned int idx3);
244  unsigned int isTorsionInRingOfSize4or5(const ROMol &mol, const unsigned int idx1,
245  const unsigned int idx2, const unsigned int idx3, const unsigned int idx4);
246  bool isAtomInAromaticRingOfSize(const Atom *atom, const unsigned int ringSize);
247  bool isAtomNOxide(const Atom *atom);
248  bool areAtomsInSameAromaticRing(const ROMol &mol,
249  const unsigned int idx1, const unsigned int idx2);
250  bool areAtomsInSameRingOfSize(const ROMol &mol,
251  const unsigned int ringSize, const unsigned int numAtoms, ...);
252  unsigned int sanitizeMMFFMol(RWMol &mol);
253  void setMMFFAromaticity(RWMol &mol);
254  unsigned int getMMFFStretchBendType(const unsigned int angleType,
255  const unsigned int bondType1, const unsigned int bondType2);
256  unsigned int getPeriodicTableRow(const int atomicNum);
258  (const ROMol &mol, const ForceFields::MMFF::MMFFAngle *oldMMFFAngleParams,
259  const ForceFields::MMFF::MMFFProp *mmffPropParamsCentralAtom,
260  const ForceFields::MMFF::MMFFBond *mmffBondParams1,
261  const ForceFields::MMFF::MMFFBond *mmffBondParams2,
262  unsigned int idx1, unsigned int idx2, unsigned int idx3);
263  }
264 }
265 
266 
267 #endif
void setMMFFAngleTerm(const bool state)
const std::string getMMFFVariant()
void setMMFFAromaticity(RWMol &mol)
#define RANGE_CHECK(lo, x, hi)
Definition: Invariant.h:133
void setMMFFVdWTerm(const bool state)
class to store MMFF parameters for angle bending
Definition: MMFF/Params.h:111
boost::shared_ptr< MMFFAtomProperties > MMFFAtomPropertiesPtr
void setMMFFDielectricConstant(const double dielConst)
RWMol is a molecule class that is intended to be edited.
Definition: RWMol.h:30
unsigned int getMMFFStretchBendType(const unsigned int angleType, const unsigned int bondType1, const unsigned int bondType2)
void setMMFFBondTerm(const bool state)
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:105
void setMMFFTorsionTerm(const bool state)
bool areAtomsInSameAromaticRing(const ROMol &mol, const unsigned int idx1, const unsigned int idx2)
bool areAtomsInSameRingOfSize(const ROMol &mol, const unsigned int ringSize, const unsigned int numAtoms,...)
unsigned int isTorsionInRingOfSize4or5(const ROMol &mol, const unsigned int idx1, const unsigned int idx2, const unsigned int idx3, const unsigned int idx4)
unsigned int sanitizeMMFFMol(RWMol &mol)
class to store MMFF parameters for stretch-bending
Definition: MMFF/Params.h:118
unsigned int getPeriodicTableRow(const int atomicNum)
class to store MMFF parameters for bond stretching
Definition: MMFF/Params.h:87
void setMMFFStretchBendTerm(const bool state)
double getMMFFFormalCharge(const unsigned int idx)
class to store MMFF parameters for out-of-plane bending
Definition: MMFF/Params.h:125
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
void setMMFFVerbosity(boost::uint8_t verbosity)
void setMMFFOopTerm(const bool state)
double getMMFFPartialCharge(const unsigned int idx)
unsigned int isAngleInRingOfSize3or4(const ROMol &mol, const unsigned int idx1, const unsigned int idx2, const unsigned int idx3)
class for representing a bond
Definition: Bond.h:46
void setMMFFEleTerm(const bool state)
bool isAtomInAromaticRingOfSize(const Atom *atom, const unsigned int ringSize)
boost::uint8_t getMMFFAtomType(const unsigned int idx)
void setMMFFOStream(std::ostream *oStream)
#define PRECONDITION(expr, mess)
Definition: Invariant.h:119
const ForceFields::MMFF::MMFFAngle * getMMFFAngleBendEmpiricalRuleParams(const ROMol &mol, const ForceFields::MMFF::MMFFAngle *oldMMFFAngleParams, const ForceFields::MMFF::MMFFProp *mmffPropParamsCentralAtom, const ForceFields::MMFF::MMFFBond *mmffBondParams1, const ForceFields::MMFF::MMFFBond *mmffBondParams2, unsigned int idx1, unsigned int idx2, unsigned int idx3)
class to store MMFF parameters for torsions
Definition: MMFF/Params.h:131
void setMMFFVariant(const std::string mmffVariant)
void setMMFFDielectricModel(boost::uint8_t dielModel)
bool isAtomNOxide(const Atom *atom)
The class for representing atoms.
Definition: Atom.h:67
boost::uint8_t getMMFFDielectricModel()
class to store MMFF Properties
Definition: MMFF/Params.h:60