Can't get nglview to work with Solara server - works in Jupyter

Hi All, I'm trying to get the nglview library working in Solara server. The following code works in Jupyter, but displays an empty box using solara run
import nglview
import solara
@solara.component
def Page():
solara.display(nglview.demo())
Page()
import nglview
import solara
@solara.component
def Page():
solara.display(nglview.demo())
Page()
All of my other solara code (using solara, reacton, ipyvutify, or ipywidgets) works fine. I'm aware of an issue from ~2021 with nglview displays in Voila requiring a resize, but I don't see the same behavior, and none of the fixes work. I feel like I'm doing something silly - any assistance would be greatly appreciated!
6 Replies
Jochem Smit
Jochem Smit2w ago
Hi, I'm not sure why this doesnt work, but depending on your needs you can also use ipymolstar, here is a pycafé example: https://app.py.cafe/jhsmit/ipymolstar-solara
PyCafe - Solara - Interactive Protein and Molecule Visualizer
Create & Share Streamlit, Dash and Python Apps Online.
TJ_Ragan
TJ_RaganOP2w ago
Ipymolstar almost works, but it’s backed by pdbe-molstar, which only allows loading mrc maps from the pdbe servers, and I want to upload my own. Thanks, though!
Jochem Smit
Jochem Smit2w ago
yeah I need to work on the docs, for pdbemolstar its possible to use local files:
# load local files via custom_data
from pathlib import Path
fpth = Path().resolve() / 'assets' / '6vsb.bcif'
custom_data = {
'data': fpth.read_bytes(),
'format': 'cif',
'binary': True,
}
view = PDBeMolstar(
custom_data=custom_data,
hide_water=True,
hide_carbs=True,
)
view
# load local files via custom_data
from pathlib import Path
fpth = Path().resolve() / 'assets' / '6vsb.bcif'
custom_data = {
'data': fpth.read_bytes(),
'format': 'cif',
'binary': True,
}
view = PDBeMolstar(
custom_data=custom_data,
hide_water=True,
hide_carbs=True,
)
view
from: https://github.com/Jhsmit/ipymolstar/blob/master/example.ipynb
GitHub
ipymolstar/example.ipynb at master · Jhsmit/ipymolstar
Mol* as anywidget. Contribute to Jhsmit/ipymolstar development by creating an account on GitHub.
Jochem Smit
Jochem Smit2w ago
hmm mrc maps i'm not sure though i'll have a look
TJ_Ragan
TJ_RaganOP2w ago
According to this: https://github.com/molstar/pdbe-molstar/issues/24, the ability to upload maps is missing (unlike uploading PDBs). Unless it’s been added in the 4 years since that discussion. I was able to upload my own pdb as custom data, but failed with maps, so probably not 😩
Monty Python
Monty Python2w ago
jpattle
<:issue_closed_completed:979047130847117343> [molstar/pdbe-molstar] Custom URL for loading density/maps/ccp4 files
I was wondering whether it is possible to load custom ccp4 files into the pdbe molstar web component. So far we have set up the pdbe molstar web component to load custom pdb files using the custom-data-url and custom-data-format attributes. Given that these custom files do not have associated maps in the www.ebi.ac.uk repository, using the show-maps attribute does not help. We have our own .ccp4 format files that we would like to load into the component in the same way we have loaded the pdb files. We have also tried to load these files by specifying custom-data-format='ccp4' but unfortunately it seems that is not the correct way to do it either as I get the error; Error: ccp4 not supported.. Looking at the Molstar Viewer (https://molstar.org/viewer/) there are options to load densities into the viewer from a custom url. Is it possible to use these features in the pdbe molstar web component? !image Thanks in advance for your help!
Labels
question
Created

Did you find this page helpful?