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