MolGFX
Scene and appearance

Focus, interaction, and picking

Direct attention to a molecular region and recover semantic picks.

Scene.focus() records a target of interest. It is useful for a pocket, ligand, or chain when a viewer or renderer frames the scene.

import molframe
import molgfx

structure = molframe.read("4hhb.cif").infer_bonds()
scene = molgfx.Scene(structure)

scene.focus("resname HEM")

Interaction channels attach molecular targets to presentation state:

scene.set_interaction(channel="selected", target="resname HEM")
scene.set_interaction(channel="hovered", target="chain A")
scene.set_interaction(channel="custom", name="active_site", target="resname HEM")

A host picks the entity under a pixel with renderer.pick(x, y) after rendering; the browser bindings expose the same detached pick. A PickResult carries a semantic kind plus optional dataset, chunk, row, and volume-label provenance—not a renderer-private handle.

Keep state and style separate

Interaction channels describe what is selected or hovered. A visual style describes how that state should look. This separation lets the same scene state drive a browser viewer and an application-specific UI.

Semantic interaction contract

The Session is the durable selection authority. Browser scene state is a revisioned projection and must carry the scene-instance token, topology generation, source revision, event id, target granularity, and operation. Unknown or stale mappings are rejected with a resynchronization result; equal row numbers from different structures are never interchangeable. Atom, residue, chain, entity, bond, and volume picks remain typed, so a volume or bond row cannot be used as an atom for a measurement.

This contract is implemented at the native/semantic boundary, but the actual browser and notebook interaction matrix is not certified by this page. No browser or Python scenario is claimed as passed; modifier precedence, rapid Shift clicks, stale readbacks, replacement, hover isolation, and cross-host round trips remain unverified.

On this page