schrodinger.application.matsci.builderwidgets module

Common widgets and code for builders such as the TM Complex Builder and the Oligamer builder

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.builderwidgets.get_builtin_template_items(path, item_type, item_class=None)

Get a list of the built-in templates

Parameters
  • path (str) – The path to the script (generated via __file__ property)

  • item_type (str) – The type item these templates are. Will form the base name of the template directory. For example, polymer items might have types of “monomer” or “initiator” while complexes might have have a type of “ligand”.

  • item_class (type(QtWidgets.QListWidgetItem)) – The base class to use when creating the template items. Defaults to QtWidgets.QListWidgetItem

Return tuple(item_class)

A list of the builtin template items

schrodinger.application.matsci.builderwidgets.get_builtin_directory(path, item_type)

Given a path to a script and an item type, generate the path to built-in templates for that script and item_type

If the script is located at /A/B/bob.py, the path returned will be /A/B/bob_dir/item_type_templates

Parameters
  • path (str) – The path to the script (generated via __file__ property)

  • item_type (str) – The type item these templates are. Will form the base name of the template directory

Return type

str

Returns

The path to the built-in directory for templates of item_type for the script at path

class schrodinger.application.matsci.builderwidgets.TemplateFamily(parent_script_path: str, item_type: str, category_keys: set = {})

Bases: NamedTuple

Information needed to find and flag template structures.

Variables
  • parent_script_path (str) – The full path of the parent script for this template’s family. Sometimes retrieved using the script.__file__ attribute.

  • item_type (str) – The type of template you want to get the information for. For example, the type could be ‘monomer’ if you want to get structures from the ‘monomer_templates’ folder in the parent path.

  • category_keys (set(str)) – The keys for the structure properties that you want to use as template categories. Useful when filtering templates by categories.

parent_script_path: str

Alias for field number 0

item_type: str

Alias for field number 1

category_keys: set

Alias for field number 2

property builtin_dir
Return type

str

Returns

The location of the built-in templates for this family

class schrodinger.application.matsci.builderwidgets.BaseTemplateListWidgetItem(**kwargs)

Bases: PyQt6.QtWidgets.QListWidgetItem

Base class for a list widget item meant to hold template structures.

__init__(**kwargs)

Initialize a list widget item intended to contain information for a single template structure.

See the documentation of the parent class for additional details and documentation for kwargs.

property display_name
Return type

str

Returns

the template name to display in the GUI/list item

property categories
Return type

list(str)

Returns

names for this item’s categories that are ready to display in a GUI

class schrodinger.application.matsci.builderwidgets.CustomListWidgetItem(**kwargs)

Bases: schrodinger.application.matsci.builderwidgets.BaseTemplateListWidgetItem

Template list widget item, but modified to work for a “custom” template with no actual structure file.

property display_name
Return type

str

Returns

the template name to display in the GUI/list item

property categories
Return type

list(str)

Returns

names for this item’s categories that are ready to display in a GUI

class schrodinger.application.matsci.builderwidgets.TemplateListWidgetItem(file_name, template_family, **kwargs)

Bases: schrodinger.application.matsci.builderwidgets.BaseTemplateListWidgetItem

List widget item designed for a template structure

__init__(file_name, template_family, **kwargs)

Initialize a list widget item intended to contain information for a single template structure.

See the documentation of the parent class for additional details and documentation for kwargs.

Parameters
  • file_name (str) – the name of the template file, including its extension

  • template_family (TemplateFamily) – data class containing the information for the template’s family

Raises

ValueError – If the template file name is invalid (i.e., has a space or parenthesis in it)

property display_name
Return type

str

Returns

the template name to display in the GUI/list item

property categories
Return type

list(str)

Returns

names for this item’s categories that are ready to display in a GUI

property category_keys
Return type

set(str)

Returns

the structure property keys found within this item’s structure file that were also listed among the template category keys

property template_path
Return type

str

Returns

The full path to this item’s template structure file

property is_builtin_template
Return type

bool

Returns

whether this template is a built-in

property is_user_template
Return type

bool

Returns

whether this template is user-defined

getStruct()

Reads the structure from the template file

Return type

structure.Structure

Returns

The template’s structure object

getTextStruct()

Reads a text-only version of this item’s structure file when doing dynamic filtering.

Return type

structure.TextualStructure

Returns

A text-only version of this item’s template structure

static getFileNameFromDisplayName(display_name)

