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.

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

Bases: 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, which use a different directory name for historical reasons

moveOldTemplates()

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

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.ItemRow(master, row_layout, item_type, unset_tip)

Bases: schrodinger.ui.qt.swidgets.SFrame

A row of control widgets for a ligand

addHydrogens()

Add hydrogens to the structure

delete()

Delete this row

fillStatusLabel()

Set the status label using the new structure

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.

getMolecularFormula()

Compute a molecular formula without the marker atoms

Return type:str
Returns:The Hill-type molecular formula (minus marker atoms)
getStructure()

Get the structure that has been requested

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.
postTreatMinimizedStructure()

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.

prepareStructureForMinimization()

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

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.

reset()

Reset all widgets

restoreCursor()

Change to a wait cursor - needed for the wait_cursor decorator

setStructure()

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

setWaitCursor()

Change to a wait cursor - needed for the wait_cursor decorator

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

Bases: schrodinger.application.matsci.builderwidgets.ItemRow

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

createSketcher()

Create a new Sketcher for this row

dataChanged
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
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
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
getNumMarkers()

Get the number of Rx atoms in this row

Return type:int
Returns:The number of Rx atoms in this row
getStructure()

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

hasStructure()

Is a structure set for this row?

Return type:bool
Returns:True if yes, False if no
reloadTemplateList()

Reload the template combo with current information

reset()

Reset all widgets

setStructure(*args)

Set the structure for this row.

When called as a PyQt slot, the first argument for this method will be the current text of the template_combo

sketchStructure()

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

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
useCustomTemplate()

Set the row to use the Custom template option

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

Bases: schrodinger.ui.qt.structure2d.StructureToolTip

A structure tooltip that displays Rx labels for the Rx atoms

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

Bases: PyQt5.QtWidgets.QDialog

A Dialog window that opens a SketcherBox instance

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.SketcherBox(master, builtin_path, custom_dirname, layout)

Bases: 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.

MARKING_INFO = 'To mark an atom, either right click on it and choose "Set R group" or hover over it and type "Rx", where x is the desired R group number.'
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.
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
clearSketcher()

Remove the current structure from the sketcher

getDefaultCustomTemplateDir()

Get the default directory for user templates

getRecentTemplatePath()

Get the path to the recent template file

Return type:str
Returns:The path to the recent template file
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.
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.
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
getUserTemplateList()

Get the list of user templates

Return type:list
Returns:list of template names in the self.custom_path
importWorkspace()

Get the workspace structure and place it in the sketcher

loadTemplate(template_index)

Load a template into the sketcher

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

Open a window to allow the user to manage existing templates

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
reset()

Reset all widgets

saveTemplate()

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

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
setSketcherStructure(struct)

Set struct as the structure in the sketcher

templatesUpdated
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.
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.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.

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
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.
unset()

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

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):
addHydrogens()

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

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
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()

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.

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.

relocateEtaMarkers()

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

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

Bases: schrodinger.ui.qt.swidgets.SComboBox

A Combo Box for managing template lists

silentlySetItems(items)

Set the items for the combobox 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: PyQt5.QtWidgets.QDialog

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

changeTemplateDirectory()

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

customDirChanged
deleteTemplate()

Delete the selected template

useDefaultTemplateDirectory()

Switch the custom template directory back to the default directory

schrodinger.application.matsci.builderwidgets.clear_marker_properties(struct)

Clear any marker properties that exist on the structure

Parameters:struct (schrodinger.structure.Structure) – The structure with the marker properties to clear
schrodinger.application.matsci.builderwidgets.convert_old_marker_props_to_new(struct)

Some template strutures may still use old-style properties to mark Rx atoms. This function converts those properties to new-style properties and removes the old ones.

Parameters:struct (schrodinger.structure.Structure) – The structure with properties to read and modify
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

schrodinger.application.matsci.builderwidgets.get_eta_marker_indexes(struct)

Get a set of all atom indexes for eta-coordination markers

Parameters:struct (schrodinger.structure.Structure) – The structure with the Rx atoms
Return type:set
Returns:Each item of the set is the atom index of a marker for an eta-coordination site
schrodinger.application.matsci.builderwidgets.get_marker_atom_indexes_from_structure(struct)

Get the indexes of atoms marked as Rx atoms

Parameters:struct (schrodinger.structure.Structure) – The structure with the Rx atoms
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 highest value of x in the keys of the dictionary.
schrodinger.application.matsci.builderwidgets.mark_eta_positions(struct, rx_atoms)

Add a structure property that gives the index of each eta-coordination marker

Parameters:
  • struct (schrodinger.structure.Structure) – The structure with the Rx atoms
  • rx_atoms (dict) – Keys are x value and values are lists of atoms denoted with that Rx marker
schrodinger.application.matsci.builderwidgets.set_marker_properties(struct, rx_atoms, clear=True)

Set the structure properties that store the atoms

Parameters:
  • struct (schrodinger.structure.Structure) – The structure with the Rx 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)
  • clear (bool) – Clear any existing marker properties before setting new ones