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:

  1. entry_plp_target: creates and tracks entries associated with

    items in the model PLP. If the user wishes to use any of the subsequent targets, they must first assign a model for this target.

  2. group_plp_target: moves associated entries into an entry group

  3. select_plp_target: selects associated entries

  4. include_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 the group_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.

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)

addProjectCloseCallback(callback_fn)

Add function to list of “project closed” callbacks.

Parameters

callback_fn (Callable) – the function to add

addProjectUpdateCallback(callback_fn)

Add function to list of “project updated” 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

blockSignals(self, b: bool) bool
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent)
deleteLater(self)
destroyed

destroyed(self, object: typing.Optional[QObject] = None) [signal]

disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
inherits(self, classname: str) bool
installEventFilter(self, a0: QObject)
isSignalConnected(self, signal: QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, id: int)
metaObject(self) QMetaObject
moveToThread(self, thread: QThread)
objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

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

parent(self) QObject
property(self, name: str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, signal: PYQT_SIGNAL) int
removeEventFilter(self, a0: QObject)
sender(self) QObject
senderSignalIndex(self) int
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

setObjectName(self, name: str)
setParent(self, a0: QObject)
setProperty(self, name: str, value: Any) bool
signalsBlocked(self) bool
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
suspendCallbacks()

Context manager to temporarily disable Maestro callbacks.

thread(self) QThread
timerEvent(self, a0: QTimerEvent)
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str
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
__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

auto_update_model = True
auto_update_target = True
blockSignals(self, b: bool) bool
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent)
deleteLater(self)
destroyed

destroyed(self, object: typing.Optional[QObject] = None) [signal]

disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
inherits(self, classname: str) bool
installEventFilter(self, a0: QObject)
isSignalConnected(self, signal: QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, id: int)
metaObject(self) QMetaObject
moveToThread(self, thread: QThread)
objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

parent(self) QObject
property(self, name: str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, signal: PYQT_SIGNAL) int
removeEventFilter(self, a0: QObject)
sender(self) QObject
senderSignalIndex(self) int
setObjectName(self, name: str)
setParent(self, a0: QObject)
setProperty(self, name: str, value: Any) bool
signalsBlocked(self) bool
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
targetValueChanged
thread(self) QThread
timerEvent(self, a0: QTimerEvent)
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str
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

auto_update_model = True
auto_update_target = True
blockSignals(self, b: bool) bool
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent)
deleteLater(self)
destroyed

destroyed(self, object: typing.Optional[QObject] = None) [signal]

disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
inherits(self, classname: str) bool
installEventFilter(self, a0: QObject)
isSignalConnected(self, signal: QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, id: int)
metaObject(self) QMetaObject
moveToThread(self, thread: QThread)
objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

parent(self) QObject
property(self, name: str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, signal: PYQT_SIGNAL) int
removeEventFilter(self, a0: QObject)
sender(self) QObject
senderSignalIndex(self) int
setObjectName(self, name: str)
setParent(self, a0: QObject)
setProperty(self, name: str, value: Any) bool
signalsBlocked(self) bool
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
targetValueChanged
thread(self) QThread
timerEvent(self, a0: QTimerEvent)
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str