Given a template display name, figure out the file name

Parameters

display_name (str) – The display name of the template, probably created from this class’ display_name property.

Return type

str

Returns

the file name for the template

class schrodinger.application.matsci.builderwidgets.TemplateSelectorFilterListPopUp(parent, autowidth=True)

Bases: schrodinger.ui.qt.filter_list.FilterListPopUp

A pop up widget that allows for dynamic filtering and selection of template structures.

BAR_PADDING = 35
__init__(parent, autowidth=True)
Parameters
  • parent (QtWidgets.QWidget) – parent widget

  • autowidth (bool) – Whether to set the width of the pop-up window based on the text of the initial items

getSelection()

Get the currently selected template

Return str or None

String indicating the name of the template or None if no template is selected.

setSelection(template)

Set the template to the requested value.

Parameters

template (str) – The name of the template to set the pop up to.

Raises
  • ValueError – If the requested template name was not found. In these cases, the template will not be changed and template_changed will not be emitted.

  • RuntimeError – If more than one matching template was found. In these cases, the template will not be changed and template_changed will not be emitted.

class schrodinger.application.matsci.builderwidgets.TemplateSelectorFilterListToolButton(parent)

Bases: schrodinger.ui.qt.filter_list.ToolButtonWithFilterListPopUp

Custom tool button with a template structure selector filter list pop up.

POP_UP_CLASS = None
getSelection()

Get the display name of currently selected template

Return str or None

String indicating the name of the template or None if no template is selected.

getSelectedFileName()

Get the file name of currently selected template

Return type

str or None

Returns

String indicating the name of the template or None if no template is selected.

setSelection(template)

Get the currently selected template

Parameters

template (str) – The display-name of the template you want to select

class schrodinger.application.matsci.builderwidgets.TemplateSelector(*args, item_class=None, command=None, **kwargs)

Bases: schrodinger.ui.qt.swidgets.SelectorWithPopUp

A frame that allows the user to specify a template structure from a pop up list.

TOOL_BUTTON_CLASS = None
__init__(*args, item_class=None, command=None, **kwargs)

Extend super’s __init__ by assigning a self.item_class attribute. This attribute is the base class used when creating/updating the item list in this class’ list widget.

Parameters
  • item_class (type(QtWidgets.QListWidgetItem)) – The child class of QListWidgetItem to use when updating or resetting items in the list widget. If None, then defaults to the base QListWidgetItem class.

  • command (function) – function to call when the selector’s tool button’s pop up’s data are changed

selectionChanged()

Set the line edit to the newly selected template name

getSelection()

Get the current selection

Return type

str

Returns

The current selection

setSelection(template)

Set the template name for the widget

Parameters

template (str) – The name of the template structure to set

Raises

ValueError – If the template name is not recognized

reset()

Reset the widget

silentlySetTemplates(template_names)

Set the items for the selector without emitting any signals

Parameters

template_names (list(str)) – A list of the new template names for the selector

silentlyTryToSelectTemplate(text)

Select the item with the given text and do so without emitting any signals. Also do not give an error if no item with text exists.

Parameters

text (str) – The text of the item to select

class schrodinger.application.matsci.builderwidgets.TemplateSelectorPopUp(parent, template_family)

Bases: schrodinger.application.matsci.builderwidgets.TemplateSelectorFilterListPopUp

A pop up widget that allows for dynamic filtering and selection of template structures.

__init__(parent, template_family)
Parameters
  • parent (QtWidgets.QWidget) – parent widget

  • template_family (TemplateFamily) – data class containing the information for the template’s family

getSelectedItem()

Get the currently selected item

Return type

BaseTemplateListWidgetItem

Returns

The currently selected item

getSelectedFileName()

Get the file name of the currently selected template

Return type

str

Returns

The location of the template file

getSelectedTemplateName()

Get the name of the currently selected template

Return type

str

Returns

The name of the currently selected template

getSelectedStructure()

Get the structure of the currently selected template

Return type

structure.Structure

Returns

The structure object of the currently selected template

class schrodinger.application.matsci.builderwidgets.TemplateToolButton(parent, template_family)

Bases: schrodinger.application.matsci.builderwidgets.TemplateSelectorFilterListToolButton

Custom tool button with a template structure selector filter list pop up.

POP_UP_CLASS

alias of schrodinger.application.matsci.builderwidgets.TemplateSelectorPopUp

__init__(parent, template_family)

Initialize this filter list tool button for selecting template structures

Parameters
  • parent (PyQt5.QtWidgets.QWidget) – The Qt parent widget

  • template_family (TemplateFamily) – data class containing the information for the template’s family

setPopUpClass(pop_up_class)

If a pop up class was not specified via the constructor, use this method to set it after the fact. Useful for placing widgets into *.ui files.

getSelectedFileName()

Get the file name of currently selected template

Return type

str

Returns

The location of the template file

getSelectedTemplateName()

Get the name of the currently selected template

Return type

str

Returns

The name of the currently selected template

getSelectedStructure()

Get the structure of the currently selected template

Return type

structure.Structure

Returns

The structure object of the currently selected template

class schrodinger.application.matsci.builderwidgets.FilteredTemplateSelector(template_family, *args, **kwargs)

Bases: schrodinger.application.matsci.builderwidgets.TemplateSelector

A frame that allows the user to specify a template structure from a pop up list.

__init__(template_family, *args, **kwargs)

See parent class for additional documentation

Parameters

template_family (TemplateFamily) – data class containing the information for the template’s family

getSelectedFileName()

Get the file name of currently selected template

Return type

str

Returns

The location of the template file

getSelectedTemplateName()

Get the name of the currently selected template

Return type

str

Returns

The display name of the currently selected template

getSelectedStructure()

Get the structure of the currently selected template

Return type

structure.Structure

Returns

The structure object of the currently selected template

silentlySetTemplates(template_names)

Sets the selector’s templates to the given template names, and do so without emitting any Qt signals from the template selector’s list widget.

Parameters

template_names (list(str)) – A list of all template names to put into the selector. Any templates already in the selector will be kept. Any templates in the selector but not in this given argument will be deleted. Note that these should be the template display names.

class schrodinger.application.matsci.builderwidgets.TemplateCombo(*args, **kwargs)

Bases: schrodinger.ui.qt.swidgets.SComboBox

A Combo Box for managing template lists

__init__(*args, **kwargs)

See parent class for documentation

silentlySetItems(items)

Set the items for the selector without emitting any signals

Parameters

items (list) – The new items (str) for the combo box

silentlyTryToSelectText(text)

Select the item with the given text and do so without emitting any signals. Also do not give an error if no item with text exists.

Parameters

text (str) – The text of the item to select

class schrodinger.application.matsci.builderwidgets.TemplateManager(parent, templates, custom_path)

Bases: PyQt6.QtWidgets.QDialog

A dialog that manages the user templates - currently only allows deletion

customDirChanged

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, templates, custom_path)

Create a TemplateManager object

Parameters
  • parent (QWidget) – The window to display this dialog over

  • templates (list) – list of template names in the self.parent.custom_path directory

  • custom_path (str) – The directory where the custom templates are stored

deleteTemplate()

Delete the selected template

changeTemplateDirectory()

Change the directory the custom templates are read from/saved to

useDefaultTemplateDirectory()

Switch the custom template directory back to the default directory

class schrodinger.application.matsci.builderwidgets.SketcherStructureMixin

Bases: object

Contains some general use methods for getting a ligand structure from the 2D sketcher

changeMarkerAtomsToTempElement(struct, rx_atoms=None)

Change all the marker atoms in the structure to a specific element

Parameters
  • struct (schrodinger.structure.Structure) – The structure to modify

  • rx_atoms (dict) – A dictionary with keys that are the x value for Rx atoms and values that are lists of atom indexes with that x value. If not supplied, the Rx atoms will be found from structure properties.

getSketcherStructure(quiet_if_empty=False)

Get the structure from the sketcher and set it up for use as a Ligand

Performs the following manipulations:
  • Stores the index of the R1/R2 marker atoms as structure properties

  • Changes R1/R2 to hydrogen atoms

  • Checks to ensure consistent use of Rx in the structure

Parameters

quiet_if_empty (bool) – If True, do not post a warning if the sketcher contains no structure

Return type

schrodinger.structure.Structure or None

Returns

The structure object from the sketcher, or None if an error occured along the way

getRxAtoms()

Find the atoms marked as R groups in the sketcher structure

Return type

(dict, int)

Returns

dict keys are the int value of x in Rx, values are lists of atom indexes set to that Rx value (atom indexes are 1-based). The int return value is the largest value of x in the dictionary keys.

validateRAtomIdentity(rx_atoms, max_x)

Overwrite in a child class to run validation on the values of the R atoms and error code. An error message should be displayed to the user by this method if appropriate

