Skip to content

Commit b885886

Browse files
Minor widget enhancements (MDAnalysis#65)
- Add documentation link in widget details page - Add confirmation for widget delete from dashboard page - Add duplicate and delete support of widget from widget details page
1 parent 12cecfb commit b885886

20 files changed

Lines changed: 327 additions & 26 deletions

mdadash/backend/analyses/acf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ class ACFAnalysis(WidgetBase):
109109
name = "ACF"
110110
description = "Autocorrelation Function"
111111

112+
_doclink = (
113+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
114+
"mdadash.backend.analyses.acf.html"
115+
)
116+
112117
_notes = (
113118
"To correctly compute positional ACF using this widget, you must supply "
114119
"coordinates in the unwrapped convention, also known as no-jump. That is, "

mdadash/backend/analyses/com_distance.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ class COMDistance(WidgetBase):
9090
name = "COMDistance"
9191
description = "Distance between two COMs"
9292

93+
_doclink = (
94+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
95+
"mdadash.backend.analyses.com_distance.html"
96+
)
97+
9398
_inputs: ClassVar = [
9499
{
95100
"attribute": "_run_frequency",

mdadash/backend/analyses/contacts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class Contacts(WidgetBase):
8080
name = "Contacts"
8181
description = "Contacts within a cutoff"
8282

83+
_doclink = (
84+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
85+
"mdadash.backend.analyses.contacts.html"
86+
)
87+
8388
_inputs: ClassVar = [
8489
{
8590
"attribute": "_run_frequency",

mdadash/backend/analyses/custom_code.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def show(self, name, values):
106106
name = "Custom Code"
107107
description = "Custom user-defined code"
108108

109+
_doclink = (
110+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
111+
"mdadash.backend.analyses.custom_code.html"
112+
)
113+
109114
_inputs: ClassVar = [
110115
{
111116
"attribute": "_run_frequency",

mdadash/backend/analyses/dssp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class DSSPAnalysis(WidgetBase):
6868
name = "DSSP Analysis"
6969
description = "Secondary structure assignment of protein"
7070

71+
_doclink = (
72+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
73+
"mdadash.backend.analyses.dssp.html"
74+
)
75+
7176
_inputs: ClassVar = [
7277
{
7378
"attribute": "_run_frequency",

mdadash/backend/analyses/energies.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class EnergyWidgetBase:
7575
data_key = ""
7676
y_label = "Energy ( kJ / mol )"
7777

78+
_doclink = (
79+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
80+
"mdadash.backend.analyses.energies.html"
81+
"#mdadash.backend.analyses.energies.EnergyWidgetBase"
82+
)
83+
7884
_notes = (
7985
"Energies are only available for streaming trajectories and only if the "
8086
"simulation engine is configured to send them."
@@ -131,7 +137,7 @@ def _reset_plot_values(self):
131137

132138
def _set_title(self):
133139
"""Set plot title"""
134-
self.ax.set_title(self.title, y=1.05)
140+
self.ax.set_title(self.title)
135141

136142
def _set_x_values(self):
137143
"""Set the values for the x-axis"""

mdadash/backend/analyses/helix_analysis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class HelixAnalysis(WidgetBase):
8989
name = "Helix Analysis"
9090
description = "Helix analysis using HELANAL"
9191

92+
_doclink = (
93+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
94+
"mdadash.backend.analyses.helix_analysis.html"
95+
)
96+
9297
_inputs: ClassVar = [
9398
{
9499
"attribute": "_run_frequency",

mdadash/backend/analyses/hydrogen_bonds.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ class HydrogenBonds(WidgetBase):
111111
"of donor-hydrogen pairs."
112112
)
113113

114+
_doclink = (
115+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
116+
"mdadash.backend.analyses.hydrogen_bonds.html"
117+
)
118+
114119
_inputs: ClassVar = [
115120
{
116121
"attribute": "_run_frequency",

mdadash/backend/analyses/janin.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class JaninPlot(WidgetBase):
3838
Show allowed and marginally allowed regions
3939
Default: ``True``
4040
41+
Custom title
42+
Custom title for the plot
43+
Default: ''
44+
4145
**Output**
4246
4347
Here is an example output plot of this widget:
@@ -50,6 +54,11 @@ class JaninPlot(WidgetBase):
5054
name = "Janin Plot"
5155
description = "Dihedral angles analysis using Janin plot"
5256

57+
_doclink = (
58+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
59+
"mdadash.backend.analyses.janin.html"
60+
)
61+
5362
_inputs: ClassVar = [
5463
{
5564
"attribute": "selection",
@@ -64,24 +73,32 @@ class JaninPlot(WidgetBase):
6473
"description": "Show allowed and marginally allowed regions",
6574
"type": "bool",
6675
},
76+
{
77+
"attribute": "custom_title",
78+
"name": "Custom title",
79+
"description": "Custom title for the plot",
80+
"type": "str",
81+
},
6782
]
6883

6984
def __init__(self):
7085
super().__init__()
7186
self.selection = "protein"
7287
self.ref = True
7388
self.janin = None
89+
self.title = "protein"
90+
self.custom_title = None
7491
self._setup_plot()
7592

7693
def _setup_plot(self):
7794
"""Setup matplotlib plot"""
7895
self.fig, self.ax = plt.subplots()
7996
(self.plot,) = self.ax.plot([], [])
80-
self.ax.grid(True)
8197

8298
def _update_selection(self):
8399
"""Update atom groups when selection phrase changes"""
84100
self.janin = Janin(self.u.select_atoms(self.selection))
101+
self.title = f"{self.selection}"
85102

86103
def on_post_connect(self):
87104
"""on_post_connect handler"""
@@ -108,5 +125,8 @@ def run_every_frame(self):
108125
self.janin.plot(ax=self.ax, color="black", marker=".", ref=self.ref)
109126
self.ax.set_xlabel(r"$\chi_1$ (degrees)")
110127
self.ax.set_ylabel(r"$\chi_2$ (degrees)")
128+
self.ax.set_title(
129+
self.custom_title.replace("\\n", "\n") if self.custom_title else self.title
130+
)
111131
self.fig.canvas.draw()
112132
display(self.fig)

mdadash/backend/analyses/msd.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ class MSDAnalysis(WidgetBase):
8888
name = "MSD Analysis"
8989
description = "Mean squared displacement analysis"
9090

91+
_doclink = (
92+
"https://mdadash.readthedocs.io/en/latest/autosummary/"
93+
"mdadash.backend.analyses.msd.html"
94+
)
95+
9196
_notes = (
9297
"To correctly compute MSD using this widget, you must supply coordinates "
9398
"in the unwrapped convention, also known as no-jump. That is, when atoms "

0 commit comments

Comments
 (0)