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
|
// $Id: rdForceFields.cpp 1528 2010-09-26 17:04:37Z glandrum $
//
// Copyright (C) 2004-2008 Greg Landrum and Rational Discovery LLC
//
// @@ 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.
//
#include <boost/python.hpp>
#include <GraphMol/GraphMol.h>
#include <RDBoost/Wrap.h>
#include <ForceField/ForceField.h>
#include <ForceField/Wrap/PyForceField.h>
#include <GraphMol/ForceFieldHelpers/UFF/AtomTyper.h>
#include <GraphMol/ForceFieldHelpers/UFF/Builder.h>
namespace python = boost::python;
namespace RDKit {
int UFFOptimizeMolecule(ROMol &mol, int maxIters=200,
double vdwThresh=10.0, int confId=-1,
bool ignoreInterfragInteractions=true ){
ForceFields::ForceField *ff=UFF::constructForceField(mol,vdwThresh, confId,
ignoreInterfragInteractions);
ff->initialize();
int res=ff->minimize(maxIters);
delete ff;
return res;
}
ForceFields::PyForceField *UFFGetMoleculeForceField(ROMol &mol,
double vdwThresh=10.0,
int confId=-1,
bool ignoreInterfragInteractions=true ){
ForceFields::ForceField *ff=UFF::constructForceField(mol,vdwThresh, confId,
ignoreInterfragInteractions);
ForceFields::PyForceField *res=new ForceFields::PyForceField(ff);
res->initialize();
return res;
}
bool UFFHasAllMoleculeParams(const ROMol &mol){
UFF::AtomicParamVect types;
bool foundAll;
boost::tie(types,foundAll)=UFF::getAtomTypes(mol);
return foundAll;
}
}
BOOST_PYTHON_MODULE(rdForceFieldHelpers) {
python::scope().attr("__doc__") =
"Module containing functions to handle molecular force fields (currently UFF)"
;
std::string docString = "Use UFF to optimize a molecule's structure\n\n\
\n\
ARGUMENTS:\n\n\
- mol : the molecule of interrest\n\
- maxIters : the maximum number of iterations (defaults to 100)\n\
- vdwThresh : used to exclude long-range van der Waals interactions\n\
(defaults to 10.0)\n\
- confId : indicates which conformer to optimize\n\
- ignoreInterfragInteractions : if true, nonbonded terms between \n\
fragments will not be added to the forcefield.\n\
\n\
RETURNS: 0 if the optimization converged, 1 if more iterations are required.\n\
\n";
python::def("UFFOptimizeMolecule", RDKit::UFFOptimizeMolecule,
(python::arg("self"),python::arg("maxIters")=200,
python::arg("vdwThresh")=10.0,python::arg("confId")=-1,
python::arg("ignoreInterfragInteractions")=true),
docString.c_str());
docString = "returns a UFF force field for a molecule\n\n\
\n\
ARGUMENTS:\n\n\
- mol : the molecule of interrest\n\
- vdwThresh : used to exclude long-range van der Waals interactions\n\
(defaults to 10.0)\n\
- confId : indicates which conformer to optimize\n\
- ignoreInterfragInteractions : if true, nonbonded terms between \n\
fragments will not be added to the forcefield.\n\
\n";
python::def("UFFGetMoleculeForceField", RDKit::UFFGetMoleculeForceField,
(python::arg("mol"),python::arg("vdwThresh")=10.0,python::arg("confId")=-1,
python::arg("ignoreInterfragInteractions")=true),
python::return_value_policy<python::manage_new_object>(),
docString.c_str());
docString = "checks if UFF parameters are available for all of a molecule's atoms\n\n\
\n\
ARGUMENTS:\n\n\
- mol : the molecule of interrest\n\
\n";
python::def("UFFHasAllMoleculeParams", RDKit::UFFHasAllMoleculeParams,
(python::arg("mol")),
docString.c_str());
}
|