Parameters
  • rx_atoms (dict) – keys are the int value of x in Rx, values are lists of atom indexes set to that Rx value (atom indexes are 1-based)

  • max_x (int) – The larget value of x in the keys of rx_atoms

Return type

bool

Returns

True if everything is OK, False if not

validateRAtomStructure(struct, rx_atoms, max_x)

Overwrite in a child class to run validation on the R atoms that requires a schrodinger.structure.Structure object. An error message should be displayed to the user by this method if appropriate.

Parameters
  • struct (schrodinger.structure.Structure) – The structure to use for validating the Ra atoms

  • rx_atoms (dict) – keys are the int value of x in Rx, values are lists of atom indexes set to that Rx value (atom indexes are 1-based)

  • max_x (int) – The larget value of x in the keys of rx_atoms

Return type

bool

Returns

True if everything is OK, False if not

class schrodinger.application.matsci.builderwidgets.MinimizeMixin

Bases: object

Methods to convert a 2D structure to a 3D structure and minimize it

convert2DTo3DAndMinimize()

Minimize the structure, converting from 2D to 3D first if necessary

findAttachmentMarkers()

Find the atoms that mark attachment points. The index of each marker atom is stored in self.markers in ascending order of Rx value.

class schrodinger.application.matsci.builderwidgets.SketcherBox(master, builtin_path, custom_dirname, layout, add_custom_template=True, single_rx_atom=False, stretch=True)

Bases: schrodinger.application.matsci.builderwidgets.SketcherStructureMixin, schrodinger.ui.qt.swidgets.SFrame

Set of widgets that controls a 2D sketcher and has additional widgets that allow the user to load/save/delete templates for the sketcher and import structures from the workspace into the sketcher.

templatesUpdated

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__(master, builtin_path, custom_dirname, layout, add_custom_template=True, single_rx_atom=False, stretch=True)

Create a SketcherBox instance

Parameters
  • master (QWidget) – Must have a warning method

  • builtin_path (str) – The absolute path to the built-in templates

  • custom_dirname (str) – The base name of the path to the custom templates

  • layout (QBoxLayout) – The layout to place this widget into

  • add_custom_template (bool) – Whether “Custom” template should be allowed in template list

  • single_rx_atom (bool) – If True, there can only be one single rx atom

  • stretch (bool) – Whether to add a stretch at the end of the template widgets

filterTemplates()

Filter templates based on whether single rx atom is requested.

Returns

valid templates

Return type

list

getTemplates()

Get templates based on whether single rx atom is requested.

Return type

list(structure.Structure)

Returns

valid templates

getDefaultCustomTemplateDir()

Get the default directory for user templates

setCustomTemplateDir(path)

The user changed the custom template directory

Parameters

path (str) – The new custom directory path. Use the module constant RESET_TO_DEFAULT_CUSTOM_DIR to reset to the Schrodinger default

getRecentTemplatePath()

Get the path to the recent template file

Return type

str

Returns

The path to the recent template file

importWorkspace()

Get the workspace structure and place it in the sketcher

clearSketcher()

Remove the current structure from the sketcher

buildTemplateList(select='')

Build a list of all templates - built in or user-defined. This list is stored in self.templates and replaces the current list in the Template Combobox.

Parameters

select (str) – The template that should be selected in the Template Combobox when all is said and done.

static getDisplayName(file_name)

Gets the display name for a given file

Parameters

file_name (str) – The name of a file (i.e., no directory pathing, but including the extension)

getCurrentSelection()

Retrieves the current selection

Return type

str

Returns

the currently selected template display name

getUserTemplateList()

Get the list of user templates

Return type

list

Returns

list of template names in the self.custom_path

getRecentTemplatesList()

Get a list of recently used templates.

Return type

list of str

Returns

Items of the list are the names of recently used templates. The list is sorted in order from most to least recently used.

silentlySetItemsAndSelectText(selection)

Update the template items and then set the selection, but do so without emitting any signals.

updateRecentTemplateFile(name)

Add a template as the most recently used template file.

Parameters

name (str) – The name of the most recently used template - should correspond to the name of the template structure file.

saveTemplate()

Save the current sketcher structure as a new user-defined template

queryTemplateName()

Opens a dialog for the user to enter a new template name

Return type

str or None

Returns

The template name given by the user, or None if no valid name was given

readTemplateStructure(name)

