schrodinger.ui.qt.appframework2.af2 module

class schrodinger.ui.qt.appframework2.af2.App(**kwargs)

Bases: schrodinger.ui.qt.appframework2.maestro_callback.MaestroCallbackMixin, schrodinger.ui.qt.appframework2.markers.MarkerMixin, schrodinger.ui.qt.appframework2.settings.SettingsPanelMixin, schrodinger.ui.qt.appframework2.baseapp.ValidatedPanel

classmethod panel(run=True)

Launch a singleton instance of this class. If the panel has already been instantiated, the existing panel instance will be re-opened and brought to the front.

Parameters

run (bool) – Whether to launch the panel

Returns

The singleton panel instance

Return type

App

__init__(**kwargs)
Parameters
  • stop_before (int) – Exit the constructor before specified step.

  • parent (QWidget) – Parent widget, if any.

  • in_knime (bool) – Whether we are currently running under KNIME - a mode in which input selector is hidden, optionally a custom Workspace Structure is specified, and buttom bar has OK & Cancel buttons.

  • workspace_st_file (bool) – Structure to be returned by getWorkspaceStructure() when in_knime is True.

classmethod runKnime(input_selector_file=None, workspace_st_file=None, jobname=None, run=True, load_settings=True, panel_state_file=None)

Call this static method to instantiate this panel in KNIME mode - where OK & Cancel buttons are shown at the bottom. Pressing OK button cases the job files to be written to the CWD.

Parameters
  • input_selector_file (str) – the filename to be fed into the input selector, replacing interactive input from the user. Required if the panel contains an input selector.

  • workspace_st_file (str) – the filename containing the schrodinger.structure.Structure that replaces the workspace structure in a Maestro session.

  • jobname (str) – Jobname for the panel

  • run (bool) – Whether to launch the panel. If False, just returns the panel instance without starting the event loop.

  • load_settings (bool) – Whether to load previous settings for the given jobname from the CWD.

  • panel_state_file – Unused (added for backwards compatability)

setPanelOptions()

Configure the panel by setting instance variables here. Always call the parent method. Panel options:

self.maestro_dockable - whether this panel should be dockable in the

Maestro main window. Setting to false will prevent the panel from docking regardless of Maestro preference. When setting it to true, if Maestro Preference allows docking of panels, it will dock the panel on the right-hand side of the main window if “Location” is set to “Main window”, or a floating window if “Location” is set to “Floating window”. Default is False.

self.title - string to display in the window title bar

self.ui - a Ui_Form instance defining the main ui, default None

self.allowed_run_modes - subset of [MODE_MAESTRO, MODE_STANDALONE,

MODE_SUBPANEL, MODE_CANVAS] defining how the panel may be run. Default is all.

self.help_topic - string defining the help topic. Default ‘’

self.input_selector_options - dict of options for the common input

selector widget. Default is an empty dict, meaning do not add an input selector

self.add_main_layout_stretch - bool of whether to add a stretch to the

main layout under the main ui (if self.ui exists). Default is True

setup()
setDefaults()
layOut()
createInputSelector()
createBottomBar()
closeEvent(event)

Receives the close event and calls the panel’s ‘close’-decorated appmethod. If the appmethod specifically returns False, the close event will be ignored and the panel will remain open. All other return values (including None) will allow the panel to proceed with closing.

This is a PyQT slot method and should not be explicitly called.

show()

Re-show all panel markers when the panel is re-shown. This separate method is needed for QDialog instances.

showEvent(event)

When the panel is shown, call the panel’s ‘show’-decorated methods. Note that restoring a minimized panel will not trigger the ‘show’ methods.

cleanup()
showProgressBarForJob(job, show_lbl=True, start_timer=True)

Show a progress bar that tracks the progress of the specified job

Parameters
  • job (schrodinger.job.jobcontrol.Job) – The job to track

  • show_lbl (bool) – If True, the job progress text description will be shown above the progress bar. If False, the text description will not be shown.

  • start_timer (bool) – If True, the progress bar will automatically be updated and removed when the job is complete. If False, it is the caller’s responsibility to periodically call self.progress_bar.readJobAndUpdateProgress() and to call self.status_bar.hideProgress() when the job is complete.

getWorkspaceStructure()

If panel is open in Maestro session, returns the current workspace schrodinger.strucutre.Structure.

