import numpy as np
from ase.io import read
import mofography as mgr
atoms = read("examples/TestCIFs/P1-IRMOF-1.cif")
dgrid = mgr.dgrid_from_atoms_rust(atoms, spacing=0.5).astype(np.float32)
seg = mgr.do_periodic_segmentation_rust(
dgrid, atoms, spacing=0.5, mask_thickness=0.05, h=0.2,
min_distance=1.5, threshold_abs=1.5,
watershed_backend="rust_det", compute_connections=True, disable_tqdm=True,
)
print(len(seg["maxima_pbc"]), "pockets")Install
This repository is the full Python package. There is no PyPI wheel yet: you install dependencies, compile mgr_rust with maturin in release mode (important for speed on your CPU), then pip install -e ..
Requirements: Python 3.10–3.12 (3.11 recommended) · Rust via rustup · Linux, macOS, or Windows. NumPy 1.20 and the 2.x series are both supported; if you hit a deprecation or type-promotion warning, open an issue with your numpy version.
Pin a release (optional)
git clone https://github.com/mofography/mofography.git && cd mofography
git checkout 2026.10.09.1One command (Linux / macOS)
A. Fresh sandbox with uv (creates .venv in the clone):
curl -fsSL https://raw.githubusercontent.com/mofography/mofography/master/scripts/install_mofography.sh | bash -s -- --mode uv-sandboxB. Active conda or venv (installs into the Python you already activated):
curl -fsSL https://raw.githubusercontent.com/mofography/mofography/master/scripts/install_mofography.sh | bash -s -- --mode pip-existingPin a release in the one-liner:
curl -fsSL https://raw.githubusercontent.com/mofography/mofography/master/scripts/install_mofography.sh | bash -s -- --mode uv-sandbox --ref 2026.10.09.1From an existing clone: ./scripts/install_mofography.sh --mode uv-sandbox, or --mode pip-existing --repo-dir .
Windows (PowerShell)
git clone https://github.com/mofography/mofography.git
cd mofography
git checkout 2026.10.09.1 # optional
.\scripts\install_mofography.ps1Further Windows details live in the README.
Manual steps (any OS)
conda create -n mgr_env python=3.11 -y && conda activate mgr_env # or your venv
conda install -c conda-forge pymatgen ase dask networkx scikit-image scikit-learn plotly freud rdkit -y
git clone https://github.com/mofography/mofography.git && cd mofography
python -m pip install maturin
cd mgr_rust && maturin develop --release && cd ..
python -m pip install -e .mamba can replace conda for faster solves. With pip, the freud package is named freud-analysis.
Verify
python -c "import mgr_rust, mofography as m; print(m.__version__)"After git pull
Rebuild the Rust extension:
cd mgr_rust && maturin develop --releaseWe do not ship prebuilt mgr_rust wheels per OS: local --release builds match your machine best. More on the backend: Rust backend notes.
Quick test
Run the two core calls on a CIF from the repo (the full walkthrough is Quick start):
Next
- Quick start: CIF to pore graph and textural properties
- CLI quick start: the same from the terminal
- Learn: all tutorials