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.7.3.tar.gz (59.4 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.7.3-cp314-cp314-macosx_11_0_arm64.whl (653.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

molex-0.7.3-cp312-cp312-win_amd64.whl (548.4 kB view details)

Uploaded CPython 3.12Windows x86-64

molex-0.7.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (735.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

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

File metadata

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

File hashes

Hashes for molex-0.7.3.tar.gz
Algorithm Hash digest
SHA256 a0f4605ee5db9d7a4d48c8a4ccbc16025c545e00aaef719e64caba3f1b921c69
MD5 d990aed9069c059c95db725fa2514a91
BLAKE2b-256 526ed0df590ad85c4745437798515ba4ee7234d21e3c5ce7b3c8eaf7febee68e

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.7.3.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.7.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for molex-0.7.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5d292992b5b4cb5962e7b8cbf3b15cefec2cabf572d16c1fd56ecc4d5250576
MD5 dd8c8b8d9f4bc98c0a5caa60a346f8ea
BLAKE2b-256 ffb38822adceff24af68d5f2b343a964df74a2f729dd34545c0661a37ef0998c

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.7.3-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.7.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: molex-0.7.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 548.4 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.7.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 72e8ac6c66031929890ff5da466db1d346ad088664e717709723a73fb1b337ef
MD5 246985dcb37ddc1395b8996e8b8f600f
BLAKE2b-256 97742a606c7493d27e53607b1d64cd9298ec66c79f1e22ed5ec8ae0334e25350

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.7.3-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.7.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for molex-0.7.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86bd385337b1e1442fba910423cdfe0a48863b4fabf48a11f5214a7e197b633e
MD5 e0ad6355c8397e1bdf8836b089b9f61b
BLAKE2b-256 cfaec832da54873e0ce993c54e461ede82e018e315f450c6b36bf26ff03a6edf

See more details on using hashes here.

Provenance

The following attestation bundles were made for molex-0.7.3-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