Read in a template file based name. The file name read is name + TEMPLATE_EXTENSION.

Parameters

name (str) – The base name of the template file without the extension

Return type

schrodinger.structure.Structure

Returns

The structure that was read in

loadTemplate(template_index)

Load a template into the sketcher

Parameters

template_index (int) – The index in the templates list of the template to load

loadTemplateFile(template_fname)

Load a template structure into the sketcher

Parameters

template_fname (str) – The name of the template file you want to load

setSketcherStructure(struct, rx_atoms=None)

Set struct as the structure in the sketcher. The structure may be modified as needed for the sketcher.

Parameters
  • struct (structure.Structure) – the structure to be placed in the 2D sketcher

  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value. Pass in an empty dict to not mark any atoms. If rx_atoms is None, they will be obtained from the structure and required to exist or a warning will be thrown and the structure will not be set.

manageTemplates()

Open a window to allow the user to manage existing templates

reset()

Reset all widgets

class schrodinger.application.matsci.builderwidgets.FilteredSketcherBox(master, layout, template_family, add_custom_template=True, single_rx_atom=False)

Bases: schrodinger.application.matsci.builderwidgets.SketcherBox

Set of widgets that controls a 2D sketcher and has additional widgets that allow the user to load/save/delete templates for the sketcher and import structures from the workspace into the sketcher.

TOOLTIP_SELECTOR = 'Load a template into the Sketcher'
TOOLTIP_CLEAR_SKETCHER = 'Clear the Sketcher of all structures'
__init__(master, layout, template_family, add_custom_template=True, single_rx_atom=False)

Create a FilteredSketcherBox instance

Parameters
  • master (QWidget) – Must have a warning method

  • QBoxLayoutlayout – The layout to place this widget into

  • template_family (TemplateFamily) – Data class instance containing the information needed to find the templates to use here

  • add_custom_template (bool) – Whether “Custom” template should be allowed in template list

  • single_rx_atom (bool) – Whether there can only be one single rx atom

updateTemplateSelectorImportButton()

Disables the button to import template structures in the sketcher if the currently selected template is custom, because there is nothing to import. Otherwise, enables the button.

filterTemplates()

Filter templates based on whether single rx atom is requested.

Returns

valid templates

Return type

list

clearSketcher()

Remove the current structure from the sketcher

buildTemplateList(*args, **kwargs)

Build a list of all templates—built in or user-defined. This list is stored in self.templates and replaces the current list in the template selector.

Parameters

select (str) – The template that should be selected in the selector when all is said and done.

getDisplayName(file_name)

Gets the display name for a given file

Parameters

file_name (str) – The name of a file (i.e., no directory pathing, but including the extension)

getCurrentSelection()

Retrieves the current selection

Return type

str

Returns

the currently selected template display name

silentlySetItemsAndSelectText(selection)

Update the template items and then set the selection, but do so without emitting any signals.

loadSelectedStructure()

Load a currently selected template into the sketcher

loadTemplateFile(template_fname)

This method is deprecated. Please use loadSelectedStructure instead.

Raises

NotImplementedError – When called

reset()

Reset all widgets

class schrodinger.application.matsci.builderwidgets.ItemRow(master, row_layout, item_type, unset_tip)

Bases: schrodinger.application.matsci.builderwidgets.MinimizeMixin, schrodinger.ui.qt.swidgets.SFrame

A row of control widgets for a ligand

__init__(master, row_layout, item_type, unset_tip)

Create a ItemRow instance

Parameters
  • master (schrodinger.ui.qt.appframework.AppFramework) – The parent panel for this row. Must have the following methods: deleteRow, setWaitCursor, restoreCursor

  • row_layout (QLayout) – The layout this ItemRow should add itself to

  • item_type (str) – A string describing the type of item this row is, such as “ligand” - this will be displayed to the user in labels and tooltips. Use the lowercase form of the word - it will be capitalized when necessary.

  • unset_tip (str) – The tooltip for the label when no structure has been set.

reset()

Reset all widgets

getMolecularFormula()

Compute a molecular formula without the marker atoms

Return type

str

Returns

The Hill-type molecular formula (minus marker atoms)

delete()

Delete this row

setWaitCursor()

Change to a wait cursor - needed for the wait_cursor decorator

restoreCursor()

Change to a wait cursor - needed for the wait_cursor decorator

prepareStructureForMinimization()

Prepare the structure for minimization. The default implementation just changes the marker atoms to H atoms.

postTreatMinimizedStructure(marker_element='Br')

Perform any necessary actions on a just-minimized structure, perhaps undoing some of the prep done by prepareStructureForMinimization. The default changes the marker atoms back to TEMP_ELEMENT atoms.

Parameters

marker_element (str) – The element to change the marker atom to (the atom that marks the attachment point and is discarded when the structure is added to a larger structure)

modifyMinimizer(mizer)

This method allows subclasses to customize the Minimizer in any way they see fit. The structure has already been set for the Minimizer and is a temporary copy of self.structure.

Parameters

mizer (schrodinger.structutils.minimizer.Minimizer) – The Minimizer object that will minimize the structure.

getStructure()

Get the structure that has been requested

removeFFProperties()

Remove any properties set on structure from force field minimization so that those properties don’t propagate to any structure built from this structure.

setStructure()

Set the structure for this row. Including: - Find the marker atoms - optimize ligand structure for best complex binding

shouldMinimize()

Get whether the structure should be minimized

Return type

bool

Returns

Whether the structure should be minimized

fillStatusLabel()

Set the status label using the new structure

addHydrogens()

Add hydrogens to the structure

class schrodinger.application.matsci.builderwidgets.StructureLabel(master, layout, unset_tooltip, unset_text='Not set', prefix='', suffix='')

Bases: schrodinger.ui.qt.swidgets.SLabel

A label that gives information about the ligand for a given row and shows the set structure in a tooltip.

__init__(master, layout, unset_tooltip, unset_text='Not set', prefix='', suffix='')

Create a StructureLabel instance

Parameters
  • master (ItemRow) – The ItemRow object this label is for

  • layout (QBoxLayout) – The layout this label should add itself to

  • unset_tooltip (str) – The tooltip to display if no structure has been set.

  • unset_text (str) – The text to display in the label if no structure has been set

  • prefix (str) – The text to put before the molecular formula

  • suffix (str) – The text to put after the molecular formula

unset()

Change the text & tooltip to indicate there is no ligand set

set(struct, prefix=None, suffix=None)

Change the text & tooltip to indicate there is a ligand set

Parameters
  • struct (schrodinger.structure.Structure) – The structure that is set for this row

  • prefix (str) – A string to add before the molecular formala - if not given, the default prefix set in the __init__ method is used.

  • suffix (str) – A string to add after the molecular formala - if not given, the default suffix set in the __init__ method is used.

event(event)

Override event to make the structure tooltip work

Parameters

event (QEvent) – The QEvent object generated by this event

Return type

bool

Returns

Whether the event was recognized

leaveEvent(event)

Removes the structure tooltip if necessary when the mouse leaves the widget.

Parameters

event (QEvent) – The QEvent object generated by this event

class schrodinger.application.matsci.builderwidgets.RGroupStructureToolTip(struct)

Bases: schrodinger.ui.qt.structure2d.StructureToolTip

A structure tooltip that displays Rx labels for the Rx atoms

__init__(struct)

Create an RGroupStructureToolTip instance

Parameters

struct (schrodinger.structure.Structure) – The structure to display

class schrodinger.application.matsci.builderwidgets.SketchDialog(master, sketcher, title)

Bases: PyQt6.QtWidgets.QDialog

A Dialog window that opens a SketcherBox instance

__init__(master, sketcher, title)

Create a SketchDialog instance

Parameters
useStructure(button)

Prompt the EndGroupRow to use the currently sketched structure, and close the dialog if the structure is acceptable

class schrodinger.application.matsci.builderwidgets.TMLigandRowMixin

Bases: object

A mixin class that takes care of minimizing bidentate transition metal complex ligand structures so that they remain planar through the R1-…-R2 bond path.

Should be used with ItemRow classes. Example use:
class LigandRow(TMLigandRowMixin, ItemRow):

findAttachmentMarkers(set_dentation=True)

Find the atoms that mark attachment points and determine the mono/bi-dentation of the ligand. The index of each marker atom is stored in self.markers.

Parameters

set_dentation (bool) – Whether to set the dentation_type property based on the current number of marker atoms of the structure

prepareStructureForMinimization()

Prepare the structure for minimization.

We change any eta-coordination marker to a dummy atom because that marker is not an actual atomic position - we don’t want it influencing the location of other atoms.

For monodentate ligands:

If not eta-coordination, the location of the first marker is important because that determines the ligand-metal bond vector. We minimize this position by placing an “H” at that location.

