Skip to main content

molex

Molecular exchange: a Rust library for parsing, transforming, analyzing, and serializing molecular structure data, with Python and C bindings.

Features

  • Parse PDB, mmCIF, BinaryCIF, MRC/CCP4 density maps, and DCD trajectories
  • Entity model: proteins, nucleic acids, ligands, ions, waters, and other small molecules as typed entities under a single Assembly
  • Analyze: DSSP secondary structure, hydrogen bonds, covalent bonds, disulfide bridges, SASA, contacts
  • Transform: Kabsch alignment and superposition RMSD, heavy-atom completion, all-atom projection, structured edits and deltas
  • Crystallography (xtal): maximum-likelihood refinement from structure factors: density synthesis, bulk-solvent masking, anisotropic scaling, sigma-A estimation, and B-factor refinement, with an optional GPU backend
  • Serialize: a compact binary wire format for FFI and IPC
  • Bindings: a PyO3 Python module (Biotite-free numpy interchange) and a C ABI static library (libmolex.a) for embedding in native hosts

Quick start (Rust)

use std::path::Path;
use molex::Assembly;

let assembly = Assembly::from_file(Path::new("1ubq.pdb"))?;
for e in assembly.entities() {
    println!("{:?}: {} atoms", e.molecule_type(), e.atom_count());
}

Assembly::from_file reads PDB or mmCIF by extension; from_pdb / from_mmcif / from_bcif take the source as a string, each with a _with(..., Completion) variant. Heavy-atom completion runs at parse time (default Completion::Heavy). Reach atoms through assembly.entities(), and write back with assembly.to_pdb().

Python

pip install molex

The Python API is object-centric: parse into an Assembly, walk its entities and residues, and read atoms as numpy columns.

import molex

asm = molex.Assembly.from_pdb(open("1ubq.pdb").read())
for e in asm.entities():
    print(e.kind, e.chain_id, e.residue_count)

asm.recompute_ss()   # opt-in DSSP secondary structure

# Biotite-free per-atom numpy columns via PyAtomTable:
table = molex.PyAtomTable.from_assembly_bytes(asm.to_assembly_bytes())
coords = table.coords          # (N, 3) float32
mol_types = table.mol_types    # AtomWorks-style vocabulary columns

from_mmcif / from_bcif parse the other formats. PyAtomTable exposes plain numpy columns (coords, atom/residue names, elements, b-factors, occupancies, chain/residue ids, and AtomWorks-style vocabulary) with no Biotite dependency. Type stubs (molex.pyi) ship with the wheel. Crystallographic refinement is available through molex.PyExperimentalData (from_sf_cif, compute_density, refine_b_factors).

C API

With the c-api feature, molex builds a static library (libmolex.a) plus a cbindgen-generated header (include/molex.h) exposing an opaque-handle C ABI: parse PDB/mmCIF/BinaryCIF into an Assembly, walk entities/residues/atoms, apply edits, and (with xtal) drive crystallographic refinement. This is the interface native hosts embed molex through.

Optional features

Feature Enables
(default) Pure-Rust core: parsing, entity model, analysis, wire format
serde Serialize / Deserialize on the core types
specta TypeScript type-export derives
python PyO3 bindings + numpy interchange
extension-module Build the Python extension as a loadable wheel (with maturin)
c-api C ABI, libmolex.a, and the generated include/molex.h
xtal Crystallographic refinement pipeline (density, scaling, sigma-A, FFT)
minimization B-factor refinement (argmin), on top of xtal
gpu GPU density/refinement backend (cubecl + wgpu), on top of xtal
testutil Crystallographic test fixtures for external bench/integration crates

Documentation

License

MIT

Metadata

Release files for molex 0.8.1

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

Source distribution (sdist)

Source distribution for molex 0.8.1
File Size Uploaded Provenance Actions
molex-0.8.1.tar.gz 1.0 MB With provenance Details for molex-0.8.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for molex 0.8.1
File Interpreter ABI Platform Actions
molex-0.8.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for molex-0.8.1-cp39-abi3-win_amd64.whl
molex-0.8.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for molex-0.8.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
molex-0.8.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for molex-0.8.1-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 3.0 MB

Release files / molex-0.8.1.tar.gz

Download URL molex-0.8.1.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
17a0db3cf9a209a20ac19b5ba0196f103d00eab84d5833b58a535b872f00137d
BLAKE2b-256 checksum
How to use checksums
be8053df2d98d3c029fc869672dc8b8c78765fec329af60c347485a94719f1ab
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 Sep 17, 2026.

Transparency log

Release files / molex-0.8.1-cp39-abi3-win_amd64.whl

Download URL molex-0.8.1-cp39-abi3-win_amd64.whl
Size 568.1 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ac51c430ea2676258f2cb36c0de197ad6abcd9fc1091096b0678add659d72db7
BLAKE2b-256 checksum
How to use checksums
bee40070dc0ac238644113d85eafa5c2082f8b1acfcba2b3ac1de8f3abf9ac1f
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 Sep 17, 2026.

Transparency log

Release files / molex-0.8.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL molex-0.8.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 745.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
08edd95cea2cae46122dceb70ea8e1d66b2389bfd2f723d95631d2888ba0d783
BLAKE2b-256 checksum
How to use checksums
ee4ab3bef5ff5489736e58051bac365f58b64a715a7709317af91bdd0e5ae369
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 Sep 17, 2026.

Transparency log

Release files / molex-0.8.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL molex-0.8.1-cp39-abi3-macosx_11_0_arm64.whl
Size 671.7 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
033ca0a6f4fd6021190e1ff4c21888323a3b4d051b6f611244d5d76965835632
BLAKE2b-256 checksum
How to use checksums
dfa0f1d939aa0cde892ed3e314d2c8b339c30c38e3ba9f9e9647989d02f40fbf
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 Sep 17, 2026.

Transparency log

Security for molex 0.8.1

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 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for molex-0.8.1.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 Sep 17, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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