schrodinger.maestro_utils.maestro_sync module¶
- class schrodinger.maestro_utils.maestro_sync.BaseMaestroSync(*args, **kwargs)¶
Bases:
object
Basic Maestro synchronization class that can be used as infrastructure for responding to specific events with the Maestro project and Workspace.
- Variables
_cb_type_callback_map (set[str, set[Callable]]) – a dictionary mapping callback types to the set of callback functions associated with that type
_callbacks_active (bool) – whether the stored callbacks should be registered at this time
- __init__(*args, **kwargs)¶
- addProjectUpdateCallback(callback_fn)¶
Add function to list of “project updated” callbacks.
- Parameters
callback_fn (Callable) – the function to add
- addProjectCloseCallback(callback_fn)¶
Add function to list of “project closed” callbacks.
- Parameters
callback_fn (Callable) – the function to add
- addWorkspaceChangeCallback(callback_fn)¶
Add function to list of “workspace changed” callbacks.
- Parameters
callback_fn (Callable) – the function to add
- addHoverCallback(callback_fn)¶
Add function to list of “hover” callbacks.
- Parameters
callback_fn (Callable) – the function to add. This function should expect to receive a single parameter of type
int
. The parameter represents the number of the atom which the mouse is currently resting over (or an invalid index if 0—see mm.mmct_valid_atom)
- setCallbacksActive(active)¶
Register or deregister all callbacks. When activating, call all “project updated” callbacks.
- Parameters
active (bool) – whether to register or deregister callbacks with Maestro
- suspendCallbacks()¶
Context manager to temporarily disable Maestro callbacks.
- onProjectUpdated()¶
Callback method for project update events. Should be overridden in concrete subclasses to add functionality.
- onProjectClosed()¶
Callback method for project close events. Should be overridden in concrete subclasses to add functionality.
- onWorkspaceChanged(what_changed)¶
Callback method for workspace change events. Should be overridden in concrete subclasses to add functionality.
- Parameters
what_changed (str) – the kind of change that occurred in the Workspace; will be one of the
WORKSPACE_CHANGED_
constants in maestro.py
- schrodinger.maestro_utils.maestro_sync.requires_structure_getter(method, self, *args, **kwargs)¶
Decorator for
ProjectEntryMaestroSync
methods that raises an exception if the decorated method is called when the structure getter is undefined.
- class schrodinger.maestro_utils.maestro_sync.ProjectEntryMaestroSync(parent=None, group_name=None, parent_group_name=None)¶
Bases:
schrodinger.maestro_utils.maestro_sync.BaseMaestroSync
,PyQt6.QtCore.QObject
Maestro sync class that acts as an interface with project entries.
If the user has a
ParamListParam
(PLP) or multiple PLPs that they wish to have correspond with entries in the project, they can assign them as the models for one or more of the targets associated with this class:entry_plp_target
: creates and tracks entries associated withitems in the model PLP. If the user wishes to use any of the subsequent targets, they must first assign a model for this target.
group_plp_target
: moves associated entries into an entry groupselect_plp_target
: selects associated entriesinclude_plp_target
: includes associated entries
In addition to assigning model PLPs to the above targets, the user must also assign a function that can return a structure from a PLP item using the
setStructureGetter()
method. A simple example would just be:mae_sync = ProjectEntryMaestroSync() mae_sync.setStructureGetter(lambda item: item.structure)
Finally, the user may also assign a
StringParam
model that tracks the title for the entry group created for thegroup_plp_target
model.- Variables
_structure_getter (callable) – the function used to access structure objects from PLP items
_st_eid_map (dict[structure.Structure, str]) – a dictionary mapping structures to their corresponding entry IDs
- __init__(parent=None, group_name=None, parent_group_name=None)¶
- Parameters
parent (QtCore.QObject) – the parent for this object
group_name (str or NoneType) – a custom name for the entry group tracked by
group_plp_target
parent_group_name (str) – the parent group name for the entry group tracked by
group_plp_target
, if it is meant to be a subgroup
- setStructureGetter(getter)¶
Assign the function that can be used by the PLP targets on this class to retrieve structure objects from items on the PLP, e.g.
plp = self.entry_plp_target.getPLP() for item in plp: st = self._structure_getter(item)
This getter must be set in order for this class to function.
- Parameters
getter (callable) – a function that will return a structure object from a PLP item
- groupName()¶
- Returns
the entry group name associated with this class
- Return type
str
- onProjectUpdated()¶
Respond to the project updating by searching for entries associated with the project entry PLP. If any have been deleted from the project, remove the associated model PLP items.
- class schrodinger.maestro_utils.maestro_sync.PLPTarget(parent=None)¶
Bases:
schrodinger.models.mappers.TargetMixin
,PyQt6.QtCore.QObject
A generic target for a PLP model.
- Variables
PLPMutated (QtCore.pyqtSignal) – a signal that propagates the
ParamListParam.mutated
signal from the model PLP
- PLPMutated¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- __init__(parent=None)¶
- targetGetValue()¶
- targetSetValue(value)¶
- getPLP()¶
- Returns
the PLP model for this target, if one has been defined
- Return type
parameters.ParamListParam or NoneType
- setPLP(plp)¶
Assign a new PLP model.
- Raises
TypeError – if an invalid parameter is supplied
- Parameters
plp (parameters.ParamListParam or NoneType) – a PLP containing structures, or None
- class schrodinger.maestro_utils.maestro_sync.TitleTarget(group_manager, parent=None)¶
Bases:
schrodinger.models.mappers.TargetMixin
,PyQt6.QtCore.QObject
Target for managing the title of an entry group via a group manager.
- __init__(group_manager, parent=None)¶
- targetGetValue()¶
See
mappers.TargetMixin
for full documentation.- Returns
the current group title
- Return type
str
- targetSetValue(value)¶
See
mappers.TargetMixin
for full documentation.- Parameters
value (str) – a new group title