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