moleculekit.viewer.molstar.inline module#
Inline (server-less) Mol* viewer for Jupyter notebooks. Emits an <iframe srcdoc> that loads Mol* from a CDN and renders the molecule entirely from data inlined into the cell output.
- class moleculekit.viewer.molstar.inline.MolstarInlineView(*, height, mvsj=None, payload=None)#
Bases:
objectNotebook cell output that renders a Mol* viewer inline.
Its
_repr_html_returns an<iframe srcdoc>that loads Mol* from a CDN and renders the inlined scene/data with no running server. Construct it with either a MolViewSpecmvsjstring (single-frame path) or apayloaddict (multi-frame trajectory path); exactly one is used.
- moleculekit.viewer.molstar.inline.build_inline_view(mol, scene, *, height=420)#
Build a MolstarInlineView for
mol.A single-frame molecule takes the MVS path (custom representations from
sceneare applied); a multi-frame molecule takes the trajectory path.- Parameters:
- Returns:
view – A notebook cell output rendering the inline viewer.
- Return type:
- moleculekit.viewer.molstar.inline.coords_to_dcd_bytes(mol)#
Encode all frames of mol.coords (Angstrom) into a CHARMM/NAMD DCD byte string in memory. Lossless float32, no unit cell, no temp file.
- moleculekit.viewer.molstar.inline.running_in_notebook()#
True only inside a Jupyter/IPython kernel (ZMQInteractiveShell).
Terminal IPython and plain Python return False, so view() falls back to the server there.
- Returns:
in_notebook – True when running inside a Jupyter/IPython kernel, otherwise False.
- Return type: