Py.Cafe

jhsmit/

ipymolstar-shiny

Molecule Visualization Tool with PDBeMolstar

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from shiny import reactive
from shiny.express import input, ui, render
from shinywidgets import render_widget, reactive_read
from ipymolstar import PDBeMolstar

ui.input_text("molecule_id", "Molecule id", "1qyn")

@render_widget
def molstar():
    view = PDBeMolstar(molecule_id='1qyn')
    return view

@reactive.effect
def _():
    molecule_id = input.molecule_id()
    # check for valid pdb id
    if len(molecule_id) == 4:
        molstar.widget.molecule_id = input.molecule_id()

@render.text
def center():
    event = reactive_read(molstar.widget, 'mouseover_event')
    return f"Mouseover event: {event}"