If panel is open from outside of Maestro, returns the self.workspace_st if self.workspace_st_file is available. Used while running from command line or starting the panel from KNIME.

Returns None otherwise.

Return type

schrodinger.structure.Structure or None

Returns

Maestro workspace structure or None

hideLayoutElements(layout)

Hide all elements from the given layout. Used for customizing KNIME panel wrappers.

loadSettings(jobname)

Load the GUI state for the job in the CWD with the given name. Default implementation will return False. Each KNIME panel will need to implement a custom version. For example, the panel may want to read the <jobname.sh> file, parse the list of command-line options, and populate the GUI accordintly. If a panel writes key/value file, then it would need to read it here.

Returns

True if panel state was restored, False if saved state was not found.

Return type

bool

jobname()

Return the job name currently set for the current task.

setJobname(jobname)

Set the job name for the current task.

writeStateAndClose()

Called when OK button button is pressed when running in KNIME mode. Will “write” the job files for current task, and close the panel.

readShFile(jobname)

Reads the jobname.sh file (written by _write()) and returns the list of command line arguments

validateOPLSDir(opls_dir=None)

See forcefield.validate_opls_dir()

Parameters

opls_dir (str or None) – the opls dir to validate

Returns

the validation result

Return type

forcefield.OPLSDirResult

schrodinger.ui.qt.appframework2.af2.JobAppSuper

alias of schrodinger.ui.qt.appframework2.af2.App

class schrodinger.ui.qt.appframework2.af2.JobApp(**kwargs)

Bases: schrodinger.ui.qt.appframework2.af2.App

jobCompleted

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.

lastJobCompleted

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__(**kwargs)
Parameters
  • stop_before (int) – Exit the constructor before specified step.

  • parent (QWidget) – Parent widget, if any.

  • in_knime (bool) – Whether we are currently running under KNIME - a mode in which input selector is hidden, optionally a custom Workspace Structure is specified, and buttom bar has OK & Cancel buttons.

  • workspace_st_file (bool) – Structure to be returned by getWorkspaceStructure() when in_knime is True.

setPanelOptions()

See parent class for more options.

self.use_mini_jobbar - whether this panel use the narrow version of the bottom job bar. This is useful for narrow panels where the regular job bar is too wide to fit. Default: False

self.viewname - this identifier is used by the job status button so that it knows which jobs belong to this panel. This is automatically generated from the module and class name of the panel and so it does not need to be set unless the module/class names are generic.

self.program_name - a human-readable text name for the job this panel launches. This shows up in the main job monitor to help the user identify the job. Example: “Glide grid generation”. Default: “Job”

self.omit_one_from_standard_jobname - see documentation in jobnames.py

add_driverhost - If True, the backend supports running -DRIVERHOST to specify a different host for the driver job than subjobs. Only certain workflows support this option.

getConfigDialog()
setup()
setDefaults()
layOut()
createBottomBar()
syncConfigDialog()
configDialogSettings()
setConfigDialogSettings(new_values)
addProjectJobNote(job_id, jobname)

Adds a note to the project annotation file. :param job_id: The ID of the job, as assigned by Maestro :type job_id: string :param jobname: The name of the job, as shown in the job panel :type jobname: string

jobnameData()

Provides panel settings that are to be incorporated into job names. If self.default_jobname includes string formatting characters (i.e. %s, {0}, etc.), then this method must be implemented. It should return a tuple or a dictionary to be interpolated into the job name.

jobnameDataChanged()

If the job name includes panel settings, then this method should be called whenever the relevant panel settings are modified

updateJobname(uniquify_custom=True)

Generate a new job name based on the current panel settings

Parameters

uniquify_custom (bool) – Whether we should uniquify custom job name by adding integers to the end. If False, only standard and modified job names will be uniquified. (See JobnameType for an explanation of job name types.)

sanitizeJobnameText(text)

Modify the given text so it can be used in a job name. White space is replaced with underscores and all other disallowed characters are removed.

Parameters

text (basestring) – The text to sanitize

Returns

The sanitized text

Return type

basestring

writeStateAndClose()

Will “write” the job files and close the panel.

cleanup()
jobname()

Return the job name currently set for the current task.

setJobname(jobname)

Set the job name for the current task.

writeJobCmd(cmdlist, job_spec=None, launch_params=None, jobdir=None)

