import nglview as nv
import parmed as pmd
from ipywidgets import IntSlider, VBox
# !wget https://raw.githubusercontent.com/rdkit/rdkit/master/rdkit/Chem/Subshape/test_data/5ht3ligs.sdf
parms = pmd.rdkit.from_sdf('5ht3ligs.sdf') # require parmed, rdkit
parms
[<Structure 22 atoms; 1 residues; 24 bonds; NOT parametrized>, <Structure 24 atoms; 1 residues; 26 bonds; NOT parametrized>, <Structure 25 atoms; 1 residues; 28 bonds; NOT parametrized>, <Structure 26 atoms; 1 residues; 29 bonds; NOT parametrized>]
view = nv.NGLWidget()
slider = IntSlider(max=len(parms)-1)
def show_one_ligand(change):
val = change['new']
view.show_only([val])
slider.observe(show_one_ligand, 'value')
VBox([view, slider])
Failed to display Jupyter Widget of type VBox
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.
for p in parms:
view.add_structure(nv.ParmEdTrajectory(p))
view.show_only([0])
[(view[i].clear(), view[i].add_licorice()) for i in range(4)]
[(None, None), (None, None), (None, None), (None, None)]