RDKit
Open-source cheminformatics and machine learning.
MMFF/AtomTyper.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2013-2016 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 namespace RDKit {
22 class ROMol;
23 class RWMol;
24 class Atom;
25 class Bond;
26 
27 namespace MMFF {
28 class RingMembershipSize;
29 using namespace ForceFields::MMFF;
31  public:
33  : mmffAtomType(0), mmffFormalCharge(0.0), mmffPartialCharge(0.0){};
35  boost::uint8_t mmffAtomType;
38 };
39 
40 typedef boost::shared_ptr<MMFFAtomProperties> MMFFAtomPropertiesPtr;
41 enum { CONSTANT = 1, DISTANCE = 2 };
42 enum {
46 };
48  public:
49  MMFFMolProperties(ROMol &mol, const std::string &mmffVariant = "MMFF94",
50  boost::uint8_t verbosity = MMFF_VERBOSITY_NONE,
51  std::ostream &oStream = std::cout);
53  unsigned int getMMFFBondType(const Bond *bond);
54  unsigned int getMMFFAngleType(const ROMol &mol, const unsigned int idx1,
55  const unsigned int idx2,
56  const unsigned int idx3);
57  const std::pair<unsigned int, unsigned int> getMMFFTorsionType(
58  const ROMol &mol, const unsigned int idx1, const unsigned int idx2,
59  const unsigned int idx3, const unsigned int idx4);
60  void computeMMFFCharges(const ROMol &mol);
61  const ForceFields::MMFF::MMFFTor *getMMFFTorsionEmpiricalRuleParams(
62  const ROMol &mol, unsigned int idx2, unsigned int idx3);
63  const ForceFields::MMFF::MMFFBond *getMMFFBondStretchEmpiricalRuleParams(
64  const ROMol &mol, const Bond *bond);
65  boost::uint8_t getMMFFAtomType(const unsigned int idx) {
66  URANGE_CHECK(idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
67 
68  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffAtomType;
69  };
70  double getMMFFFormalCharge(const unsigned int idx) {
71  URANGE_CHECK(idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
72 
73  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffFormalCharge;
74  };
75  double getMMFFPartialCharge(const unsigned int idx) {
76  URANGE_CHECK(idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
77 
78  return this->d_MMFFAtomPropertiesPtrVect[idx]->mmffPartialCharge;
79  };
80  void setMMFFBondTerm(const bool state) { this->d_bondTerm = state; };
81  bool getMMFFBondTerm() { return this->d_bondTerm; };
82  void setMMFFAngleTerm(const bool state) { this->d_angleTerm = state; };
83  bool getMMFFAngleTerm() { return this->d_angleTerm; };
84  void setMMFFStretchBendTerm(const bool state) {
85  this->d_stretchBendTerm = state;
86  };
87  bool getMMFFStretchBendTerm() { return this->d_stretchBendTerm; };
88  void setMMFFOopTerm(const bool state) { this->d_oopTerm = state; };
89  bool getMMFFOopTerm() { return this->d_oopTerm; };
90  void setMMFFTorsionTerm(const bool state) { this->d_torsionTerm = state; };
91  bool getMMFFTorsionTerm() { return this->d_torsionTerm; };
92  void setMMFFVdWTerm(const bool state) { this->d_vdWTerm = state; };
93  bool getMMFFVdWTerm() { return this->d_vdWTerm; };
94  void setMMFFEleTerm(const bool state) { this->d_eleTerm = state; };
95  bool getMMFFEleTerm() { return this->d_eleTerm; };
96  void setMMFFVariant(const std::string &mmffVariant) {
97  PRECONDITION((mmffVariant == "MMFF94") || (mmffVariant == "MMFF94s"),
98  "bad MMFF variant");
99 
100  this->d_mmffs = ((mmffVariant == "MMFF94s") ? true : false);
101  };
102  const std::string getMMFFVariant() {
103  return (this->d_mmffs ? "MMFF94s" : "MMFF94");
104  };
105  void setMMFFDielectricConstant(const double dielConst) {
106  PRECONDITION(dielConst > 0.0, "bad dielectric constant");
107 
108  this->d_dielConst = dielConst;
109  };
110  double getMMFFDielectricConstant() { return this->d_dielConst; };
111  void setMMFFDielectricModel(boost::uint8_t dielModel) {
112  this->d_dielModel = dielModel;
113  };
114  boost::uint8_t getMMFFDielectricModel() { return this->d_dielModel; };
115  void setMMFFVerbosity(boost::uint8_t verbosity) {
116  this->d_verbosity = verbosity;
117  };
118  boost::uint8_t getMMFFVerbosity() { return this->d_verbosity; };
119  void setMMFFOStream(std::ostream *oStream) { this->d_oStream = oStream; };
120  std::ostream &getMMFFOStream() { return *(this->d_oStream); };
121  bool isValid() { return d_valid; };
122  bool getMMFFBondStretchParams(const ROMol &mol, const unsigned int idx1,
123  const unsigned int idx2, unsigned int &bondType,
124  MMFFBond &mmffBondStretchParams);
125  bool getMMFFAngleBendParams(const ROMol &mol, const unsigned int idx1,
126  const unsigned int idx2, const unsigned int idx3,
127  unsigned int &angleType,
128  MMFFAngle &mmffAngleBendParams);
129  bool getMMFFStretchBendParams(const ROMol &mol, const unsigned int idx1,
130  const unsigned int idx2,
131  const unsigned int idx3,
132  unsigned int &stretchBendType,
133  MMFFStbn &mmffStretchBendParams,
134  MMFFBond mmffBondStretchParams[2],
135  MMFFAngle &mmffAngleBendParams);
136  bool getMMFFTorsionParams(const ROMol &mol, const unsigned int idx1,
137  const unsigned int idx2, const unsigned int idx3,
138  const unsigned int idx4, unsigned int &torsionType,
139  MMFFTor &mmffTorsionParams);
140  bool getMMFFOopBendParams(const ROMol &mol, const unsigned int idx1,
141  const unsigned int idx2, const unsigned int idx3,
142  const unsigned int idx4,
143  MMFFOop &mmffOopBendParams);
144  bool getMMFFVdWParams(const unsigned int idx1, const unsigned int idx2,
145  MMFFVdWRijstarEps &mmffVdWParams);
146 
147  private:
148  void setMMFFHeavyAtomType(const RingMembershipSize &rmSize, const Atom *atom);
149  void setMMFFHydrogenType(const Atom *atom);
150  void setMMFFFormalCharge(const unsigned int idx, const double fChg) {
151  URANGE_CHECK(idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
152 
153  this->d_MMFFAtomPropertiesPtrVect[idx]->mmffFormalCharge = fChg;
154  };
155  void setMMFFPartialCharge(const unsigned int idx, const double pChg) {
156  URANGE_CHECK(idx, this->d_MMFFAtomPropertiesPtrVect.size() - 1);
157 
158  this->d_MMFFAtomPropertiesPtrVect[idx]->mmffPartialCharge = pChg;
159  };
160  bool d_valid;
161  bool d_mmffs;
162  bool d_bondTerm;
163  bool d_angleTerm;
164  bool d_stretchBendTerm;
165  bool d_oopTerm;
166  bool d_torsionTerm;
167  bool d_vdWTerm;
168  bool d_eleTerm;
169  double d_dielConst; //!< the dielectric constant
170  boost::uint8_t d_dielModel; //!< the dielectric model (1 = constant, 2 =
171  // distance-dependent)
172  boost::uint8_t d_verbosity;
173  std::ostream *d_oStream;
174  std::vector<MMFFAtomPropertiesPtr> d_MMFFAtomPropertiesPtrVect;
175 };
176 unsigned int isAngleInRingOfSize3or4(const ROMol &mol, const unsigned int idx1,
177  const unsigned int idx2,
178  const unsigned int idx3);
179 unsigned int isTorsionInRingOfSize4or5(const ROMol &mol,
180  const unsigned int idx1,
181  const unsigned int idx2,
182  const unsigned int idx3,
183  const unsigned int idx4);
184 bool isRingAromatic(const ROMol &mol, const INT_VECT &ringIndxVect);
185 bool isAtomInAromaticRingOfSize(const Atom *atom, const unsigned int ringSize);
186 bool isAtomNOxide(const Atom *atom);
187 bool areAtomsInSameAromaticRing(const ROMol &mol, const unsigned int idx1,
188  const unsigned int idx2);
189 bool areAtomsInSameRingOfSize(const ROMol &mol, const unsigned int ringSize,
190  const unsigned int numAtoms, ...);
191 unsigned int sanitizeMMFFMol(RWMol &mol);
192 void setMMFFAromaticity(RWMol &mol);
193 unsigned int getMMFFStretchBendType(const unsigned int angleType,
194  const unsigned int bondType1,
195  const unsigned int bondType2);
196 unsigned int getPeriodicTableRow(const int atomicNum);
198  const ROMol &mol, const ForceFields::MMFF::MMFFAngle *oldMMFFAngleParams,
199  const ForceFields::MMFF::MMFFProp *mmffPropParamsCentralAtom,
200  const ForceFields::MMFF::MMFFBond *mmffBondParams1,
201  const ForceFields::MMFF::MMFFBond *mmffBondParams2, unsigned int idx1,
202  unsigned int idx2, unsigned int idx3);
203 }
204 }
205 
206 #endif
void setMMFFAngleTerm(const bool state)
const std::string getMMFFVariant()
void setMMFFAromaticity(RWMol &mol)
void setMMFFVdWTerm(const bool state)
class to store MMFF parameters for angle bending
Definition: MMFF/Params.h:110
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:106
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)
std::vector< int > INT_VECT
Definition: types.h:190
class to store MMFF parameters for stretch-bending
Definition: MMFF/Params.h:117
unsigned int getPeriodicTableRow(const int atomicNum)
class to store MMFF parameters for bond stretching
Definition: MMFF/Params.h:86
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:124
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29
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)
#define URANGE_CHECK(x, hi)
Definition: Invariant.h:140
class for representing a bond
Definition: Bond.h:47
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)
void setMMFFVariant(const std::string &mmffVariant)
#define PRECONDITION(expr, mess)
Definition: Invariant.h:107
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:130
bool isRingAromatic(const ROMol &mol, const INT_VECT &ringIndxVect)
void setMMFFDielectricModel(boost::uint8_t dielModel)
bool isAtomNOxide(const Atom *atom)
The class for representing atoms.
Definition: Atom.h:68
boost::uint8_t getMMFFDielectricModel()
class to store MMFF Properties
Definition: MMFF/Params.h:59