molsysviewer.MolSysView#

class molsysviewer.MolSysView(*, debug_js=None)[source]#

Mol* viewer widget with a Python-facing API.

Provides structure loading, visibility control, shape management, and utilities to export static HTML views for documentation or sharing.

Parameters:

debug_js (bool | None)

__init__(*, debug_js=None)[source]#
Parameters:

debug_js (bool | None)

Return type:

None

Methods

__init__(*[, debug_js])

add(from_molecular_system, *[, selection, ...])

Add atoms/structures from another system into this view and refresh the viewer (live).

append_structures(from_molecular_system, *)

Append structures (frames) to the loaded system and refresh the viewer (live).

clear_decorations(*[, shapes, styles, labels])

Clear decorative elements (shapes/styles/labels) without touching the loaded structure or camera.

get([element, selection, structure_indices, ...])

Retrieve attribute values from the current molecular system (MolSysMT get).

get_camera_snapshot(*[, pretty])

Return the last camera snapshot received from the frontend.

hide([selection, structure_indices, syntax])

Hide atoms matching the given selection (MolSysMT syntax by default).

info([element, selection, syntax, mask, ...])

isolate([selection, structure_indices, syntax])

Show only the atoms in selection; hide everything else (reset if selection == 'all').

load(molecular_system[, selection, ...])

Load a molecular system (MolSysMT-compatible) into the viewer.

new_layer(*[, tag, kind])

Create a new layer (non-structural visual group).

new_region([selection, atom_indices, tag, ...])

Create a new region (structural subset) with an optional representation.

remove(*[, selection, structure_indices, syntax])

Remove atoms and/or structures from this view and refresh the viewer (live).

reset_camera()

Reset the camera / view in the frontend.

reset_viewer()

Fully clear the viewer and reset internal state (requires a new load(...)).

select([selection, structure_indices, ...])

Select indices from the current molecular system (MolSysMT selection language).

set(*[, element, selection, ...])

Set attribute values on the loaded system and refresh the viewer (live).

set_camera_snapshot(snapshot, *[, duration_ms])

Apply a previously saved camera snapshot.

set_controls_visible(visible, *[, autohide, ...])

Show or hide the on-canvas controls (reset/full/bg/spin/swing + trajectory bar).

show([selection, structure_indices, syntax, ...])

Show the widget (first call or if force=True) and optionally adjust visibility.

write_html(output_filename, *[, title, ...])

Export this viewer widget to an HTML file.

zoom([selection, structure_indices, syntax, ...])

Focus the camera on the geometric center of a selection of atoms.

Attributes

js_logs

Logs received from the frontend when debug_js is enabled.

layers

Public registry of layers (non-structural visuals).

molsys

Read-only handle to the loaded MolSysMT molecular system.

regions

Public registry of regions (structural selections).

visible_atom_indices

Return the indices of currently visible atoms.

visible_structure_indices

Return the indices of currently visible structures.