RDKit
Open-source cheminformatics and machine learning.
MMFF.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2015-2018 Greg Landrum
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #include <RDGeneral/export.h>
11 #ifndef RD_MMFFCONVENIENCE_H
12 #define RD_MMFFCONVENIENCE_H
13 #include <ForceField/ForceField.h>
15 #include <RDGeneral/RDThreads.h>
16 #include "AtomTyper.h"
17 #include "Builder.h"
18 
19 namespace RDKit {
20 class ROMol;
21 namespace MMFF {
22 //! Convenience function for optimizing a molecule using MMFF
23 /*
24  \param mol the molecule to use
25  \param maxIters the maximum number of force-field iterations
26  \param mmffVariant the MMFF variant to use, should be "MMFF94" or "MMFF94S"
27  \param nonBondedThresh the threshold to be used in adding non-bonded terms
28  to the force field. Any non-bonded contact whose
29  current
30  distance is greater than \c nonBondedThresh * the minimum
31  value
32  for that contact will not be included.
33  \param confId the optional conformer id, if this isn't provided, the
34  molecule's
35  default confId will be used.
36  \param ignoreInterfragInteractions if true, nonbonded terms will not be added
37  between
38  fragments
39 
40  \return a pair with:
41  first: -1 if parameters were missing, 0 if the optimization converged, 1 if
42  more iterations are required.
43  second: the energy
44 */
45 std::pair<int, double> MMFFOptimizeMolecule(
46  ROMol &mol, int maxIters = 1000, std::string mmffVariant = "MMFF94",
47  double nonBondedThresh = 10.0, int confId = -1,
48  bool ignoreInterfragInteractions = true) {
49  std::pair<int, double> res = std::make_pair(-1, -1);
50  MMFF::MMFFMolProperties mmffMolProperties(mol, mmffVariant);
51  if (mmffMolProperties.isValid()) {
53  mol, nonBondedThresh, confId, ignoreInterfragInteractions);
54  res = ForceFieldsHelper::OptimizeMolecule(*ff, maxIters);
55  delete ff;
56  }
57  return res;
58 }
59 
60 //! Convenience function for optimizing all of a molecule's conformations using
61 // MMFF
62 /*
63  \param mol the molecule to use
64  \param res vector of (needsMore,energy) pairs
65  \param numThreads the number of simultaneous threads to use (only has an
66  effect if the RDKit is compiled with thread support).
67  If set to zero, the max supported by the system will be
68  used.
69  \param maxIters the maximum number of force-field iterations
70  \param mmffVariant the MMFF variant to use, should be "MMFF94" or "MMFF94S"
71  \param nonBondedThresh the threshold to be used in adding non-bonded terms
72  to the force field. Any non-bonded contact whose
73  current
74  distance is greater than \c nonBondedThresh * the minimum
75  value
76  for that contact will not be included.
77  \param ignoreInterfragInteractions if true, nonbonded terms will not be added
78  between
79  fragments
80 
81 */
83  std::vector<std::pair<int, double>> &res,
84  int numThreads = 1, int maxIters = 1000,
85  std::string mmffVariant = "MMFF94",
86  double nonBondedThresh = 10.0,
87  bool ignoreInterfragInteractions = true) {
88  MMFF::MMFFMolProperties mmffMolProperties(mol, mmffVariant);
89  if (mmffMolProperties.isValid()) {
91  mol, &mmffMolProperties, nonBondedThresh, -1, ignoreInterfragInteractions);
92  ForceFieldsHelper::OptimizeMoleculeConfs(mol, *ff, res, numThreads, maxIters);
93  delete ff;
94  } else {
95  for (unsigned int i = 0; i < mol.getNumConformers(); ++i) {
96  res[i] = std::make_pair(static_cast<int>(-1), static_cast<double>(-1));
97  }
98  }
99 }
100 } // namespace MMFF
101 } // end of namespace RDKit
102 #endif
Builder.h
RDKit::MMFF::MMFFOptimizeMolecule
std::pair< int, double > MMFFOptimizeMolecule(ROMol &mol, int maxIters=1000, std::string mmffVariant="MMFF94", double nonBondedThresh=10.0, int confId=-1, bool ignoreInterfragInteractions=true)
Convenience function for optimizing a molecule using MMFF.
Definition: MMFF.h:45
RDKit::ROMol::getNumConformers
unsigned int getNumConformers() const
Definition: ROMol.h:443
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition: ForceField.h:79
RDKit::MMFF::constructForceField
RDKIT_FORCEFIELDHELPERS_EXPORT ForceFields::ForceField * constructForceField(ROMol &mol, double nonBondedThresh=100.0, int confId=-1, bool ignoreInterfragInteractions=true)
Builds and returns a MMFF force field for a molecule.
RDKit::ROMol
Definition: ROMol.h:171
AtomTyper.h
FFConvenience.h
RDKit::ForceFieldsHelper::OptimizeMolecule
std::pair< int, double > OptimizeMolecule(ForceFields::ForceField &ff, int maxIters=1000)
Convenience function for optimizing a molecule using a pre-generated force-field.
Definition: FFConvenience.h:86
RDThreads.h
RDKit::MMFF::MMFFOptimizeMoleculeConfs
void MMFFOptimizeMoleculeConfs(ROMol &mol, std::vector< std::pair< int, double >> &res, int numThreads=1, int maxIters=1000, std::string mmffVariant="MMFF94", double nonBondedThresh=10.0, bool ignoreInterfragInteractions=true)
Convenience function for optimizing all of a molecule's conformations using.
Definition: MMFF.h:82
RDKit::MMFF::MMFFMolProperties
Definition: MMFF/AtomTyper.h:64
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::ForceFieldsHelper::OptimizeMoleculeConfs
void OptimizeMoleculeConfs(ROMol &mol, ForceFields::ForceField &ff, std::vector< std::pair< int, double >> &res, int numThreads=1, int maxIters=1000)
Convenience function for optimizing all of a molecule's conformations using.
Definition: FFConvenience.h:106
ForceField.h
RDKit::MMFF::MMFFMolProperties::isValid
bool isValid()
Definition: MMFF/AtomTyper.h:138
export.h