Skip to main content

MolGFX

Documentation

MolGFX is a semantic molecular-rendering library for Python, Rust, and WebGPU. It renders structures supplied by MolFrame as interactive browser scenes or deterministic native images. MolGFX does not parse, fetch, dock, simulate, or open an application window.

MolGFX haemoglobin cartoon, heme, and local pocket

Install

python -m pip install --upgrade molgfx

Render a structure

import molframe
import molgfx

# Infer bonds so atom-and-bond representations have sticks to draw.
structure = molframe.read("structure.cif").infer_bonds()
scene = molgfx.Scene(structure)
scene.add(molgfx.rep.cartoon(target=molgfx.sel.protein(), color=molgfx.color.chain()))
scene.add(molgfx.rep.ball_and_stick(target=molgfx.sel.ligands()))

molgfx.Renderer().render_image(scene, size=(1920, 1080)).save("structure.png")

Targets are MolFrame queries, and a small command language works around them through molgfx.Session:

show cartoon, protein
select pocket, byres (within 5 of resname HEM) and protein
show licorice, $pocket
color orange, $pocket

The Rust engine opens no window and owns no application panels. This repository also supplies the official browser host: a canvas, navigation and semantic picks, not a Workbench, console, toolbar or file picker. Session remains the sole command and undo/redo authority. Python notebooks use this same frontend through AnyWidget, a normal package dependency.

session = molgfx.Session(structure)
session.execute("show cartoon, protein")
viewer = molgfx.Viewer(session)
viewer  # Display in Jupyter.

Browser SDK

npm install molgfx
import { Viewer } from "molgfx";
import "molgfx/viewer.css";

const viewer = await Viewer.create(document.getElementById("scene")!);
await viewer.load(await fetch("structure.cif").then(r => r.arrayBuffer()), { name: "structure.cif" });
viewer.execute("show cartoon, protein");
// On host teardown:
await viewer.dispose();

The one npm package exports molgfx, molgfx/viewer, molgfx/anywidget and molgfx/react. The React adapter owns viewer mount/dispose, not molecular state. Public TypeScript declarations never expose the raw wasm ABI.

"use client";
import { MolGFXViewer } from "molgfx/react";
import "molgfx/viewer.css";

export function Protein({ bytes }: { bytes: Uint8Array }) {
  return <MolGFXViewer structure={bytes} name="protein.cif"
    style={{ width: "100%", height: 480 }}
    onError={error => console.error(error.message)} />;
}

Keep the input byte object stable between unchanged React renders. The adapter reuses its Viewer for structure updates and disposes it on unmount; it does not duplicate Scene, Session or rendering semantics.

Shared frontend build

nix develop -c npm ci --prefix web
nix develop -c npm run build --prefix web
nix develop -c npm test --prefix web
nix develop -c npm pack ./web --pack-destination web

web/scripts/build.mjs runs wasm-pack into ignored web/generated, then emits the official package into ignored web/dist and copies identical artifacts to Python static assets. The documentation site imports the public npm package; Next.js emits its WASM asset rather than loading a private runtime directory. A content-hash manifest and archive-level checks prove that npm tarballs and Python wheels carry identical runtime bytes. Build before running maturin from a source checkout; PyPI source distributions include the prebuilt runtime and need Python >=3.12, Rust and dependency fetching, but no Node, wasm-pack or adjacent MolFrame checkout. Cargo, Python and npm versions must match. Native wheel builds repair external libraries; release gates rebuild the source archive and exercise fresh installed wheels before publication.

Python and npm have separate release workflows. Published versions are immutable; release 0.4.1 supersedes the existing PyPI 0.4.0 package. npm trusted publishing requires the package owner to authorize this repository and release workflow. Until the first registry publication, the docs use the public package through a local npm dependency, exercising the same exports and bundler asset resolution.

Writing queries and commands walks through both, and the MolFrame query reference lists every keyword.

Status

Beta. Public APIs are available through the molgfx facade; MolFrame provides structure input and molecular selection semantics.

License

MIT

Metadata

Release files for molgfx 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for molgfx 0.4.2
File Size Uploaded Provenance
molgfx-0.4.2.tar.gz 4.1 MB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for molgfx 0.4.2
File
molgfx-0.4.2-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
molgfx-0.4.2-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details
molgfx-0.4.2-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details
molgfx-0.4.2-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
molgfx-0.4.2-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 76.0 MB

Release files / molgfx-0.4.2.tar.gz

Download URL molgfx-0.4.2.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
d889812b708b441d68a4dc82487d0ce12c2f557dcf204f512bf380524a8d2c2c
BLAKE2b-256 checksum
How to use checksums
91ed51d5938d4802211f562f683766f682bb017993c85ee26ae8051219babe4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / molgfx-0.4.2-cp312-abi3-win_amd64.whl

Download URL molgfx-0.4.2-cp312-abi3-win_amd64.whl
Size 22.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5cb29b2593c05e7094d294a77a736ec62219cf4e1b4523e5e21617e125aa5734
BLAKE2b-256 checksum
How to use checksums
c4c24e786c045ac4c773681c8d1566bc2abc40127a6b5652abfa06358cb76c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / molgfx-0.4.2-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL molgfx-0.4.2-cp312-abi3-manylinux_2_28_x86_64.whl
Size 13.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
485dade95971b1ea27f0da3ee111d5239a0359a7219f6364bd7783365c17ef6f
BLAKE2b-256 checksum
How to use checksums
3bded4e7aa59599a5a08df5ae8a3b0158fabea0ffb5a825e1df041f2976eaf04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / molgfx-0.4.2-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL molgfx-0.4.2-cp312-abi3-manylinux_2_28_aarch64.whl
Size 12.6 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5de1ed6256ab62cf4c7e6387d51b4ce22af9884bc6cea0d29db1448fc8df486f
BLAKE2b-256 checksum
How to use checksums
347cc8a48a83a9183665c7c3bfd0878253cc0b79ef3438d5f20a6ec5022f5fa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / molgfx-0.4.2-cp312-abi3-macosx_11_0_arm64.whl

Download URL molgfx-0.4.2-cp312-abi3-macosx_11_0_arm64.whl
Size 11.7 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d302dffeda3d823f50488527ce76c75c57ba727607e5f07bbd09ba01c64e0ee2
BLAKE2b-256 checksum
How to use checksums
f46618408f5784a028455c2a127754043ed8549592e7f00a027578f705df3312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / molgfx-0.4.2-cp312-abi3-macosx_10_12_x86_64.whl

Download URL molgfx-0.4.2-cp312-abi3-macosx_10_12_x86_64.whl
Size 12.4 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d434bad1ecb635563f93d83ae8ea18a111737c5bf8c630c279d9d3e4cb24f565
BLAKE2b-256 checksum
How to use checksums
ed444a4352f6625670163c118d2592100e14b8fbe8b3a95ebddccf23a1d4e936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Security for molgfx 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for molgfx-0.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page