moleculekit.viewer.molstar.registry module#
Slot registry and topology hashing for the molstar viewer.
- class moleculekit.viewer.molstar.registry.Registry#
Bases:
objectThread-safe slot table for the molstar viewer.
Maps slot uuids to
Slotentries, each holding a live Molecule reference and a snapshot for change detection. All mutating operations are guarded by an internal lock so the monitor thread and request handlers can share it.- diff_and_snapshot()#
Diff each slot’s live mol against its snapshot.
Updates each changed slot’s snapshot (and topo_hash on a topology change) in place after diffing.
- register(mol)#
Register a molecule and return its slot uuid.
If
molis already registered (same object identity), its existing uuid is returned and no new slot is created.
- class moleculekit.viewer.molstar.registry.Slot(uuid, mol_ref, snapshot, topo_hash, label, visible=True)#
Bases:
objectA single registered molecule tracked by the viewer Registry.
- mol_ref#
The live, mutable Molecule reference held by the user.
- snapshot#
A
mol.copy()snapshot used for diffing againstmol_ref.
- 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.
- 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.