openmmtools.utils.RestorableOpenMMObject

class openmmtools.utils.RestorableOpenMMObject(*args, **kwargs)[source]

Base class for restorable custom integrators and forces.

Normally, a custom OpenMM object loses its specific class (and all its methods) when it is copied or deserialized from its XML representation. Class interfaces inheriting from this can be restored through the method restore_interface(). Also, this class extend the copying functions to copy also Python attributes.

The class automatically adds a global parameter or variable in custom forces and integrators respectively on __init__ to keep track of the original class.

Methods

deserialize_xml(xml_serialization) Shortcut to deserialize the XML representation and the restore interface.
is_restorable(openmm_object) Check if the custom integrator or force has a restorable interface.
restore_interface(openmm_object) Restore the original interface of an OpenMM custom force or integrator.
__init__(*args, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__(*args, **kwargs) x.__init__(…) initializes x; see help(type(x)) for signature
deserialize_xml(xml_serialization) Shortcut to deserialize the XML representation and the restore interface.
is_restorable(openmm_object) Check if the custom integrator or force has a restorable interface.
restore_interface(openmm_object) Restore the original interface of an OpenMM custom force or integrator.
classmethod deserialize_xml(xml_serialization)[source]

Shortcut to deserialize the XML representation and the restore interface.

Parameters:
xml_serialization : str

The XML representation of the OpenMM custom force/integrator.

Returns:
openmm_object

The deserialized OpenMM force/integrator with the original interface restored (if restorable).

classmethod is_restorable(openmm_object)[source]

Check if the custom integrator or force has a restorable interface.

Parameters:
openmm_object : object

The custom integrator or force to check.

Returns:
True if the object has a restorable interface, False otherwise.
classmethod restore_interface(openmm_object)[source]

Restore the original interface of an OpenMM custom force or integrator.

The function restore the methods of the original class that inherited from RestorableOpenMMObject. Return False if the interface could not be restored.

Parameters:
openmm_object : object

The object to restore.

Returns:
True if the original class interface could be restored, False otherwise.