For bidentate ligands:

If neither marker is eta, we change the second marker to a dummy atom in order to avoid both marker atoms clashing sterically - in the complex there will be only the metal atom there so setting the second marker to a dummy ensures that the metal is in a good bidentate binding pocket.

If one or both markers are eta, we leave any remaining non-eta marker as an H atom to optimize its position.

The location of any eta-marker is updated afterwards based on the position of the minimized eta-coordinating atoms.

addHydrogens()

Add hydrogens to the structure, properly accounting for phantom Rx bonds and incorrect formal charges caused by those bonds.

modifyMinimizer(mizer)

Add torsion constraints to the minimizer to keep the coordination sphere planar and with torsions of 0.

Parameters

mizer (schrodinger.structutils.minimizer.Minimizer) – The Minimizer object that will minimize the structure.

postTreatMinimizedStructure(marker_element='Br')

Undo the modifications to the structure that we made before minimization. This means we add back the second marker and point it at the first marker. The location of the second marker actually doesn’t really matter, but pointed at the first marker is as good a place as any.

relocateEtaMarkers()

Move each eta marker to the centroid of the atoms it marks

class schrodinger.application.matsci.builderwidgets.ItemRowWithTemplates(master, row_layout, item_type, template_selector_class, default_template, stretch=True, unset_tip=None, builtin_dir=None, sketcher=True, sketcher_class=None, name_field=True, none_item=False, single_rx_atom=False)

Bases: schrodinger.application.matsci.builderwidgets.ItemRow

An ItemRow that holds the data for one unit and includes a combo for choosing Template structures

dataChanged

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__(master, row_layout, item_type, template_selector_class, default_template, stretch=True, unset_tip=None, builtin_dir=None, sketcher=True, sketcher_class=None, name_field=True, none_item=False, single_rx_atom=False)

Create a EndGroupRow instance

Parameters
  • master (schrodinger.ui.qt.appframework.AppFramework) – The parent panel for this row. Must have the following methods: deleteRow, setWaitCursor, restoreCursor

  • row_layout (QLayout) – The layout this EndGroupRow should add itself to

  • item_type (str) – A string describing the type of item this row is, such as “monomer” - this will be displayed to the user in labels and tooltips. Use the lowercase form of the word - it will be capitalized when necessary.

  • template_selector_class (type(TemplateSelector)) – A fully-implemented subclass of TemplateSelector (the class, not an instance)

  • stretch (bool) – Should a layout stretch be added after all widgets have been laid out

  • default_template (str) – The default template to load for this row when created.

  • unset_tip (str) – The tooltip to use when no structure has been set

  • builtin_dir (str) – The path to the directory where built-in templates are stored. By default, it will be the script’s ‘_dir’ directory + the template name

  • sketcher (bool) – Whether to use a button that opens a sketcher window

  • sketcher_class (SketcherBox) – The 2D sketcher class to use in the Sketcher dialog window

  • name_field (bool) – True if a name field should be added, False if not

  • none_item (bool) – Combox has a None item if True

  • single_rx_atom (bool) – If True, there can only be one single rx atom

reset()

Reset all widgets

setSingleRxAtom(single_rx_atom)

Set the single Rx atom mode.

Parameters

single_rx_atom (bool) – If True, there can only be one single rx atom

filterTemplates()

Filter templates based on whether single rx atom is requested.

useCustomTemplate()

Set the row to use the Custom template option

sketchStructure()

Open up a sketcher to allow the user to sketch a new structure

reloadTemplateList(select='')

Reload the template selector with current information. If the current selection is not in the currect list of templates, then fall back to the default.

Parameters

select (str) – The template to select after the list is re-populated. May be the constant RESELECT_CURRENT_TEMPLATE to pick whatever the current template is

getNumMarkers()

Get the number of Rx atoms in this row

Return type

int

Returns

The number of Rx atoms in this row

getAtomsAndWeight()

Count the number of atoms and atomic weight for this row

Return type

(int, float)

Returns

The number of atoms and total molecular weight for the structure of this row - does not include marker atoms

setStructure()

Set the structure for this row.

getStructure()

Get the structure either from the sketcher or from a template file

updateTemplates(templates, select)

Load a new list of templates into the template list

Parameters
  • templates (list) – list of template names

  • select (str) – Attempt to select this template in the combo after loading new names

getName(no_h=False)

Get the name the user has specified for this item

Parameters

