# openforcefield.utils.toolkits.ToolkitRegistry

class `openforcefield.utils.toolkits.``ToolkitRegistry`(register_imported_toolkit_wrappers=False, toolkit_precedence=None, exception_if_unavailable=True)

  Registry for ToolkitWrapper objects

  Examples

  Register toolkits in a specified order, skipping if unavailable

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

  Register specified toolkits, raising an exception if one is unavailable

      >>> toolkit_registry = ToolkitRegistry()
      >>> toolkits = [OpenEyeToolkitWrapper, AmberToolsToolkitWrapper]
      >>> for toolkit in toolkits:
      ...     toolkit_registry.register_toolkit(toolkit)

  Register all available toolkits in arbitrary order

      >>> from openforcefield.utils import all_subclasses
      >>> toolkits = all_subclasses(ToolkitWrapper)
      >>> for toolkit in toolkit_precedence:
      ...     if toolkit.is_available():
      ...         toolkit_registry.register_toolkit(toolkit)

  Retrieve the global singleton toolkit registry, which is created when this module is imported from all available toolkits:

      >>> from openforcefield.utils.toolkits import GLOBAL_TOOLKIT_REGISTRY as toolkit_registry
      >>> available_toolkits = toolkit_registry.registered_toolkits

  Warning

  This API is experimental and subject to change.

  Attributes
    `registered_toolkits`

      List registered toolkits.

  Methods

  `add_toolkit`(toolkit_wrapper) | Append a ToolkitWrapper onto the list of toolkits in this ToolkitRegistry
  `call`(method_name, *args, **kwargs) | Execute the requested method by attempting to use all registered toolkits in order of precedence.
  `register_toolkit`(toolkit_wrapper[, …]) | Register the provided toolkit wrapper class, instantiating an object of it.
  `resolve`(method_name) | Resolve the requested method name by checking all registered toolkits in order of precedence for one that provides the requested method.

  `__init__`(register_imported_toolkit_wrappers=False, toolkit_precedence=None, exception_if_unavailable=True)

    Create an empty toolkit registry.

    Parameters
      register_imported_toolkit_wrappers bool, optional, default=False
        If True, will attempt to register all imported ToolkitWrapper subclasses that can be found, in no particular

          order.

      toolkit_precedence list, optional, default=None

        List of toolkit wrapper classes, in order of desired precedence when performing molecule operations. If None, defaults to [OpenEyeToolkitWrapper, RDKitToolkitWrapper, AmberToolsToolkitWrapper].

      exception_if_unavailable bool, optional, default=True

        If True, an exception will be raised if the toolkit is unavailable

  Methods

  `__init__`([…]) | Create an empty toolkit registry.
  `add_toolkit`(toolkit_wrapper) | Append a ToolkitWrapper onto the list of toolkits in this ToolkitRegistry
  `call`(method_name, *args, **kwargs) | Execute the requested method by attempting to use all registered toolkits in order of precedence.
  `register_toolkit`(toolkit_wrapper[, …]) | Register the provided toolkit wrapper class, instantiating an object of it.
  `resolve`(method_name) | Resolve the requested method name by checking all registered toolkits in order of precedence for one that provides the requested method.

  Attributes

  `registered_toolkits` | List registered toolkits.

  `registered_toolkits`

    List registered toolkits.

    Warning

    This API is experimental and subject to change.

    Returns
      toolkits iterable of toolkit objects
  `register_toolkit`(toolkit_wrapper, exception_if_unavailable=True)

    Register the provided toolkit wrapper class, instantiating an object of it.

    Warning

    This API is experimental and subject to change.

    Parameters
      toolkit_wrapper instance or subclass of ToolkitWrapper

        The toolkit wrapper to register or its class.

      exception_if_unavailable bool, optional, default=True

        If True, an exception will be raised if the toolkit is unavailable

  `add_toolkit`(toolkit_wrapper)

    Append a ToolkitWrapper onto the list of toolkits in this ToolkitRegistry

    Warning

    This API is experimental and subject to change.

    Parameters
      toolkit_wrapper openforcefield.utils.ToolkitWrapper

        The ToolkitWrapper object to add to the list of registered toolkits

  `resolve`(method_name)

    Resolve the requested method name by checking all registered toolkits in order of precedence for one that provides the requested method.

    Parameters
      method_name str

        The name of the method to resolve

    Returns
      method

        The method of the first registered toolkit that provides the requested method name

    Raises
      NotImplementedError if the requested method cannot be found among the registered toolkits

    Examples

    Create a molecule, and call the toolkit `to_smiles()` method directly

        >>> from openforcefield.topology import Molecule
        >>> molecule = Molecule.from_smiles('Cc1ccccc1')
        >>> toolkit_registry = ToolkitRegistry(register_imported_toolkit_wrappers=True)
        >>> method = toolkit_registry.resolve('to_smiles')
        >>> smiles = method(molecule)

  `call`(method_name, *args, **kwargs)

    Execute the requested method by attempting to use all registered toolkits in order of precedence.

    `*args` and `**kwargs` are passed to the desired method, and return values of the method are returned

    This is a convenient shorthand for `toolkit_registry.resolve_method(method_name)(*args, **kwargs)`

    Parameters
      method_name str

        The name of the method to execute

    Raises
      NotImplementedError if the requested method cannot be found among the registered toolkits

    Examples

    Create a molecule, and call the toolkit `to_smiles()` method directly

        >>> from openforcefield.topology import Molecule
        >>> molecule = Molecule.from_smiles('Cc1ccccc1')
        >>> toolkit_registry = ToolkitRegistry(register_imported_toolkit_wrappers=True)
        >>> smiles = toolkit_registry.call('to_smiles', molecule)