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

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";

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

megane-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (537.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

megane-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (536.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

megane-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (537.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

megane-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (536.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

megane-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

megane-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (538.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

megane-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

megane-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (539.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

File details

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

File metadata

File hashes

Hashes for megane-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63d01b1827368cc38881fbc8a0e193c3e5214919acf3bf3a55daabadc666d40f
MD5 9eb012eba53029bb76387bcd44f423f2
BLAKE2b-256 a0c643dc49d272478afdd01017644292520d73e0ff6ad2ad5a3cd93b4827cd9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1be8ba7a955d849b23aeb11d9de9a4b549ceca18f016fd2cb455d9745b5525ef
MD5 6eddc805f1b85f5efd146f7f76200d87
BLAKE2b-256 b675017b00c8dbac0172143d2e10d1dd9e186255aff42ac2f2f50a526a5be9ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d3a8b55535c3980f8949643b38d5d987d4616fb9f1e1f2f5fd36a379c4c6c925
MD5 e20f75ba39d332223dc485ca73057202
BLAKE2b-256 14feece576a760629a2456868197fb5cb1a51d9a6cf30e2b3f4e61a2db0bacec

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aad104de1d0ebd35c1731c73267fb8ce059466c94321fc4bf02936c56344c8b0
MD5 20f27e8fa9980090bcaeab7ffea010bf
BLAKE2b-256 a460e0b1bc61111d14973cc6170b4d79da00a1ca5441a0c6ca3c88e49c54d9e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1db70a2a692a3142716f73b3d2cdd82e1948d444cc117e2e51b1c599f12ef2c4
MD5 8766ea7d5206ffcb4a2c25178810d957
BLAKE2b-256 dd1abaec7a7181fe0ad3aed08fc0442081159a8a8c9a9411773990d662fcdc17

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e5a138a9dc69d44e1eda8e6a4e3c770283c60e2561ec59852742413d95e469b
MD5 3bc7bf8af58c2bd1e900a6b4f108e65a
BLAKE2b-256 dcff4c5047cf4c649a0fc3c13665d300336de10d75c8195d034c0119758e76da

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7530073fbed92245719e225e52cc37eb374234a7956d3bcdf8c196f99c34148f
MD5 df9cd881ab5042b2b0beeffb1ac055a6
BLAKE2b-256 da423a3e5e644e95059b88ef049f13297d4ae4ad7b0764fdc3d920623684f5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for megane-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c47e9524920b79f589993561896280095613589af6b331d0d06ac0aa8cda2f22
MD5 8533bc1a6c4dcd018ee9ad253a648ed8
BLAKE2b-256 9cb9bad084be306dd330798ae0312f890dc4fbd2b25e678d6729e0d0d768cb52

See more details on using hashes here.

Provenance

The following attestation bundles were made for megane-0.1.0-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