Writes the job invocation command to a file named “<jobname>.sh” Removes options from the command that are maestro-specific.

Note this may modify the contents of cmdlist

Parameters
  • cmdlist (list) – Commands to launch/submit the job

  • job_spec (schrodinger.job.launchapi.JobSpecification) – The job specification for the command you want to write. This is NOT used to write the command that is run; it is used to write a commented-out, un-hashed, human-readable command in the sh file. If None (which is also the default), then the human-readable comment is not written. If it is present, launch_params must be present too.

  • launch_params (job.launchparams.LaunchParameters) – Job launch params

  • jobdir (str) – write the job from this dir, if provided.

writeReadableCmdComment(cmdlist)

Append a readable and portable command (something that starts with $SCHRODINGER/run <script.py>) to the shell run file.

Parameters

cmdlist (list) – Commands to launch/submit the job

getCmdListArgValue(cmdlist, arg)
jobDir()
createJobDir()
registerJob(job, show_progress_bar=False)

Registers a job with the periodic job check callback and starts timer.

Parameters
  • job (jobcontrol.Job) – job to register

  • show_progress_bar (bool) – Whether or not to show a progress bar tracking the job’s status.

updateStatusBar()

Updates the status bar.

generateStatus()

Generate the text to put into the status bar

Returns

The text to put into the status bar

Return type

str

launchScript(script, script_args=None, input_files=[], structure_output_file=None, output_files=[], aux_modules=[], show_progress_bar=False, **kwargs)

DEPRECATED, add get_job_spec_from_args() to the backend script and launch it using launchJobCmd() or also add getJobSpec() to the panel and launch using launchFromJobSpec().

Creates and launches a script using makeLauncher. For documentation on method parameters, see makeLauncher below. Use this method for scripts that do not themselves integrate with job control.

This method honors self.start_mode; it can either launch the script or write out a job file to the job directory.

Parameters

show_progress_bar (bool) – Whether or not to show a progress bar tracking the job’s status.

launcherToCmdList(slauncher)
makeLauncher(script, script_args=[], input_files=[], structure_output_file=None, output_files=[], aux_modules=[], **kwargs)

DEPRECATED, add get_job_spec_from_args() to the backend script and launch it using launchJobCmd() or also add getJobSpec() to the panel and launch using launchFromJobSpec().

Create a launcher.Launcher instance using the settings defined by the panel, its config dialog, and specified arguments. Returns a launcher instance ready to be launched or further modified. Use this method for scripts that do not themselves integrate with job control.

Only use this method if you need to modify the launcher before launching it. Otherwise, the method launchScript() is preferred to create the launcher and launch it.

Parameters
  • script (str) – Remote path to the script to be launched. See Launcher documentation for more info. If only launching to localhost is desired, then a local path can be specified.

  • script_args (list of str) – arguments to be added to the script’s command line

  • input_files (list of str) – input files that will be copied to the temporary job directory.

  • structure_output_file (str) – this is the file that will be registered with job control to incorporate at the end of the job

  • output_files (list of str) – additional output files to be copied back from the temporary job directory

  • aux_modules (list of modules) – Additional modules required by the script

Returns

A prepped launcher

Return type

Launcher

launchLauncher(slauncher, show_progress_bar=False)

Either launches a launcher instance or writes the job invocation command, depending on the state of self.start_mode. This allows the panel’s start method to double as a write method.

Calling launchLauncher() is only necessary if creating a customized launcher using makeLauncher().

Parameters

show_progress_bar (int) – Whether or not to show a progress bar tracking the job’s status.

getJobSpec()
validForceFieldSelectorCustomOPLSDir()

Check whether a force field selector exists and if so whether it is set to use a custom OPLS directory that is valid. :return: whether OPLS directory has issues :rtype: bool

launchFromJobSpec(oplsdir=None)

Call this function in start method if the calling script implements the launch api. This function requires implementation of getJobSpec to return the job specification.

Parameters

oplsdir (None, False or str) – If None (default), search widgets on the panel for a ffselector.ForceFieldSelector (or subclass thereof) and get any custom OPLS directory information from that widget. If False, do not use a custom OPLS directory. If a str, this is the path to use for the custom OPLS directory. Note that the OPLSDIR setting found by oplsdir=None is ambiguous if there is more than one ForceFieldSelector child widget, and that ForceFieldSelector widgets that are NOT child widgets of this panel - such as a widget on a dialog - will not be found. Setting this parameter to False for a panel that does not use a ForceFieldSelector widget avoids the widget search but will only shave a few thousandths of a second off job startup time even for very complex panels.

