Skip to main content

Parse, analyze, and transform molecular structure data (PDB, mmCIF, BinaryCIF, MRC)

Project description

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

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

molex-0.8.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

molex-0.8.0-cp314-cp314-macosx_11_0_arm64.whl (652.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

molex-0.8.0-cp312-cp312-win_amd64.whl (549.9 kB view details)

Uploaded CPython 3.12Windows x86-64

molex-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (730.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file molex-0.8.0.tar.gz.

File metadata

  • Download URL: molex-0.8.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for molex-0.8.0.tar.gz
Algorithm Hash digest
SHA256 0b14f7d14f808eb9ba5eb0013406c41cd08c13adb8614e28670186be11edf313
MD5 7633e1bfbc63d513414ee66651ef6658
BLAKE2b-256 dae16a131171fee0313ee21df7f7f9834bcb463f3b65f45526fb1427f7fe3cfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.8.0.tar.gz:

Publisher: release.yml on foldit-org/molex

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

File details

Details for the file molex-0.8.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for molex-0.8.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a1f7e3bc276a17c34ea956f7ef96f8ee31344755dbb444b7a2da79db51bfd184
MD5 421e9ad65de994601fd9db010ddd78f8
BLAKE2b-256 ee4d6c31f724ca2c2b90d47cbd11df9a11266fa99da5486df26f31d285fdf16b

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.8.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on foldit-org/molex

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

File details

Details for the file molex-0.8.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: molex-0.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 549.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for molex-0.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6a3dfe2d3a3b9ad0eca26f8ebf06171d8d63ddb28d1007644713bd658bc05d28
MD5 2fe8681a6f6586e1ecf9bbcebb568866
BLAKE2b-256 7eb0e03f277321604211c78fce333dd4ddc4799c6b0eb812f27bc403c9a88c14

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.8.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on foldit-org/molex

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

File details

Details for the file molex-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for molex-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f183ce3d557aeca5c61ac5289059f40a55b30dd1dd11fdbbb7cf67b6e0ceb0e6
MD5 640a52311f8169fcf0488196ef7eef83
BLAKE2b-256 f5210db1a08884b0aa45a690c4915853b308de2639b1e68f81cc1ad085403a66

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on foldit-org/molex

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