Utilities

Toolkit wrappers

The toolkit wrappers provide a simple uniform API for accessing minimal functionality of cheminformatics toolkits.

These toolkit wrappers are generally used through a ToolkitRegistry, which can be constructed with a desired precedence of toolkits:

from openforcefield.utils.toolkits import ToolkitRegistry
toolkit_registry = ToolkitRegistry()
toolkit_precedence = [OpenEyeToolkitWrapper, RDKitToolkitWrapper, AmberToolsToolkitWrapper]
[ toolkit_registry.register(toolkit) for toolkit in toolkit_precedence if toolkit.is_available() ]

Alternatively, the global toolkit registry (which will attempt to register any available toolkits) can be used:

from openforcefield.utils.toolkits import DEFAULT_TOOLKIT_REGISTRY as toolkit_registry

The toolkit wrappers can then be accessed through the registry:

molecule = Molecule.from_smiles('Cc1ccccc1')
smiles = toolkit_registry.call('to_smiles', molecule)
ToolkitRegistry Registry for ToolkitWrapper objects
ToolkitWrapper Toolkit wrapper base class.
OpenEyeToolkitWrapper OpenEye toolkit wrapper
RDKitToolkitWrapper RDKit toolkit wrapper
AmberToolsToolkitWrapper AmberTools toolkit wrapper

Serialization support

Serializable Mix-in to add serialization and deserialization support via JSON, YAML, BSON, TOML, MessagePack, and XML.

Structure tools

Tools for manipulating molecules and structures

Todo

These methods are deprecated and will be removed. We recommend that no new code makes use of these functions.

generateSMIRNOFFStructure Given an OpenEye molecule (oechem.OEMol), create an OpenMM System and use to generate a ParmEd structure using the SMIRNOFF forcefield parameters.
generateProteinStructure Given an OpenMM PDBFile, create the OpenMM System of the protein using OpenMM’s ForceField and then generate the parametrized ParmEd Structure of the protein.
combinePositions Loops through the positions from the ParmEd structures of the protein and ligand, divides by unit.angstroms which will ensure both positions arrays are in the same units.
mergeStructure Combines the parametrized ParmEd structures of the protein and ligand to create the Structure for the protein:ligand complex, while retaining the SMIRNOFF parameters on the ligand.
generateTopologyFromOEMol Generate an OpenMM Topology object from an OEMol molecule.
get_testdata_filename Get the full path to one of the reference files in testsystems.
normalize_molecules Normalize all molecules in specified set.
read_molecules Read molecules from an OpenEye-supported file.
setPositionsInOEMol Set the positions in an OEMol using a position array with units from simtk.unit, i.e.
extractPositionsFromOEMol Get the positions from an OEMol and return in a position array with units via simtk.unit, i.e.
read_typelist Read a parameter type or decorator list from a file.
positions_from_oemol Extract OpenMM positions from OEMol.
check_energy_is_finite Check the potential energy is not NaN.
get_energy Return the potential energy.
get_molecule_parameterIDs Process a list of molecules with a specified SMIRNOFF ffxml file and determine which parameters are used by which molecules, returning collated results.
getMolParamIDToAtomIndex Take a Molecule and a SMIRNOFF forcefield object and return a dictionary, keyed by parameter ID, where each entry is a tuple of ( smirks, [[atom1, …
merge_system Merge two given OpenMM systems.
save_system_to_amber Save an OpenMM System, with provided topology and positions, to AMBER prmtop and coordinate files.
save_system_to_gromacs Save an OpenMM System, with provided topology and positions, to AMBER prmtop and coordinate files.

Miscellaneous utilities

Miscellaneous utility functions.

inherit_docstrings Inherit docstrings from parent class
all_subclasses Recursively retrieve all subclasses of the specified class
temporary_cd Context to temporary change the working directory.
temporary_directory Context for safe creation of temporary directories.
get_data_filename Get the full path to one of the reference files in testsystems.