Spaces:
Runtime error
Runtime error
File size: 1,318 Bytes
5e5b762 544da8b 5e5b762 544da8b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import solara
from ipymolstar import PDBeMolstar
from solara.components.file_drop import FileInfo
# gives an error, should be some error-less empty data file
custom_data_initial = {
"data": b"data_",
"format": "cif",
"binary": False,
}
@solara.component
def Page():
custom_data = solara.use_reactive(custom_data_initial)
dark_effective = solara.lab.use_dark_effective()
def on_cif_file(file_info: FileInfo):
custom_data.set({"data": file_info["data"], "format": "cif", "binary": False})
solara.Title("Alphafold3 result viewer")
with solara.AppBar():
solara.lab.ThemeToggle()
with solara.Sidebar():
solara.FileDrop(label="Upload cif file", on_file=on_cif_file, lazy=False)
with solara.Card():
theme = "dark" if dark_effective else "light"
PDBeMolstar.element(
molecule_id="" if not custom_data.value else "",
custom_data=custom_data.value if custom_data.value else None,
show_water=False,
theme=theme,
).key(f"pdbemolstar-{dark_effective}")
@solara.component
def Layout(children):
dark_effective = solara.lab.use_dark_effective()
return solara.AppLayout(
children=children, toolbar_dark=dark_effective, color=None
) # if dark_effective else "primary")
|