no_h (bool) – If True, return an empty string if the name is “H”

Return type

str

Returns

The name for this row

getASLName()

Modify the user’s name to make it acceptable for ASL syntax, which reserves some characters.

Return type

str

Returns

The name for this row modified to pass ASL syntax

hasStructure()

Is a structure set for this row?

Return type

bool

Returns

True if yes, False if no

createSketcher()

Create a new Sketcher for this row

class schrodinger.application.matsci.builderwidgets.ComplexLigandRxMixin

Bases: object

validateRAtomIdentity(rx_atoms, max_x)

Run validation on the values of the R atoms. An error message is displayed to the user by this method if appropriate

Parameters
  • rx_atoms (dict) – keys are the int value of x in Rx, values are lists of atom indexes set to that Rx value (atom indexes are 1-based)

  • max_x (int) – The larget value of x in the keys of rx_atoms. Unused, kept for API compatibility with parent class.

Return type

bool

Returns

True if everything is OK, False if not

validateRAtomStructure(struct, rx_atoms, max_x)

Run validation on the R atoms that requires a schrodinger.structure.Structure object.

Parameters
  • struct (schrodinger.structure.Structure) – The structure to use for validating the Ra atoms

  • rx_atoms (dict) – keys are the int value of x in Rx, values are lists of atom indexes set to that Rx value (atom indexes are 1-based)

  • max_x (int) – The larget value of x in the keys of rx_atoms. Unused, kept for API compatibility with parent class.

Return type

bool

Returns

True if everything is OK, False if not

class schrodinger.application.matsci.builderwidgets.ComplexTemplateSketcher(*args, **kwargs)

Bases: schrodinger.application.matsci.builderwidgets.ComplexLigandRxMixin, schrodinger.application.matsci.builderwidgets.SketcherBox

A 2D sketcher that is decorated with a number of widgets for creating and saving templates. Overrides the parent class mainly for validation of the template structure.

This class is specifically for templates for the Single and Multi complex builders.

__init__(*args, **kwargs)
moveOldTemplates()

Move any templates from the old location to the new one that is used starting in 2014-3

class schrodinger.application.matsci.builderwidgets.FilteredComplexTemplateSketcher(master, layout, template_family, add_custom_template=True, single_rx_atom=False)

Bases: schrodinger.application.matsci.builderwidgets.FilteredSketcherBox, schrodinger.application.matsci.builderwidgets.ComplexTemplateSketcher

class schrodinger.application.matsci.builderwidgets.LigandSketcherStructGetter(sketcher, master)

Bases: schrodinger.application.matsci.builderwidgets.ComplexLigandRxMixin, schrodinger.application.matsci.builderwidgets.TMLigandRowMixin, schrodinger.application.matsci.builderwidgets.MinimizeMixin, schrodinger.application.matsci.builderwidgets.SketcherStructureMixin

Gets a structure from the sketcher, marks the attachment points, checks for valid attachment points and creates a 3D structure.

__init__(sketcher, master)

Create a LigandSketcherStructGetter instance

Parameters
  • sketcher (schrodinger.ui.sketcher.sketcher) – The sketcher instance

  • master (QWidget) – A widget with a warning method

getStructure()

Get the structure from the sketcher, validate it, and convert it to 3D

Note

Note that various methods called from here will post warning dialogs using the master widget (passed into the __init__ method) warning method when things go wrong.

Return type

schrodinger.structure.Structure or None

Returns

The 3D structure or None if an error occured.

class schrodinger.application.matsci.builderwidgets.CleanOptionsCheckbox(text='Clean geometry with:', checked=True, **kwargs)

Bases: schrodinger.ui.qt.swidgets.SCheckBoxWithSubWidget

A Checkbox for cleaning the stucture with options for clean method

FORCEFIELD = 'Force field'
XTB = 'xTB'
USER_TO_FLAG_VALUE = {'Force field': 'ff', 'xTB': 'xtb'}
__init__(text='Clean geometry with:', checked=True, **kwargs)

Create an instance

Parameters
  • text (str) – The checkbox text

  • checked (bool) – The initial checked state of the checkbox

useFF()

Check if force field is the current clean method

Return type

bool

Returns

True if force field should be used

useXTB()

Check if xTB is the current clean method

Return type

bool

Returns

True if xTB should be used

getCMDValue()

Get the command line flag value for the chosen method

Return type

str

Returns

The command line flag value

reset()

Reset the widgets