moleculekit.viewer.molstar.registry module#

Slot registry and topology hashing for the molstar viewer.

class moleculekit.viewer.molstar.registry.Registry#

Bases: object

Thread-safe slot table for the molstar viewer.

diff_and_snapshot()#

Diff each slot’s live mol against its snapshot.

Returns a list of (kind, slot_uuid, payload_hints) tuples. Updates each slot’s snapshot/topo_hash in place after diffing. Empty list when nothing changed.

Return type:

list[tuple[str, str, dict]]

register(mol)#
Return type:

str

remove(uid)#
Return type:

None

class moleculekit.viewer.molstar.registry.Slot(uuid, mol_ref, snapshot, topo_hash, label, visible=True)#

Bases: object

label: str#
mol_ref: Any#
snapshot: Any#
topo_hash: str#
uuid: str#
visible: bool = True#
moleculekit.viewer.molstar.registry.coords_to_bytes(mol)#

Return all frames as little-endian float32 bytes.

Layout: per frame, the flat [x0..xN, y0..yN, z0..zN] vector matching the per-frame layout used by molecule_to_dict.

Return type:

bytes

moleculekit.viewer.molstar.registry.topo_hash(mol)#

Stable sha1 hex over the topology-defining fields of a Molecule.

Skipped: coords, beta, occupancy, charge (partial charge) — these can vary without a structural change to the rendered scene.

Return type:

str