launchJobCmd(cmdlist, show_progress_bar=False, auto_add_host=True, use_parallel_flag=True, jobdir=None)

Launches a job control command. Use this to launch scripts that accept the standard job control options arguments like -HOST, -DISP, etc. By default, automatically populates standard arguments from the config dialog, but will not overwrite if they are already found in cmdlist. For example, if -HOST is found in cmdlist, launchJobCmd will ignore the host specified in the config dialog.

This method honors self.start_mode; it can either launch the script or write out a job file to the job directory.

Parameters
  • cmdlist (list) – the command list

  • show_progress_bar (bool) – Whether or not to show a progress bar tracking the job’s status.

  • auto_add_host (bool) – Whether or not to automatically add -HOST flag to command when it is not already included.

  • use_parallel_flag (bool) – Whether requesting CPUs > 1 without specifying threads > 1 should be represented by the use of the -PARALLEL X flag (True, default) or -HOST host:X (False). -PARALLEL is a Jaguar flag and may not be appropriate for other programs.

  • jobdir (str) – launch the job from this dir, if provided.

Returns

Job object for started job, or None if job start failed or if writing instead of starting. Panels should in general ignore the return value.

setupJobCmd(cmdlist, auto_add_host=True, use_parallel_flag=True)

Adds standard arguments HOST, NJOBS, PROJ, DISP, VIEWNAME to the cmdlist if they are set in the config dialog. Settings pre-existing in the cmdlist take precedence over the config dialog settings.

Parameters
  • cmdlist (list) – the command list

  • auto_add_host (bool) – Whether or not to automatically add -HOST flat to command when it is not already included.

  • use_parallel_flag (bool) – Whether requesting CPUs > 1 without specifying threads > 1 should be represented by the use of the -PARALLEL X flag (True, default) or -HOST host:X (False). -PARALLEL is a Jaguar flag and may not be appropriate for other programs.

showSTUDialog(sh_txt, jobname)

Shows dialog with information necessary to start a STU test, including a label that links to the test suite.

Parameters

sh_txt (str) – Text contained within the .sh file

startDebug()
class schrodinger.ui.qt.appframework2.af2.BaseBottomBar(app_methods, **kwargs)

Bases: PyQt6.QtWidgets.QFrame, schrodinger.ui.qt.appframework2.validation.ValidationMixin

__init__(app_methods, **kwargs)
setup()
layOut()
makeButton(method, slot_method=None)
makeCustomButtons()
buildCustomBar()
class schrodinger.ui.qt.appframework2.af2.BottomBar(app_methods, **kwargs)

Bases: schrodinger.ui.qt.appframework2.af2.BaseBottomBar

layOut()
buildStandardBar()
hideToolbarStyle()

This method is only useful on Darwin to hide the toolbar background for non Job related panels with a bottom bar of buttons.

class schrodinger.ui.qt.appframework2.af2.JobBottomBar(app_methods, **kwargs)

Bases: schrodinger.ui.qt.appframework2.af2.BottomBar

layOut()
buildStandardBar()
class schrodinger.ui.qt.appframework2.af2.MiniJobBottomBar(app_methods, **kwargs)

Bases: schrodinger.ui.qt.appframework2.af2.JobBottomBar

This is just an alternate layout of the regular job bar, optimized for narrow panels.

setup()
buildStandardBar()

Constructs the parent standard bar, then removes widgets that need to be relocated for the mini layout. When a widget is removed from a toolbar, it needs to be re-instantiated, as the old instance becomes unusable.

layOut()
class schrodinger.ui.qt.appframework2.af2.OKAndCancelBottomBar(app_methods, **kwargs)

Bases: schrodinger.ui.qt.appframework2.af2.BaseBottomBar

Version of the bottom bar - which shows OK and Cancel buttons.

layOut()
buildStandardBar()
class schrodinger.ui.qt.appframework2.af2.SettingsButton(methods)

Bases: schrodinger.ui.qt.utils.ButtonAcceptsFocusMixin, schrodinger.ui.qt.swidgets.SToolButton

__init__(methods)

