Spaces:
Runtime error
Runtime error
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, | |
} | |
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}") | |
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") | |