Fast, open RMSD_n packing comparisons for molecular crystals.
Try it in your browser: https://oxtal.github.io/oxtalign/. Compare two structures or score a batch of predictions without installing anything; files stay on your device.
RMSD_n is the standard similarity metric in crystal structure prediction (CSP), as implemented in CCDC's COMPACK (Chisholm & Motherwell, J. Appl. Cryst. 38, 228–231, 2005): take a molecule in crystal A with its n − 1 nearest neighbours, and search for a rigid motion that superimposes that shell onto crystal B. The comparison yields two numbers: how many of the n molecules land within 1 Å of a counterpart, and RMSD_n, the root-mean-square atomic deviation over the molecules that do.
OXtalign is a fast, open Python implementation (gemmi + numpy + scipy) from the team behind OXtal. Why use it:
- 🎯 Agreement with COMPACK. Among 2,000 CSD comparisons, when both methods find full matches, their RMSD₁₅ values agree to within 0.005 Å on average. Full-match decisions agree on 99% of curated polymorph comparisons and 88% of random CSD comparisons.
- ⚡ Fast. Per comparison on one core: 3.4 ms median, 5.0 ms mean (6.4 ms and 8.1 ms including reading CIFs), against COMPACK's 69 ms and 2.0 s. That is a 20× speed-up on a typical pair, and ~400× over a batch of 2,000 pairs, because COMPACK times out on hard ones. 11,200 comparisons per second on 64 cores, and the median cost grows linearly with shell size.
- 🔁 Deterministic. No distance or angle tolerances, no timeouts, no random seeds. The same inputs give the same numbers on any machine or worker count.
- 📦 Any input. Experimental CIFs (symmetry, disorder, Z′ > 1, solvates, salts, organometallics), predicted clusters without a unit cell, PDB and XYZ files, in-memory arrays, ASE and pymatgen objects. No preprocessing needed.
- 🧩 Easy to use.
pip install oxtalign, then a function call. Apache-2.0 licence.
pip install oxtalign # latest release (PyPI)
pip install git+https://github.com/OXtal/oxtalign # latest development version (GitHub main)Needs Python ≥ 3.10; the only runtime dependencies are gemmi, numpy and scipy. To work on the code itself,
clone the repo and run uv sync --extra dev.
oxtalign compare formI.cif formII.cif # RMSD_15 = 0.0925 Å matched 15/15 status: full
oxtalign compare formI.cif formII.cif --profile # coverage at tol = 1, 2, 3 Å: how much packing is shared
oxtalign overlay formI.cif formII.cif -o overlay.html --pdb overlay.pdbfrom oxtalign import compare
res = compare("formI.cif", "formII.cif", n=15)
res.rmsd_n, res.n_matched, res.status # 0.0925, 15, "full" (status: full | partial | failed)
res.rmsd_1, res.inverted, res.transform # conformer RMSD, mirror-image flag, 4x4 overlay B -> A
res.rmsd_capped, res.bond_preserving # continuous whole-shell score; whether atoms were matched along bondsstatus is full when all n molecules overlay within the per-molecule tolerance (default 1 Å), partial
when at least half do, and failed otherwise. This is the match definition used in the OXtal paper. The two
structures must be the same compound unless --allow-partial is set. Every command takes the same comparison
options (table below).
Example: are two determinations the same polymorph? compare gives the numbers COMPACK would: 15 of 15
molecules within ~0.1–0.3 Å means the same packing.
Visualisation. oxtalign overlay writes a self-contained interactive HTML page: drag to rotate, scroll
to zoom, toggle A / B / matched-only, with matched molecules in green and unit cells drawn. Add --pdb to
also get the overlay as a two-chain PDB for Mercury, ChimeraX or VESTA (chain A = reference shell, chain B =
overlaid, B-factor = each molecule's RMSD).
Details.
- Hydrogens are dropped;
--include-hydrogenskeeps them. - Disorder sites with occupancy below 0.5 are dropped.
oxtalign.io_cif.read(..., disorder="dominant")selects the dominant configuration from_atom_site_disorder_groupinstead. - Already-expanded P1 cells, Z′ > 1, co-crystals, salts and bare molecular clusters work out of the box.
- OXtalign matches each atom to the same atom in the other structure by following the molecule's bonds.
- The comparison looks for A's n-molecule cluster inside B. For a partial match, swapping A and B can change
the count slightly;
--symmetrictries both and keeps the better one. - Mirror-image packings do not match by default, as in COMPACK. To compare the enantiomorphic packings of an
achiral molecule, use
--inversion(allow_inversion=True). --allow-partialtolerates two determinations that perceive slightly different heavy-atom counts (disorder drift), or a shared cation with a different counter-ion.- Polymeric systems are out of scope.
oxtalign score preds/ --truth truths/ --jobs 32 --csv scores.csv # which predictions hit an experimental form
oxtalign dedup landscape/*.cif --threshold 0.25 --jobs 32 --csv clusters.csv # distinct packings in a landscape
oxtalign matrix *.cif --jobs 32 --csv matrix.csv # all-pairs RMSD_15score maps predictions to truths by refcode prefix (CAPRYL_seed3.cif ↔ CAPRYL.cif, CAPRYL01.cif, …)
and reports the usual CSP-evaluation columns: whether the prediction passed (at least half the shell matched
and no steric clash), the matched count, the RMSD and the best-matching reference. dedup groups structures
whose full shells overlay below a threshold and names a representative per group. To rank predictions that
only partly match, sort by rmsd_capped, which changes smoothly where the matched count jumps.
from oxtalign import compare, from_arrays, from_ase, from_pdb, from_pymatgen, from_xyz, load
from oxtalign.batch import distance_matrix, score_predictions
s = from_arrays(elements, frac_coords, cell=(a, b, c, alpha, beta, gamma)) # or a 3x3 lattice; symops=...
c = from_arrays(elements, xyz, bonds=bonds) # a cluster without a cell
p = from_pdb("form.pdb") # CRYST1 expands the asymmetric unit; no CRYST1 -> cluster
x = from_xyz("form.xyz") # extended-XYZ Lattice="..." if present, else a cluster
compare(s, from_ase(atoms), n=15) # ASE / pymatgen: no import needed
M, results, structures = distance_matrix(paths, n=15, n_jobs=32) # inf where no match
rows = score_predictions("preds/", {"CAPRYL": ["CAPRYL.cif"]}, n_jobs=32)If a structure is so noisy that molecules clash, or it has unusual bond lengths, tell OXtalign where the molecules are:
load("pred.cif", bonds="file") # bonds from the CIF's own _geom_bond list
from_arrays(elements, frac, cell=lattice, bonds=pairs) # bonds as (i, j) pairs
compare("pred.cif", "truth.cif", reassemble=True) # work the molecules out from the other structure
score_predictions("preds/", truth_map, reassemble=True) # the same for a batch; adds an `assembly` columnMolecular clusters without a cell (Cartesian mmCIF with _chem_comp_bond, as OXtal writes them) are
compared exactly like periodic cells. Every comparison is independent, so n_jobs scales across processes.
On a dedicated node, pin_cores=True / --pin-cores binds one worker per physical core.
| Python | CLI | default | meaning |
|---|---|---|---|
n |
--n |
15 | molecules in the coordination shell |
mol_rmsd_tol |
--tol |
1.0 Å | a molecule counts as matched below this overlay RMSD |
search |
--search |
standard |
exhaustive searches harder for an incomplete match (below) |
allow_inversion |
--inversion |
off | also match the mirror image (enantiomorph); inverted reports it |
topology |
--topology |
auto |
match atoms by following the bonds, falling back to matching by position if bonds differ (strict and ignore also exist; see the method document) |
symmetric |
--symmetric |
off | compare in both directions and keep the better result (twice the cost, usually not required) |
bonds |
--bonds |
auto |
file: molecules from the file's bond list; perceive: always perceive |
reassemble |
--reassemble |
off | re-assemble a side whose molecules cannot be delimited, guided by the other (compare, score) |
include_hydrogens |
--include-hydrogens |
off | heavy atoms only by default |
allow_partial |
--allow-partial |
off | tolerate small atom-count / counter-ion differences |
Which search to use. search="standard" (the default) is right for almost everything: comparing
polymorphs, removing duplicates, screening predictions. It stops as soon as it finds a complete, tight match.
search="exhaustive" keeps looking when the first attempt does not match every molecule: it tries more
starting orientations and more choices of central molecule. It is typically 1.5–4× slower. Turn it on when
- the crystal has more than one molecule in the asymmetric unit (Z′ > 1);
- you want to rank structures that match only partly (e.g. 9 of 15 against 12 of 15):
standardcan undercount; - you got "no match" for a pair you expected to match, and want to be sure.
Clashing molecules. If molecules sit so close that atoms of neighbouring molecules are within bonding
distance, OXtalign cannot tell where one molecule ends and the next begins, and no search setting helps. Tell it
the bonds instead: --bonds file reads them from the CIF, and --reassemble works them out from the other
structure of the pair.
All numbers were measured on one machine (AMD EPYC 9654, Linux, Python 3.12, one BLAS thread per process) with the
scripts in benchmark/, which also draw the figures. The OXtalign runs set every option
explicitly: shell n = 15, 1 Å per-molecule tolerance, heavy atoms, bonds perceived, search="standard", and
inversion allowed (it is off by default) because COMPACK was run that way.
COMPACK was run as CCDC's PackingSimilarity with the usual CSP-evaluation settings: shell 15, 50% distance and
75° angle tolerances, hydrogens and bond counts ignored, inversion allowed, 20 s timeout. The CIFs are CSD
entries, so neither they nor COMPACK's outputs are distributed; rerunning the benchmarks needs a CSD licence.
COMPACK is proprietary CCDC software, run here under our own CSD licence, and OXtalign is an independent
implementation that is not affiliated with or endorsed by CCDC.
Agreement with COMPACK. 2,000 polymorph comparisons: 163 from seven curated polymorph families (ROY, galunisertib, ritonavir, …) and 1,837 from random CSD refcode families. Where both engines match all 15 molecules (1,255 comparisons), RMSD₁₅ differs by 0.005 Å on average. The full-match decision is the same for 99% of the curated and 88% of the random comparisons. A disagreement can be a miss by either engine: OXtalign fully matches 116 comparisons that COMPACK does not, COMPACK 110 that OXtalign does not, and COMPACK returned an error or timed out on 9 curated and 118 random comparisons.
Speed. On one core, over the 2,000 pairs with both CIFs read afresh each time (so nothing is cached), a comparison takes 3.4 ms at the median and 5.0 ms on average. Reading and assembling the two CIFs adds 2.7 ms at the median; reading is 6.7× faster than in 0.1.0. In a batch each structure is read only once, so there is further speed-up. COMPACK takes 69 ms at the median and 2.0 s on average, because of its tail of 20 s timeouts: 20× slower on a typical pair, and 67 min against 9.9 s (~400×) for the whole set. Across processes, OXtalign reaches 11,200 comparisons/s on 64 workers. COMPACK parallelises too, but from a much higher per-comparison cost: 24.6 comparisons/s on 64 workers, 457× fewer.
Shell size. On 200 pairs (half matched by COMPACK at n = 15, half not), OXtalign's median cost grows linearly with the shell, 2.4 ms + 0.05 ms × n (R² 0.99 for n = 1 to 150; 9.8 ms at n = 150). COMPACK is about as fast for a single molecule. From two molecules on, OXtalign pulls ahead, by 24× at n = 15 (143× on the mean) and ~800× at n = 30, as COMPACK's distance-graph search grows combinatorially and starts failing (19 of 200 comparisons at n = 30). The two engines give the same full-match decision on 86–92% of comparisons at every n.
Beyond experimental CIFs. Left: 30 predicted CAPRYL clusters (no unit cell) compared all-against-all; near-identical clusters show up as diagonal blocks. Middle and right: crystals with every molecule perturbed by a set amount. RMSD₁₅ tracks the perturbation while it is small; past ~0.8 Å the packing is no longer recognised as the same one, as expected.
Both structures are first assembled into whole molecules: symmetry is expanded, and bonds are worked out from interatomic distances or read from the file. OXtalign then takes one molecule of A with its n − 1 nearest neighbours, tries many ways of laying that cluster onto B, and refines each one by repeatedly re-pairing the molecules and re-fitting the rigid motion. The overlay with the most matched molecules wins; among equals, the one with the lowest RMSD. The method is deterministic. Method has the details and limitations; that document was drafted almost entirely by an LLM.
src/oxtalign/ io_cif · io_arrays · assemble · cluster · matching/ · compare · batch · overlay · cli
tests/ pytest suite; CSD fixtures are listed by refcode, not shipped (tests/data/README.md)
benchmark/ scripts behind the numbers and figures above (benchmark/README.md)
web/ the browser app (web/README.md)
docs/ METHOD.md and the figures above
Apache License 2.0 (see LICENSE). If you use OXtalign, please cite OXtal and this software:
@inproceedings{jin2026oxtal,
title = {{OXtal}: An All-Atom Diffusion Model for Organic Crystal Structure Prediction},
author = {Jin, Emily and Nica, Andrei Cristian and Galkin, Mikhail and Rector-Brooks, Jarrid and
Lee, Kin Long Kelvin and Miret, Santiago and Arnold, Frances H. and Bronstein, Michael and
Bose, Avishek Joey and Tong, Alexander and Liu, Cheng-Hao},
booktitle = {International Conference on Learning Representations (ICLR)},
year = {2026},
url = {https://arxiv.org/abs/2512.06987}
}
@software{oxtalign2026,
title = {{OXtalign}: fast, open RMSD$_n$ packing similarity for molecular crystals},
author = {Liu, Cheng-Hao},
year = {2026},
url = {https://github.com/OXtal/oxtalign},
version = {0.2.0}
}



