schrodinger.application.canvas.clustergui module

Canvas clustering functionality that uses GUI libraries

There are classes to perform custering and to support graphical interfaces to the clustering options.

The following panels currently use this module:
  • canvas_cluster_gui.py - Fingerprint Similarity (Canvas Similarity and Clustering)

  • interaction_fingerprints_gui.py - Interaction Fingerprints

  • volume_cluster_gui.py - Clustering of Ligands (Clustering Based on Volume Overlap)
    • does not use the CanvasFingerprintClusterGUI class, only dialogs.

  • conformer_cluster_gui.py - Conformer Cluster
    • does not use the CanvasFingerprintClusterGUI class, only dialogs.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.canvas.clustergui.distance_to_diagonal(mouse_x, mouse_y, bbox)

Calculate perpendicular distance from a point to the diagonal line of a bounding box (from bottom-left to top-right).

Parameters:
  • mouse_x – X coordinate of the point

  • mouse_y – Y coordinate of the point

  • bbox – Bounding box with x0, y0, x1, y1 attributes

Returns:

Distance from point to diagonal line segment

class schrodinger.application.canvas.clustergui.ApplyMode

Bases: Enum

DUPLICATE = 'Duplicate entries to a new group for each cluster'
MOVE = 'Move entries to a new group for each cluster'
REPRESENTATIVE = 'A group containing the structures nearest the centroid in each cluster'
ENTRY = 'Cluster index and size properties for each entry'
class schrodinger.application.canvas.clustergui.ClusteringTabModel(*args, _param_type=<object object>, **kwargs)

Bases: CompoundParam

linkage_method: str

A parameter of the class.

num_clusters: int

A parameter of the class.

apply_mode: ApplyMode

A parameter of the class.

apply_modeChanged

A pyqtSignal emitted by instances of the class.

apply_modeReplaced

A pyqtSignal emitted by instances of the class.

linkage_methodChanged

A pyqtSignal emitted by instances of the class.

linkage_methodReplaced

A pyqtSignal emitted by instances of the class.

num_clustersChanged

A pyqtSignal emitted by instances of the class.

num_clustersReplaced

A pyqtSignal emitted by instances of the class.

class schrodinger.application.canvas.clustergui.ColorByPropertyModel(*args, _param_type=<object object>, **kwargs)

Bases: CompoundParam

Model for the ColorByPropertyPopUp widget.

color_by_property: str

A parameter of the class.

range_min: float

A parameter of the class.

range_max: float

A parameter of the class.

use_log_scale: bool

A parameter of the class.

display_color_scale: bool

A parameter of the class.

color_map: str

A parameter of the class.

color_by_propertyChanged

A pyqtSignal emitted by instances of the class.

color_by_propertyReplaced

A pyqtSignal emitted by instances of the class.

color_mapChanged

A pyqtSignal emitted by instances of the class.

color_mapReplaced

A pyqtSignal emitted by instances of the class.

display_color_scaleChanged

A pyqtSignal emitted by instances of the class.

display_color_scaleReplaced

A pyqtSignal emitted by instances of the class.

range_maxChanged

A pyqtSignal emitted by instances of the class.

range_maxReplaced

A pyqtSignal emitted by instances of the class.

range_minChanged

A pyqtSignal emitted by instances of the class.

range_minReplaced

A pyqtSignal emitted by instances of the class.

use_log_scaleChanged

A pyqtSignal emitted by instances of the class.

use_log_scaleReplaced

A pyqtSignal emitted by instances of the class.

class schrodinger.application.canvas.clustergui.ColorByPropertyPopUp(parent)

Bases: MapperMixin, InitMixin, PopUp

Pop up dialog for letting user select a property to color dendrogram by.

ui_module = <module 'schrodinger.application.canvas.color_by_property_popup_ui' from '/scr/buildbot/builds/build/internal/lib/python3.11/site-packages/schrodinger/application/canvas/color_by_property_popup_ui.py'>
model_class

