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, built from the shared scene rule:
mol.reps, together with any one-off representation added byview()’ssel,styleandcolorarguments, replace the automatic scene when set, matching the VMD and NGL backends. A multi-frame molecule takes the trajectory path instead.- Parameters:
mol (
Molecule) – The molecule to render.scene (
dict) – Scene description with arepresentationslist (as produced for the viewer). Currently unused: the single-frame path builds its own description frommoldirectly, and the trajectory path never looks at it either (Mol*’s public UMD applies its default preset for trajectories; see_build_trajectory_view). Still accepted becausemolecule.py’s_viewMolstarpasses it.height (
int) – Height of the rendered iframe in pixels. Defaults toDEFAULT_HEIGHT.
- 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: