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.

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.

get_data_file_path

Get the full path to one of the reference files in testsystems.

convert_0_1_smirnoff_to_0_2

Convert an 0.1-compliant SMIRNOFF dict to an 0.2-compliant one.

convert_0_2_smirnoff_to_0_3

Convert an 0.2-compliant SMIRNOFF dict to an 0.3-compliant one.

attach_units

Attach units to dict entries for which units are specified.

detach_units

Given a dict which may contain some simtk.unit.Quantity objects, return the same dict with the Quantities replaced with unitless values, and a new dict containing entries with the suffix “_unit” added, containing the units.

check_units_are_compatible

Checks whether a simtk.unit.Quantity or list of simtk.unit.Quantitys is compatible with given unit.

unit_to_string

Serialize a simtk.unit.Unit and return it as a string.

string_to_unit

Deserializes a simtk.unit.Quantity from a string representation, for example: “kilocalories_per_mole / angstrom ** 2”

convert_all_quantities_to_string

Traverses a SMIRNOFF data structure, attempting to convert all quantities into strings.

convert_all_strings_to_quantity

Traverses a SMIRNOFF data structure, attempting to convert all quantity-defining strings into simtk.unit.Quantity objects.

extract_serialized_units_from_dict

Create a mapping of (potentially unit-bearing) quantities from a dictionary, where some keys exist in pairs like {‘length’: 8, ‘length_unit’:’angstrom’}.

serialize_numpy

Serializes a numpy array into a JSON-compatible string.

deserialize_numpy

Deserializes a numpy array from a JSON-compatible string.

Structure tools

Tools for manipulating molecules and structures

Warning

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

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.