alias of ColorByPropertyModel

optionsChanged

A pyqtSignal emitted by instances of the class.

__init__(parent)
Parameters:

parent – Parent panel

setup()

Subclass-specific initialization. Subclasses can re-implement this function with custom set up code.

initSetUp()

Creates widget from ui and stores it ui_widget.

Suggested subclass use: create and initialize subwidgets, and connect signals.

onPropertyChanged()

Triggered when the “Color by property” combo is modified.

onApplyPressed()
updateProperties(properties_and_values)

Update the available properties in the combo box.

Parameters:

properties_and_values – Dict mapping property names to lists of values for all clustered structures

defineMappings()

Define mappings between model and the UI. For full documentation, see mappers.MapperMixin.

class schrodinger.application.canvas.clustergui.CanvasFingerprintClusterGUI(fp_clu, command=None)

Bases: MapperMixin, BaseWidget

A Container for GUI elements for the Clustering tab/section of the

following panels: * canvas_cluster_gui.py - Fingerprint Similarity (Canvas Similarity and Clustering) * interaction_fingerprints_gui.py - Interaction Fingerprints

ui_module = <module 'schrodinger.application.canvas.cluster_tab_ui' from '/scr/buildbot/builds/build/internal/lib/python3.11/site-packages/schrodinger/application/canvas/cluster_tab_ui.py'>
model_class

alias of ClusteringTabModel

defineMappings()

Override this in the subclass to define mappings. Should return a list of tuples [(<target>, <param>)]. Targets can be:

  1. a basic widget, like QLineEdit or QComboBox

  2. a custom object that inherits MapperMixin or TargetMixin

  3. a TargetSpec instance

  4. a slot

For common widgets, standard signals and getter/setter methods will be used, as defined in mappers._get_default_access_names().

For more fine-grained custom control, instantiate a TargetSpec object, which allows custom setters, getters, and signals to be specified.

Supplying a slot as the first element of the tuple is equivalent to providing TargetSpec(slot=my_slot).

Note that all target slots are triggered on setModel() as well as in response to the specified signal.

The param is an abstract param reference, e.g. MyModel.my_param.

Example:

def defineMappings(self):
    combo = self.style_combo
    return [(self.name_le, MyModel.name),
            (TargetSpec(combo,
                    getter=combo.currentText,
                    setter=combo.setCurrentText), MyModel.style),
            (self.coord_widget, MyModel.coord),
            (self._onASLTextChanged, MyModel.asl_text)]
__init__(fp_clu, command=None)

Creates a tab that can be used in a QTabWidget for calculating clustering. The tab has the following sections: Linkage, Cluster, Clustering Results, Apply Clustering

Parameters:

command (callable object) – function to be called when the Calculate Clustering button is pressed.

Return type:

QWidget

Returns:

widget containing the clustering gui

initSetUp()

Creates widget from ui and stores it ui_widget.

Suggested subclass use: create and initialize subwidgets, and connect signals.

initSetDefaults()

@overrides: widgetmixins.InitMixin

setNumClusters(num)

Set the number of clusters in the Apply Clustering Section

doApplyClustering()

Once the clustering has been performed for the selected entries this method will apply it

updateResults()

Once clustering has been performed this method should be called to update the clustering results GUI:

close()

Perform the tasks necessary when closing the panel. This will include closing all the open plot windows

showStatisticsPlot()

Display a plot of clustering statistics

showDendrogramPlot()

Display the clustering dendgoram

showDistanceMatrixPlot()

Display the distance matrix

class schrodinger.application.canvas.clustergui.ClusterStatisticsPlotDialog(fp_clu)

Bases: AppFramework

A class which displays a dialog with a plot of the statistics for the most recent clustering

num_clusters_selected

A pyqtSignal emitted by instances of the class.

PLOT_TYPES = ['Kelley Penalty', 'R-Squared', 'Semipartial R-Squared', 'Merge Distance', 'Separation Ratio']
__init__(fp_clu)

