Skip to main content

A fast, beautiful molecular viewer

Project description

megane

Desktop-grade molecular visualization. Right in your browser.

CI PyPI npm License

Docs · Getting Started · PyPI · npm

megane screenshot


Features

  • 1M+ atoms at 60fps — Billboard impostor rendering with WebGL handles massive protein complexes in real time
  • Jupyter, CLI, React — Use as a Jupyter widget, serve from the command line, or embed the React component in your own app
  • Rust + WASM — PDB, GRO, XYZ, MOL, and XTC parsers in Rust, shared between Python (PyO3) and browser (WASM)
  • Trajectory streaming — Stream XTC trajectories over WebSocket in real time, scrub through thousands of frames
  • Atom selection & measurement — Select 2–4 atoms to measure distances, angles, or dihedral angles
  • Adaptive rendering — High-quality InstancedMesh for small systems, auto-switches to Billboard Impostor for large systems

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

megane-0.1.1.tar.gz (266.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

megane-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (538.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

megane-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (537.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

megane-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (538.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

megane-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (537.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

megane-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

megane-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (539.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

megane-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

megane-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (539.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

File details

Details for the file megane-0.1.1.tar.gz.

File metadata

  • Download URL: megane-0.1.1.tar.gz
  • Upload date:
  • Size: 266.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for megane-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aec9e538ff397a3c09e677d465a749ae50cc119a74f8ab28594e7b173ce7f4aa
MD5 72b28ae018528835817d44ed7a69e343
BLAKE2b-256 585f02402b6794cb7c0edf5520a5f0726b4576cb61389795bc41ffd260d3b1dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1.tar.gz:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 466b5f7d881ff9bc4b759643bb5547039505cfd9dfc451675538cf3ba5ec19bd
MD5 17d5d088743065fddd2aeb8f2e4bfc90
BLAKE2b-256 e5ea6624b5517bc14b21496057445745295d6a005f30468176e34f640053cc67

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5df2d7775ebeaed656ee7e9ef9304de4e32ba551e1797af5fb11a42fdd348f33
MD5 75e81102427d7df5dd9febe884b08ce3
BLAKE2b-256 1e018b9b366065c1e5d47086bf9c12f9271f5152024157c87675e56bff20feda

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 69606b58fd4df292d5d4486ef7032b6a1986d2e4b4293c312f97385e227a3acd
MD5 78f0c802aa50dcb4522cfe6be9d45db7
BLAKE2b-256 7a2ec6c1555667c5bce4058b687c0a92214daa2110cf91a8a9c4bae66911ed78

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ad31586503279e0718e901c7d0a928c23d3a64f36f33ed9a133f75d40eaea5d5
MD5 23c95baf16bb95771b52cd60072c4a9b
BLAKE2b-256 a0ea2bfe3e652c0f6713027fd15bbd52d8b05e5bddcb923331c8563359831c14

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee67b87d79b4b9ccc5265b9376e25e8f57e766633f67d79eb97802b39be5f426
MD5 f51e7871632fd5eedd90c4e7f2fb5b0b
BLAKE2b-256 23fddec83844fe54c47698297fa7285e31229043762543bffa858d5363ee592d

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 279a3b099a6ae27fae7dd2df09e1c360b2a671ea6ac2294b552ceb401f190e07
MD5 4679d2a8a788780a66e3c984732d3a66
BLAKE2b-256 a84b9209a4dd152153be4d1667fa801b5b609b4d47279904b87f73897624d588

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b03d73944e943e8ef4e92a664b5182f33735f10e39152259a60d98270e47c7f7
MD5 54ba29df22a45f776c53e964ce2c9b68
BLAKE2b-256 5a1575e8b32d40fdf8ba86f45f06c08ff0caee7310e30d97bd3a96d6eba422ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file megane-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7c0e918dca2b01bfaed949fad86a0e56184a414311785868f1c99bb446401fa
MD5 8afb917c51745aedf2fa4ac80c951399
BLAKE2b-256 a164ec21464d65b5f5796855bf3bcf82d3b9b77297655930f7643984a68f4579

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on hodakamori/megane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page