A fast, beautiful molecular viewer
Project description
megane
Spectacles for atomistic data.
1M+ atoms at 60fps. Visual pipelines. Jupyter, browser, React, VSCode.
Docs · Getting Started · PyPI · npm
Features
- 1M+ Atoms at 60fps — Billboard impostor rendering scales from small molecules to massive complexes in real time. InstancedMesh for small systems auto-switches to GPU-accelerated billboard impostors for large systems. Stream XTC trajectories over WebSocket.
- Runs Everywhere — Jupyter widget, CLI server, React component, and VSCode extension. Rust-based PDB, GRO, XYZ, MOL, and XTC parsers shared between Python (PyO3) and browser (WASM) — parse once, run anywhere.
- Visual Pipeline Editor — Build visualization workflows by wiring nodes. 8 node types (load, bond, filter, modify, labels, polyhedra, viewport) with 6 typed data channels (particle, bond, cell, label, mesh, trajectory) flowing through color-coded edges.
- Embed & Integrate — Control the viewer from Plotly via ipywidgets events. Embed in MDX / Next.js docs. React to
frame_change,selection_change, andmeasurementevents. Use the framework-agnostic renderer from Vue, Svelte, or vanilla JS.
Scale
megane renders over 1 million atoms at 60fps in the browser. Small systems get high-quality InstancedMesh spheres and cylinders; large systems automatically switch to GPU-accelerated billboard impostors. No desktop app, no plugin — just a browser tab.
Trajectory streaming works over WebSocket via a binary protocol. Load an XTC file and scrub through thousands of frames in real time, without reading everything into memory.
Anywhere
One codebase, every environment.
| Environment | How | Install |
|---|---|---|
| Jupyter | anywidget inline viewer | pip install megane |
| Browser | megane serve local server |
pip install megane |
| React | <MeganeViewer /> component |
npm install megane-viewer |
| VSCode | Custom editor for .pdb, .gro, .xyz | Extension |
The secret: PDB, GRO, XYZ, MOL, and XTC parsers are written in Rust and compiled to both PyO3 (Python) and WASM (browser). Parse once, run anywhere.
Visual Pipelines
Wire nodes to build visualization workflows — no code required.
8 node types across 5 categories: load data, add bonds, filter atoms by query, modify scale and opacity per-group, generate labels, render coordination polyhedra, and display in a 3D viewport.
6 typed data channels — particle, bond, cell, label, mesh, trajectory — flow through color-coded edges. Only matching types can connect.
Pipelines serialize to JSON, so you can save, share, and version-control your visualization recipes.
Integrate
megane is not a walled garden. It fits into your existing workflow.
Plotly — Click a point on a Plotly FigureWidget to jump to a trajectory frame. Use megane's on_event("frame_change") callback to update Plotly markers in sync.
MDX / Next.js — Drop <MeganeViewer /> or <Viewport /> into your .mdx documentation. WASM parsing works out of the box with a one-line webpack config.
ipywidgets — React to frame_change, selection_change, and measurement events. Compose megane with any widget in the Jupyter ecosystem.
Framework-agnostic — MoleculeRenderer is a plain Three.js class. Mount it in Vue, Svelte, or a vanilla <div>.
Installation
Python
pip install megane
npm (for React embedding)
npm install megane-viewer
Quick Start
Jupyter Notebook
import megane
viewer = megane.MolecularViewer()
viewer.load("protein.pdb")
viewer # display in cell
# With trajectory
viewer.load("protein.pdb", xtc="trajectory.xtc")
viewer.frame_index = 50
CLI
megane serve protein.pdb
megane serve protein.pdb --xtc trajectory.xtc
megane serve # upload from browser
React
import { MeganeViewer, parseStructureFile } from "megane-viewer";
function App() {
const [snapshot, setSnapshot] = useState(null);
const handleUpload = async (file: File) => {
const result = await parseStructureFile(file);
setSnapshot(result.snapshot);
};
return <MeganeViewer snapshot={snapshot} mode="local" /* ... */ />;
}
Supported File Formats
| Format | Extension | Description |
|---|---|---|
| PDB | .pdb |
Protein Data Bank |
| GRO | .gro |
GROMACS structure file |
| XYZ | .xyz |
Cartesian coordinate format |
| MOL/SDF | .mol, .sdf |
MDL Molfile (V2000) |
| XTC | .xtc |
GROMACS compressed trajectory |
Development
Prerequisites
- Python 3.10+
- Node.js 18+
- Rust (for building the parser)
- uv
Setup
git clone https://github.com/hodakamori/megane.git
cd megane
# Python
uv sync --extra dev
# Node.js
npm install
npm run build
Development Mode
# Terminal 1: Vite dev server
npm run dev
# Terminal 2: Python backend
uv run megane serve protein.pdb --dev --no-browser
Tests
uv run pytest # Python tests
npm test # TypeScript unit tests
cargo test -p megane-core # Rust tests
make test-all # All tests
Project Structure
src/ TypeScript frontend
renderer/ Three.js rendering (impostor, mesh, shaders)
protocol/ Binary protocol decoder + web workers
parsers/ WASM-based file parsers (PDB, GRO, XYZ, MOL, XTC)
logic/ Bond / label / vector source logic
components/ React UI components
hooks/ Custom React hooks
stream/ WebSocket client
crates/ Rust workspace
megane-core/ Core parsers and bond inference
megane-python/ PyO3 Python extension
megane-wasm/ WASM bindings (wasm-bindgen)
python/megane/ Python backend
parsers/ PDB / XTC parsers
protocol.py Binary protocol encoder
server.py FastAPI WebSocket server
widget.py anywidget Jupyter widget
tests/ Tests (Python, TypeScript, E2E)
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file megane-0.3.0.tar.gz.
File metadata
- Download URL: megane-0.3.0.tar.gz
- Upload date:
- Size: 383.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e876b2202c17416e33e86f411f1071bcadfc4d4b19e8609cc27243261d2dc298
|
|
| MD5 |
9f8e4aa4697f576a0cbdd7519eb5ddff
|
|
| BLAKE2b-256 |
20bd431f1ef437adb36981d5186de58efc4d620d4022ebc3965702f4ca13f579
|
Provenance
The following attestation bundles were made for megane-0.3.0.tar.gz:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0.tar.gz -
Subject digest:
e876b2202c17416e33e86f411f1071bcadfc4d4b19e8609cc27243261d2dc298 - Sigstore transparency entry: 1074979243
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: megane-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 655.0 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
980fc0082c4afd0c08b1557da88f5e90d9c6c3e879884391ab1afe585bf8c4e2
|
|
| MD5 |
b6656e4be28356f4707ca9c3fd94a247
|
|
| BLAKE2b-256 |
8490173932280c754f18c66017e24ef571b86bf8384849e2664ef9a1c16e6834
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
980fc0082c4afd0c08b1557da88f5e90d9c6c3e879884391ab1afe585bf8c4e2 - Sigstore transparency entry: 1074979354
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: megane-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 653.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34ede43832b10f8ed681ebfc2a85ce9ed79b65d94783e1860f93436f75f2c6ea
|
|
| MD5 |
7b982631970ef4e0ddbdbd59b74f28ea
|
|
| BLAKE2b-256 |
a69f383e4a679915471758fc06cb1fee7c09db99ee9f8b94beb65a53f1404a27
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
34ede43832b10f8ed681ebfc2a85ce9ed79b65d94783e1860f93436f75f2c6ea - Sigstore transparency entry: 1074979320
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: megane-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 654.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efed7081b182544cba8f2dae4b9a5850ba4d5524c746cce7631ea852bee30274
|
|
| MD5 |
5912704ae68c1c32b2fc48593026eca3
|
|
| BLAKE2b-256 |
01fcbd0a78303bb3146c86784ff9504cb22d52efe5c1d61250e65fc479f2cf7b
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
efed7081b182544cba8f2dae4b9a5850ba4d5524c746cce7631ea852bee30274 - Sigstore transparency entry: 1074979547
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: megane-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 653.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f503da14fd4072618a74fa82fa2b189cc4cbec7a71cd669f46530a15e170ea53
|
|
| MD5 |
30fe7caf61395486390cad71c6e8e2ea
|
|
| BLAKE2b-256 |
8ee7a3f1da4190874254a5ef0ba138980f2939437a4c069e04a9f2cca6aae22a
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f503da14fd4072618a74fa82fa2b189cc4cbec7a71cd669f46530a15e170ea53 - Sigstore transparency entry: 1074979507
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: megane-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 657.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75084e377bf8e7930c1651ee690a0ae6a10dfbd9a90b224f1c26a152177f44ce
|
|
| MD5 |
d77f153b390a3a058abcc524d125ce7c
|
|
| BLAKE2b-256 |
79bdcc3c34f484745112455fa5374eef3d3b998d52b5df522888326fc775ff3d
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
75084e377bf8e7930c1651ee690a0ae6a10dfbd9a90b224f1c26a152177f44ce - Sigstore transparency entry: 1074979282
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: megane-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 656.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f09fd6e639037a96ee85cb38148ec27c31bb27d823031abe3329e83efdac85e0
|
|
| MD5 |
dde795296c96be697110620e2a21ce6b
|
|
| BLAKE2b-256 |
1108d8f0a47e48a4348727a7cecf23fc00bfcb78ed0274449b0185713af06439
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f09fd6e639037a96ee85cb38148ec27c31bb27d823031abe3329e83efdac85e0 - Sigstore transparency entry: 1074979452
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: megane-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 657.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d521c210e8d1a201c35dbd660019dbbae72578468fca16b2cf686a2191908c0b
|
|
| MD5 |
2bc1e83b3af5a2e001776b9ba6432031
|
|
| BLAKE2b-256 |
d0452de11390e569e8d72a026255ebbdaadef114bef2f7e5e26c59be7c37f519
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d521c210e8d1a201c35dbd660019dbbae72578468fca16b2cf686a2191908c0b - Sigstore transparency entry: 1074979598
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file megane-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: megane-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 656.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d8303df5fa831aec5ff80583ceb805843bbfc096395d83bc39ffd4f2eae1a30
|
|
| MD5 |
0191d7e346cd6d12ebad3384762d482f
|
|
| BLAKE2b-256 |
d98d31be77b9d9866bd273d85b3f82cc27a9c80a283151011ba5bf31d92bd041
|
Provenance
The following attestation bundles were made for megane-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on hodakamori/megane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megane-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
8d8303df5fa831aec5ff80583ceb805843bbfc096395d83bc39ffd4f2eae1a30 - Sigstore transparency entry: 1074979399
- Sigstore integration time:
-
Permalink:
hodakamori/megane@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/hodakamori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@775799a6ab97c8a8d0d2237115c5f1d67a2589aa -
Trigger Event:
push
-
Statement type: