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.4.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.7.4-cp314-cp314-macosx_11_0_arm64.whl (653.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

molex-0.7.4-cp312-cp312-win_amd64.whl (548.5 kB view details)

Uploaded CPython 3.12Windows x86-64

molex-0.7.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (728.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: molex-0.7.4.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.7.4.tar.gz
Algorithm Hash digest
SHA256 1a7caff19a1d9e976f7e4eee8d03e5e1f46c7be5ef673709e6b295440c457eb0
MD5 97fa09a3efd2c5bd919b989a4eba4aec
BLAKE2b-256 68a55e26770339f6650b34c5d191794ea74dd4f8fdf03fa32e68385b15e33407

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for molex-0.7.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6760dbce108649bfd5aa5c58b12663177a40a052a93f9b0d08f182743848debd
MD5 f773e83cc92e05cb18b8609c3e801edf
BLAKE2b-256 029e28f9aedb0a5c7c9cf1ee17c0fc79e887ccb22c5891abd42771620ad9ef03

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: molex-0.7.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 548.5 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 350d0f38c1c0fff3ae134c414a7234560809b33af562822b34786f9a461e6893
MD5 ae976d07b0979bd109083fee6cb32f1b
BLAKE2b-256 44d6a1d25124d42642b346e43264d3a170dcde408f153bedc17aa4044c0a45f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for molex-0.7.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 591055e67a3cc8c4a829e2fdb345fe3db5f7362413aa0295eb80b3773dc90609
MD5 786dd2106723c3df67b031b78024f17d
BLAKE2b-256 51ce967227cae75283b08c5be27b722bef8fed963348579d6b4b87bd9d938295

See more details on using hashes here.

Provenance

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