本文整理汇总了Python中rdkit.Chem.AllChem.MMFFGetMoleculeForceField方法的典型用法代码示例。如果您正苦于以下问题:Python AllChem.MMFFGetMoleculeForceField方法的具体用法?Python AllChem.MMFFGetMoleculeForceField怎么用?Python AllChem.MMFFGetMoleculeForceField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem.AllChem
的用法示例。
在下文中一共展示了AllChem.MMFFGetMoleculeForceField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_molecule_force_field
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MMFFGetMoleculeForceField [as 别名]
def get_molecule_force_field(self, mol, conf_id=None, **kwargs):
"""
Get a force field for a molecule.
Parameters
----------
mol : RDKit Mol
Molecule.
conf_id : int, optional
ID of the conformer to associate with the force field.
kwargs : dict, optional
Keyword arguments for force field constructor.
"""
from rdkit.Chem import AllChem
if self.force_field == 'uff':
ff = AllChem.UFFGetMoleculeForceField(mol, confId=conf_id, **kwargs)
elif self.force_field.startswith('mmff'):
AllChem.MMFFSanitizeMolecule(mol)
mmff_props = AllChem.MMFFGetMoleculeProperties(
mol, mmffVariant=self.force_field)
ff = AllChem.MMFFGetMoleculeForceField(
mol, mmff_props, confId=conf_id, **kwargs)
else:
raise ValueError("Invalid force_field " +
"'{}'.".format(self.force_field))
return ff
示例2: get_molecule_force_field
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MMFFGetMoleculeForceField [as 别名]
def get_molecule_force_field(self, mol, conf_id=None, **kwargs):
"""Get a force field for a molecule.
Parameters
----------
mol : RDKit Mol
Molecule.
conf_id : int, optional
ID of the conformer to associate with the force field.
**kwargs : dict, optional
Keyword arguments for force field constructor.
"""
if self.forcefield == "uff":
ff = AllChem.UFFGetMoleculeForceField(
mol, confId=conf_id, **kwargs
)
elif self.forcefield.startswith("mmff"):
AllChem.MMFFSanitizeMolecule(mol)
mmff_props = AllChem.MMFFGetMoleculeProperties(
mol, mmffVariant=self.forcefield
)
ff = AllChem.MMFFGetMoleculeForceField(
mol, mmff_props, confId=conf_id, **kwargs
)
else:
raise ValueError(
"Invalid forcefield " + "'{}'.".format(self.forcefield)
)
return ff
示例3: compute
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MMFFGetMoleculeForceField [as 别名]
def compute(self, input_data: "AtomicInput", config: "TaskConfig") -> "AtomicResult":
"""
Runs RDKit in FF typing
"""
self.found(raise_error=True)
import rdkit
from rdkit.Chem import AllChem
# Failure flag
ret_data = {"success": False}
# Build the Molecule
jmol = input_data.molecule
mol = self._process_molecule_rdkit(jmol)
if input_data.model.method.lower() == "uff":
ff = AllChem.UFFGetMoleculeForceField(mol)
all_params = AllChem.UFFHasAllMoleculeParams(mol)
elif input_data.model.method.lower() in ["mmff94", "mmff94s"]:
props = AllChem.MMFFGetMoleculeProperties(mol, mmffVariant=input_data.model.method)
ff = AllChem.MMFFGetMoleculeForceField(mol, props)
all_params = AllChem.MMFFHasAllMoleculeParams(mol)
else:
raise InputError("RDKit only supports the UFF, MMFF94, and MMFF94s methods currently.")
if all_params is False:
raise InputError("RDKit parameters not found for all atom types in molecule.")
ff.Initialize()
ret_data["properties"] = {"return_energy": ff.CalcEnergy() * ureg.conversion_factor("kJ / mol", "hartree")}
if input_data.driver == "energy":
ret_data["return_result"] = ret_data["properties"]["return_energy"]
elif input_data.driver == "gradient":
coef = ureg.conversion_factor("kJ / mol", "hartree") * ureg.conversion_factor("angstrom", "bohr")
ret_data["return_result"] = [x * coef for x in ff.CalcGrad()]
else:
raise InputError(f"RDKit can only compute energy and gradient driver methods. Found {input_data.driver}.")
ret_data["provenance"] = Provenance(
creator="rdkit", version=rdkit.__version__, routine="rdkit.Chem.AllChem.UFFGetMoleculeForceField"
)
ret_data["schema_name"] = "qcschema_output"
ret_data["success"] = True
# Form up a dict first, then sent to BaseModel to avoid repeat kwargs which don't override each other
return AtomicResult(**{**input_data.dict(), **ret_data})