ViewerJSON#
molsysmt.ViewerJSON is the native lightweight 3D graphics representation in MolSysMT used for WebGL rendering and interactive visualization engines.
Overview and Role#
As a user, molsysmt.ViewerJSON is the intermediate dictionary schema wrapped by the ViewerJSON dataclass when calling msm.view(system) or converting a system for web rendering. It encapsulates atomic coordinates, element symbols, residue/chain labels, bond connectivity, and periodic box dimensions into a pure, serializable JSON schema.
Declarative Schema#
The underlying data dictionary of ViewerJSON follows a standardized graphics payload schema:
Top-Level Key |
Value Type |
Description |
|---|---|---|
|
String ( |
Graphics payload schema version tag. |
|
Dictionary of Lists |
Columnar per-atom vectors: |
|
Dictionary |
Bond connectivity mapping: |
|
List of Dicts |
Frame list containing |
Usage and Workflow#
import molsysmt as msm
# 1. Convert molecular system to a ViewerJSON object
viewer_obj = msm.convert(system, to_form='molsysmt.ViewerJSON')
# 2. Export payload as JSON string or write to gzipped file
json_str = viewer_obj.dumps(indent=2)
viewer_obj.dump("molecular_graphics.json.gz", compression="gzip")
# 3. Render directly in Jupyter notebook or web frontend
view = msm.view(viewer_obj)
Invariants and Performance#
Pure JSON Primitives: All internal values are strictly primitive Python types (
dict,list,str,int,float,None).Built-In Gzip Compression: Supports direct gzip compression (
compression="gzip") for fast network transmission.
API Documentation#
Viewer form converters and getters are documented under the [Visualization Tools].