Create an instance of the dialog. Objects passed are the parent and the CanvasFingerprintCluster object which will have the statistics

Parameters:

fp_clu (CanvasFingerprintCluster object) – object that contains the clustering statistics

redraw()

Redraw the plot with the current settings

setPlotType(plot_type)

Called when the plot type option menu is changed

show()

Show the plot dialog

close()

Dismiss the window

click(event)

Click in plot handler

class schrodinger.application.canvas.clustergui.DendrogramPlotDialog(fp_clu=None)

Bases: QDialog

A class which displays a dialog with a plot of the dendrogram from the most recent clustering

num_clusters_selected

A pyqtSignal emitted by instances of the class.

__init__(fp_clu=None)

Create an instance of the dialog. Either fp_clu should be specified (CanvasFingerprintCluster object with data)

Parameters:

fp_clu (CanvasFingerprintCluster object) – object that contains the clustering statistics

setupColorByPropertyPopUp()
show()

Show the plot dialog

close()

Dismiss the window

getColorMap()

Return the color map based on the currentl “Color by property” settings in the pop up.

Returns:

ScalarMappable for mapping values to colors

Return type:

matplotlib.cm.ScalarMappable

calculateStructureColors(color_map)

Calculate colors for structure legs based on property values.

Uses property values from color_by_property_popup to determine structure colors. If no color-by-property is selected, all structures are colored black. Structure indices are obtained from self.clustered_st_order.

Parameters:

color_map – ScalarMappable for mapping property values to colors, or None

Returns:

List of color tuples, parallel to self.clustered_st_order

Return type:

list

prepareDendrogramLineData(lines, structure_colors)

Prepare dendrogram line data with colors for plotting.

Assembles line data for plotting, assigning colors to structure legs and cluster connections.

Parameters:
  • lines – List of (st_index, xcoords, ycoords) tuples from getDendrogramData

  • structure_colors – List of color tuples, parallel to self.clustered_st_order

Returns:

List of (st_index, xcoords, ycoords, color_tuple) tuples

Return type:

list

plotDendrogramLines(lines, structure_colors)

Plot dendrogram lines and circles on the subplot.

Prepares dendrogram line data with colors, then creates line objects for all dendrogram segments and adds circles at the bottom of structure legs. Populates self.line_objects and self.circle_collection.

Parameters:
  • lines – List of (st_index, xcoords, ycoords) tuples from getDendrogramData

  • structure_colors – List of color tuples for structure circles, parallel to clustered_st_order

Returns:

Maximum x coordinate across all lines

Return type:

float

setupMouseInteraction()

Define and register mouse event handlers for hover interactions.

Sets up callbacks for mouse motion and figure leave events to handle highlighting of structure legs and display of tooltips.

redraw()

Redraw the plot. Called when dialog is opened and also from the main panel when clustering data is changed.

click(event)

Click in plot handler

class schrodinger.application.canvas.clustergui.DistanceMatrixPlotDialog(fp_clu, structures=True)

Bases: AppFramework

A class which displays a dialog with a plot of the distance matrix associated with the most recent clustering

PLOT_TYPES = ['Cluster order', 'Original order']
__init__(fp_clu, structures=True)

Create an instance of the dialog.

Parameters:
  • fp_clu (CanvasFingerprintCluster object) – object that contains the clustering statistics

  • structures (bool) – True if the distance matrix should show structures when the user clicks on the plot, False if not TODO: This option is unsed (always set to True)

setPlotType(plot_type)

Called when the plot type combobox is changed

Parameters:

plot_type (string) – the new plot type

setColormap(color_map_name)

Called when the color map combobox is changed

Parameters:

color_map_name (string) – the new color map

redraw()

Force a redraw with refetching of the distance map data

draw()

Called when the plot type option menu is changed

show()

Show the plot dialog

close()

Dismiss the window

click(event)

Click in plot handler

drawStructure(canv, eid, title_label)

Draw the structure from the project with entry id ‘eid’ in the Canvas ‘canv’