Skip to content

Commit

Permalink
Show color legend in the Speck component (#641)
Browse files Browse the repository at this point in the history
* Show color legend in the Speck component

* Specify commit for speck package

* Change validation function for the speck legend test

* Update callback in the speck legend test

* Adding style props to mol3d and speck

Co-authored-by: Hammad Khan <[email protected]>
  • Loading branch information
nickmelnikov82 and HammadTheOne authored Dec 14, 2021
1 parent c507bf3 commit f557022
Show file tree
Hide file tree
Showing 30 changed files with 288 additions and 60 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* [#628](https://github.com/plotly/dash-bio/pull/628) Added option to add colored labels to rows and columns on Clustergram.
* [#640](https://github.com/plotly/dash-bio/pull/640) Added loading states to each component to support custom loading css with `dash-data-is-loading`.
* [#642](https://github.com/plotly/dash-bio/pull/642) Added `scrollZoom` property to Molecule2dViewer.

* [#641](https://github.com/plotly/dash-bio/pull/641) Added `showLegend` property to Speck viewer, which allows users to show a color legend for atoms shown on the canvas.
* [#641](https://github.com/plotly/dash-bio/pull/641) Added `style` property to Speck and Molecule3dViewer to enable generic style overrides on the plot div.

### Changed
* [#589](https://github.com/plotly/dash-bio/pull/589) Removed hardcoded clustergram linkage method, added parameter `link_method` instead.
Expand Down
6 changes: 3 additions & 3 deletions R/dashbioMolecule3dViewer.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# AUTO GENERATED FILE - DO NOT EDIT

dashbioMolecule3dViewer <- function(id=NULL, atomLabelsShown=NULL, backgroundColor=NULL, backgroundOpacity=NULL, labels=NULL, loading_state=NULL, modelData=NULL, onChangeSelection=NULL, onRenderNewData=NULL, orbital=NULL, selectedAtomIds=NULL, selectionType=NULL, shapes=NULL, styles=NULL, zoom=NULL, zoomTo=NULL) {
dashbioMolecule3dViewer <- function(id=NULL, atomLabelsShown=NULL, backgroundColor=NULL, backgroundOpacity=NULL, height=NULL, labels=NULL, loading_state=NULL, modelData=NULL, onChangeSelection=NULL, onRenderNewData=NULL, orbital=NULL, selectedAtomIds=NULL, selectionType=NULL, shapes=NULL, style=NULL, styles=NULL, width=NULL, zoom=NULL, zoomTo=NULL) {

props <- list(id=id, atomLabelsShown=atomLabelsShown, backgroundColor=backgroundColor, backgroundOpacity=backgroundOpacity, labels=labels, loading_state=loading_state, modelData=modelData, onChangeSelection=onChangeSelection, onRenderNewData=onRenderNewData, orbital=orbital, selectedAtomIds=selectedAtomIds, selectionType=selectionType, shapes=shapes, styles=styles, zoom=zoom, zoomTo=zoomTo)
props <- list(id=id, atomLabelsShown=atomLabelsShown, backgroundColor=backgroundColor, backgroundOpacity=backgroundOpacity, height=height, labels=labels, loading_state=loading_state, modelData=modelData, onChangeSelection=onChangeSelection, onRenderNewData=onRenderNewData, orbital=orbital, selectedAtomIds=selectedAtomIds, selectionType=selectionType, shapes=shapes, style=style, styles=styles, width=width, zoom=zoom, zoomTo=zoomTo)
if (length(props) > 0) {
props <- props[!vapply(props, is.null, logical(1))]
}
component <- list(
props = props,
type = 'Molecule3dViewer',
namespace = 'dash_bio',
propNames = c('id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'labels', 'loading_state', 'modelData', 'onChangeSelection', 'onRenderNewData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'styles', 'zoom', 'zoomTo'),
propNames = c('id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'height', 'labels', 'loading_state', 'modelData', 'onChangeSelection', 'onRenderNewData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'style', 'styles', 'width', 'zoom', 'zoomTo'),
package = 'dashBio'
)

Expand Down
6 changes: 3 additions & 3 deletions R/dashbioSpeck.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# AUTO GENERATED FILE - DO NOT EDIT

dashbioSpeck <- function(id=NULL, data=NULL, loading_state=NULL, presetView=NULL, scrollZoom=NULL, view=NULL) {
dashbioSpeck <- function(id=NULL, data=NULL, loading_state=NULL, presetView=NULL, scrollZoom=NULL, showLegend=NULL, style=NULL, view=NULL) {

props <- list(id=id, data=data, loading_state=loading_state, presetView=presetView, scrollZoom=scrollZoom, view=view)
props <- list(id=id, data=data, loading_state=loading_state, presetView=presetView, scrollZoom=scrollZoom, showLegend=showLegend, style=style, view=view)
if (length(props) > 0) {
props <- props[!vapply(props, is.null, logical(1))]
}
component <- list(
props = props,
type = 'Speck',
namespace = 'dash_bio',
propNames = c('id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'view'),
propNames = c('id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'showLegend', 'style', 'view'),
package = 'dashBio'
)

Expand Down
15 changes: 12 additions & 3 deletions dash_bio/Molecule3dViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Molecule3dViewer(Component):
- backgroundOpacity (number; default 0):
Property to change the background opacity - ranges from 0 to 1.
- height (number; optional):
The height (in px) of the container.
- labels (list of dicts; optional):
Labels corresponding to the atoms of the molecule. Each label has
a `text` field, a string containing the label content, and can
Expand Down Expand Up @@ -89,6 +92,9 @@ class Molecule3dViewer(Component):
Add a predefined renderable shape objects to the molecule. Valid
shape types are Arrow, Sphere, and Cylinder.
- style (dict; default { height: 500, width: 500,}):
Generic style overrides on the plot div.
- styles (list of dicts; optional):
Property that can be used to change the representation of the
molecule. Options include sticks, cartoon and sphere.
Expand All @@ -99,6 +105,9 @@ class Molecule3dViewer(Component):
- visualization_type (a value equal to: 'cartoon', 'sphere', 'stick'; optional)
- width (number; optional):
The width (in px) of the container.
- zoom (dict; default { factor: 0.8, animationDuration: 0, fixedPath: False,}):
Zoom the current view by a constant factor, with optional
parameters to modify the duration and motion of the zoom
Expand Down Expand Up @@ -144,12 +153,12 @@ class Molecule3dViewer(Component):
The index value used to identify the residue; residues are
numbered sequentially starting from 1."""
@_explicitize_args
def __init__(self, id=Component.UNDEFINED, selectionType=Component.UNDEFINED, backgroundColor=Component.UNDEFINED, backgroundOpacity=Component.UNDEFINED, styles=Component.UNDEFINED, modelData=Component.UNDEFINED, atomLabelsShown=Component.UNDEFINED, selectedAtomIds=Component.UNDEFINED, labels=Component.UNDEFINED, orbital=Component.UNDEFINED, zoom=Component.UNDEFINED, zoomTo=Component.UNDEFINED, shapes=Component.UNDEFINED, onRenderNewData=Component.UNDEFINED, onChangeSelection=Component.UNDEFINED, loading_state=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'labels', 'loading_state', 'modelData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'styles', 'zoom', 'zoomTo']
def __init__(self, id=Component.UNDEFINED, selectionType=Component.UNDEFINED, backgroundColor=Component.UNDEFINED, backgroundOpacity=Component.UNDEFINED, styles=Component.UNDEFINED, modelData=Component.UNDEFINED, atomLabelsShown=Component.UNDEFINED, selectedAtomIds=Component.UNDEFINED, labels=Component.UNDEFINED, orbital=Component.UNDEFINED, zoom=Component.UNDEFINED, zoomTo=Component.UNDEFINED, shapes=Component.UNDEFINED, height=Component.UNDEFINED, width=Component.UNDEFINED, style=Component.UNDEFINED, onRenderNewData=Component.UNDEFINED, onChangeSelection=Component.UNDEFINED, loading_state=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'height', 'labels', 'loading_state', 'modelData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'style', 'styles', 'width', 'zoom', 'zoomTo']
self._type = 'Molecule3dViewer'
self._namespace = 'dash_bio'
self._valid_wildcard_attributes = []
self.available_properties = ['id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'labels', 'loading_state', 'modelData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'styles', 'zoom', 'zoomTo']
self.available_properties = ['id', 'atomLabelsShown', 'backgroundColor', 'backgroundOpacity', 'height', 'labels', 'loading_state', 'modelData', 'orbital', 'selectedAtomIds', 'selectionType', 'shapes', 'style', 'styles', 'width', 'zoom', 'zoomTo']
self.available_wildcard_properties = []
_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
Expand Down
12 changes: 9 additions & 3 deletions dash_bio/Speck.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class Speck(Component):
The option of whether or not to allow scrolling to control the
zoom.
- showLegend (boolean; default False):
The option of whether to show color legend.
- style (dict; default { height: '600px', width: '600px', position: 'relative',}):
Generic style overrides on the plot div.
- view (dict; default speckView.new()):
An object that determines and controls various parameters related
to how the molecule is displayed.
Expand Down Expand Up @@ -107,12 +113,12 @@ class Speck(Component):
- zoom (number; optional)"""
@_explicitize_args
def __init__(self, id=Component.UNDEFINED, data=Component.UNDEFINED, scrollZoom=Component.UNDEFINED, view=Component.UNDEFINED, presetView=Component.UNDEFINED, loading_state=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'view']
def __init__(self, id=Component.UNDEFINED, data=Component.UNDEFINED, scrollZoom=Component.UNDEFINED, view=Component.UNDEFINED, presetView=Component.UNDEFINED, style=Component.UNDEFINED, loading_state=Component.UNDEFINED, showLegend=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'showLegend', 'style', 'view']
self._type = 'Speck'
self._namespace = 'dash_bio'
self._valid_wildcard_attributes = []
self.available_properties = ['id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'view']
self.available_properties = ['id', 'data', 'loading_state', 'presetView', 'scrollZoom', 'showLegend', 'style', 'view']
self.available_wildcard_properties = []
_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
Expand Down
4 changes: 2 additions & 2 deletions dash_bio/async-moleculeviewer3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_bio/async-moleculeviewer3.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit f557022

Please sign in to comment.