Create an SToolButton instance

Parameters
  • text (str) – The text of the button

  • layout (QtWidgets.QBoxLayout) – The layout for this button

  • tip (str) – The tooltip for this button

  • command (callable) – The command to connect the clicked signal to

maestroJobPreferences()

Open the Maestro preference panel with Jobs/Starting node selected.

class schrodinger.ui.qt.appframework2.af2.StatusBar(app, add_reset=False)

Bases: schrodinger.ui.qt.standard_widgets.statusbar.StatusBar

A status bar for AF2 based panels, which contains a status label or progress bar, and optionally a help button and a reset button. :cvar status_shrunk: emitted when the status bar has been shrunk due to hiding the progress bar. The signal is emitted with the number of pixels the status bar has been shrunk by. :cvar reset_clicked: emitted when the reset button is clicked

status_shrunk

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.

reset_clicked

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__(app, add_reset=False)
showMessage(message, timeout=0, color=None)

Modifies existing showMessage function to include color. Also makes text bold for emphasis.

Parameters
  • message (str) – the message to display

  • timeout (int) – time to show message in ms. If set to 0 (default) the message is not cleared.

  • color (QtGui.QColor) – text color for message. Default is black

clearMessage(self)
setStatus(text)
setWarningStatus(text)
status()
addHelpButton(app)
hideProgress()

Hide the progress bar and re-display the status message

showProgress()

Show the progress bar in place of the status message

class schrodinger.ui.qt.appframework2.af2.ProgressFrame(parent=None)

Bases: PyQt6.QtWidgets.QFrame

A progress bar. Job progress can be tracked using trackJobProgress and readJobandUpdateProgress. The progress bar can be also be used “manually” for non-job-control tasks: It can be shown and hidden from the panel via self.status_bar.showProgress and self.status_bar.hideProgress and can be updated using self.progress_bar.setValue, self.progress_bar.setMaximum, self.progress_bar.setText, and self.progress_bar.setTextVisible.

__init__(parent=None)
trackJobProgress(job, show_lbl=False)

Track the progress of the specified job

Parameters
  • job (schrodinger.job.jobcontrol.Job) – The job to track

  • show_lbl (bool) – If True, the job progress text description will be shown above the progress bar. If False, the text description will not be shown. Defaults to False.

readJobAndUpdateProgress()

Update the status bar based on the current job’s progress. The job progress will be re-read.

Returns

True if the job has completed. False otherwise.

Return type

bool

updateProgress()

Update the status bar based on the current job’s progress. Note that the job database will not be re-read. Use readJobAndUpdateProgress instead if you have not already updated the job object.

setValue(value)
setMaximum(value)
setText(text)
setTextVisibile(visible)
mouseDoubleClickEvent(event)

If the user double clicks and there is a job loaded, launch the Monitor panel

Note

If self._job is None or if refers to a completed job, then we assume the progress bar is currently tracking progress for something not job-related (such as reading input files into the panel), so we don’t launch the Monitor panel.

schrodinger.ui.qt.appframework2.af2.reduce_settings_for_group(settings, group)

Reduces a full settings dictionary to a dictionary targeted for a specific group. The function does two things:

  1. Strips off the group prefix for this group from aliases. Example: For ‘group_A’, ‘group_A.num_atoms’ becomse just ‘num_atoms’. In the case of resultant name collisions, the group-specific setting takes priority. Ex. “group_A.num_atoms” takes priority over just “num_atoms”.

  2. Removes settings for other groups. For example, if ‘group_A’ is passed in, settings like ‘group_B.num_atoms’ will be excluded.

Parameters
  • settings (dict) – settings dictionary mapping alias to value

  • group (str) – the desired group

schrodinger.ui.qt.appframework2.af2.expand_settings_from_group(settings, group, all_aliases)
schrodinger.ui.qt.appframework2.af2.get_readable_cmd_list(jlaunch_cmdlist, job_spec, launch_params)

Generate a portable command for launching the job defined by the given job specification, for writing out as a comment to <jobname.sh> file that user can re-use when submitting jobs, without having to base64 decode the command from the jlaunch command list.

The returned command will use $SCHRODINGER/run <script.py> instead of jlaunch.pl, so the script must define a get_job_spec_from_args() function for the command to work.

Parameters
Return type

list[str]

Returns

Command to launch/submit the job