AtomMapper
Fast atom mapping for pairs of related molecules. AtomMapper identifies a shared core and reports which atoms and bonds are added, removed, or changed. It accepts SMILES strings or RDKit molecules and returns an atom correspondence, a mapped reaction SMILES, and a structured list of changes. No 3D coordinates are needed.
AtomMapper follows mapping constraints based on OpenFE's LOMAP: a connected core, complete rings, and preserved stereochemistry by default. Its search engine is written in Rust, with a Python API and command-line interface.
In the included benchmarks, AtomMapper used 17–101× less total mapping time than LOMAP's mapping step across 3,529 molecular pairs. Most of the gain comes from avoiding LOMAP's slowest searches; the median per-pair speedup was 1.1–2.2×. With the bond-maximizing objective, 95–98% of mappings agreed with LOMAP up to symmetry, excluding LOMAP timeouts. These measurements cover mapping, not similarity scoring or network planning. See the benchmark results and methodology.
Two EG5 ligands from the protein-ligand benchmark. The shared core is aligned; colors show removed, added, and changed atoms and bonds. AtomMapper can generate these drawings from either the command line or Python.
Installation
Requires Python 3.11 or later.
python -m pip install atommapper
Wheels are available for Linux (x86_64 and aarch64), macOS (Intel and Apple silicon), and Windows (x64). RDKit, NetworkX, and SciPy are installed as dependencies. If pip builds from source instead of installing a compatible wheel, you also need a Rust toolchain. For an editable checkout, see Development.
Quick start
Python
from atommapper import map_atoms
result = map_atoms("Cc1ccc(F)cc1", "Cc1cccc(F)c1")
print(result.status) # complete
print(result.metadata["size"]) # 4: one atom and one bond removed, one of each added
print(result.reaction_smiles)
# Zero-based atom indices: source atom -> target atom
atom_map = {atom.source_index: atom.target_index for atom in result.mapping}
Each entry in result.mapping connects a source atom to a target atom. A mapped atom
can change element by default; use element_change=False to require matching elements.
Atoms outside the mapping are reported in result.atom_changes, and bond changes in
result.bond_changes.
You can also pass RDKit Chem.Mol objects directly. The input molecules are copied,
not modified, and existing atom-map numbers are ignored. Returned indices refer to the
input molecules; for SMILES, they follow RDKit's parsing order with explicit hydrogens
retained. Ordinary explicit hydrogens are then merged into their attached atoms for the
search. Pass Chem.Mol objects when you need indices tied to molecules already in your
workflow.
Command line
atommapper "Cc1ccc(F)cc1" "Cc1cccc(F)c1"
[CH3:1][c:6]1[cH:2][cH:4][c:7]([F:8])[cH:5][cH:3]1>>[CH3:1][c:6]1[cH:2][cH:4][cH:7][c:5]([F:9])[cH:3]1
The same atom-map number on both sides identifies a mapped pair. A number on only one
side identifies a removed or added atom: here, fluorine 8 is removed and fluorine 9 is
added. These one-based identifiers are different from the zero-based input indices.
The source>>target notation describes the correspondence; it does not predict a chemical
reaction or mechanism.
# Full result, including status, atom indices, changes, and search metadata
atommapper "CCO" "CC=O" --json
# Save a drawing as well as printing the mapped SMILES
atommapper "Cc1ccc(F)cc1" "Cc1cccc(F)c1" --draw walk.svg --numbers
atommapper --help
Choosing a mapping
map_atoms(source, target, *, element_change=True, objective="change",
allow_stereo_inversion=False, settings=None)
| Option | Default behavior | Alternative |
|---|---|---|
objective |
"change": minimize the size of the change |
"bonds": maximize kept bonds, then kept atoms, then minimize change |
element_change |
True: mapped atoms may change element |
False / --fixed-elements: require matching elements |
allow_stereo_inversion |
False: reject mappings that invert a retained stereo element |
True / --allow-stereo-inversion: allow inversions and count each as one change |
settings |
Default search budgets and work limit | A Settings instance; see Search limits |
The change size counts each inserted or deleted atom or bond, each element change, and
each bond-order change as one. Allowed stereo inversions also count as one. Other
attribute changes, such as charge and hydrogen count, are reported but do not add to this
objective. Consequently, metadata["size"] is not the number of entries in the change
lists, nor a free-energy or chemical-similarity score.
For example, pyridine and benzene can keep all six ring atoms with element_change=True.
With element_change=False, they have no valid shared core because preserving the five
carbons alone would leave an incomplete ring.
Use objective="bonds" (--objective bonds) for a bond-maximizing comparison with LOMAP.
AtomMapper applies constraints during its search and uses stricter stereo checks, so
identical mappings are not guaranteed. It does not provide LOMAP's hydrogen mapping,
similarity scores, or network planner.
Drawings and notebooks
A MappingResult displays as an SVG drawing in notebooks. To save or render it explicitly:
from atommapper import draw_png, draw_svg, map_atoms, save_image
result = map_atoms("Cc1ccc(F)cc1", "Cc1cccc(F)c1")
svg = draw_svg(result, width=400, height=300) # SVG text
png = draw_png(result, numbers=True) # PNG bytes
save_image(result, "walk.svg") # .svg or .png selects the format
The source and target appear side by side with their shared atoms aligned. Each panel is
400 × 300 pixels by default, with a legend below. Set width and height in Python or
--size 400x300 on the command line to change the panel size.
Removed atoms and bonds are vermillion, additions are blue, and changes are yellow.
Hydrogen-count changes are omitted from the highlights. Stereo inversions carry R/S or
E/Z labels; preserving double-bond geometry can require moving some mapped atoms out of
alignment. numbers=True (--numbers) labels mapped atoms with their identifiers.
Working with results
map_atoms returns a MappingResult:
| Field | Meaning |
|---|---|
reaction_smiles |
Mapped source>>target SMILES; mapped atoms are numbered first, then source-only and target-only atoms |
mapping |
Tuple of MappedAtom(identifier, source_index, target_index, tag) records |
atom_changes, bond_changes |
Changes keyed by the identifiers in reaction_smiles |
status, reason |
Search outcome and an explanation when applicable |
metadata |
Change size, kept counts, optimality, stereo verdicts, checks, budgets, timings, settings, and dependency versions |
The mapping tag is seed or refined, indicating how an atom entered the search; it is
not a confidence score. result.reverse() swaps the two sides and renumbers the result
without searching again. result.to_dict() returns the public fields as plain Python
data for serialization.
Check status before using a result in an automated workflow:
| Status | Meaning |
|---|---|
complete |
The configured search finished; global optimality is not guaranteed |
timed_out |
A work budget, size ceiling, the work limit, or the wall-clock guard stopped the search; the result is the best found so far |
no_common_vertices |
No atom can be mapped under the constraints; the mapping is empty |
unsupported_input |
A valid input cannot be represented faithfully; reason explains why, and no mapped SMILES is returned |
from atommapper import InvalidInput, Settings, map_atoms
try:
result = map_atoms("CCO", "CC=O", settings=Settings(work_limit=10.0))
except InvalidInput as error:
print(f"Invalid molecule: {error}")
else:
if result.status == "unsupported_input":
print(result.reason)
elif result.status == "timed_out":
print("Partial result:", result.metadata["budget"]["stopped_by"])
else:
print(result.reaction_smiles)
Invalid or empty molecules raise InvalidInput (a ValueError subclass). An unknown
objective raises ValueError; invalid Settings values raise TypeError or ValueError.
A charged hydrogen attached to a heavy atom is an example of an unsupported input.
The CLI exits with 0 for a completed search (including an empty mapping), 1 for
invalid or unsupported input, 2 for argument-parsing errors, and 3 for a search
stopped by a limit. A partial result is still printed; --accept-partial changes its exit
code to 0, but does not change the result's status.
Mapping constraints
- Connected core. Mapped atoms joined by retained bonds form one connected component. Atoms isolated on both sides, such as counterions, are exempt.
- Ring membership. Ring atoms map only to ring atoms; chain atoms only to chain atoms.
- Complete rings. Every retained ring atom and ring bond must lie on a cycle in the shared core. A benzene ring can map to one ring of naphthalene, but cyclohexane and cyclopentane cannot share a partial ring.
- Bonds between mapped atoms. Two mapped atoms bonded on either side must also be bonded on the other side. Bond orders may change, even with fixed elements.
- Stereochemistry. By default, a mapping cannot invert a retained tetrahedral centre
or double bond. The check uses the mapped neighbours, including attached hydrogens,
rather than simply comparing R/S labels. Stereo can still be gained or lost and is
reported in
metadata["stereo"]. - Hydrogens. Ordinary attached hydrogens are implicit; changes in their count are reported as atom attributes. This is intended for heavy-atom mapping, not a complete all-atom correspondence.
Ties favor fewer mapped atoms with changed heavy-atom neighbours, then the smaller moving group, then canonical order. These choices are designed to give consistent mappings when the inputs are reordered or reversed. All benchmark pairs agreed under reversal up to symmetry; timeouts and search caps can affect that behavior.
Search limits
from atommapper import Settings, map_atoms
result = map_atoms(
"Cc1ccc(F)cc1", "Cc1cccc(F)c1",
settings=Settings(work_limit=30.0, node_budget=2_000_000),
)
| Setting | Default | Purpose | CLI option |
|---|---|---|---|
fragment_steps |
20,000,000 | Total fragment-search work budget | --steps |
node_budget |
1,000,000 | Total branch-and-bound work budget | --nodes |
work_limit |
60.0 | Limit on the work of a call, in virtual seconds (about one wall second of the reference machine; see below), counted without reading a clock | --work-limit |
wall_guard_factor |
10.0 | Wall-clock guard, as a multiple of work_limit |
Python only |
fragment_bond_pairs |
20,000 | Ceiling on compatible bond pairs in the fragment search | --pairs |
coarse_fragment_steps |
100,000 | Work cap for the element-independent fragment pass | Python only |
The work budgets and the work limit make the stopping point reproducible. The work limit
is a virtual clock: each stage counts its work, and the clock advances by a fixed amount
per unit. The same calls therefore stop on every machine and under any load, with
work among the stop reasons, and a pair whose fragment-search set-up alone costs more
than the limit stops before the search. CPLEX's deterministic time limit and Gurobi's
WorkLimit are the same device.
The amounts per unit are a constant of the package, the reference clock
(atommapper.clock.REFERENCE_RATES): one virtual second is one second of the reference
machine, an AMD Ryzen Threadripper PRO 5975WX running eight calls at a time (with all 32
cores busy, the same calls took about 1.8 times as long). work_limit is the only knob.
Results made on two machines are comparable when it is the same; the name of the clock is
in Settings().reference_clock and in metadata["versions"]["clock"], so results cached
by their settings do not mix if a later version fits the rates again.
The wall clock remains as a guard, at wall_guard_factor times the limit in real seconds:
a call it stops reports time and does depend on machine speed and load. Neither clock is
a hard process deadline: parsing, stereo perception, and result assembly are not
interrupted. The optional global check described below has its own additional budget.
To see what a virtual second is worth on your machine, calibrate:
atommapper calibrate --wall-seconds 10 --workers 1
or atommapper.calibrate(10.0, workers=1) in Python. It maps a benchmark shipped with
the package (300 calls on synthetic molecules, about two minutes on one core of the
reference machine; benchmarks/make_calibration_pairs.py builds it), reports the wall
seconds per virtual second (median, 5th and 95th percentiles, per stage too; on the
reference machine its slow calls give 1.02 with eight calls at a time and 0.97 with one)
and suggests the work_limit that takes the wall time you asked for. Run it with the
number of workers the real work will use. Results are comparable across machines only at the same
work_limit: a calibrated limit gives up exact comparability with results made at
another limit.
Reaching the coarse-pass cap is part of the normal method and does not set timed_out;
inspect metadata["fragment_search"]["coarse_capped"]. The bond-pair ceiling protects
against large search graphs; increase it if stopped_by includes pairs.
Settings also exposes max_fragments, k_seeds, and max_alternatives for advanced
control of candidate storage and refinement. Restricting seeds or truncating candidates
can affect mapping quality and consistency under input reversal.
Optimality and limitations
A completed search is not a proof of the globally best mapping. AtomMapper starts
from shared connected fragments, trims them to the constraints, and grows mappings around
the remaining pieces using branch-and-bound. Each starting piece is held fixed, so the
usual result is metadata["optimality"] == "optimal_given_seed".
The seeds can miss a better mapping, sometimes by a large margin. For example,
NC1Cc2ccccc2CCC1=O to N[C@H]1CCc2ccccc2C[C@@H]1O with fixed elements gives a change
size of 21, although a size of 8 is possible. Extra seeds address common stereo-related
failures, but do not make the search globally exact. Increasing budgets alone may not
fix a poor choice of seeds.
Settings(global_budget_s=...) enables an optional exact lower-bound calculation after
the search, using unconstrained graph edit distance. If it finishes and matches the
mapping cost, optimality becomes optimal. Otherwise, it does not establish optimality.
This check can be expensive and is intended for small molecules and validation.
Development
Building from source requires Python 3.11+ and Rust:
git clone https://github.com/craabreu/atommapper.git
cd atommapper
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install -e ".[test,dev]"
make check # lint, types, Rust checks and tests, rebuild, Python tests
make format # format Python and Rust sources
The make commands require Make. To run only the Python tests after installation, use
python -m pytest -q. Benchmark dependencies and reproduction commands are documented
separately.
Please report bugs with a minimal pair of input molecules, the mapping options, and
result.metadata["versions"] on the
issue tracker.
License
AtomMapper is released under the MIT license.
Metadata
Release files for atommapper 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| atommapper-0.2.0.tar.gz | 90.9 kB | With provenance | Details for atommapper-0.2.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| atommapper-0.2.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details for atommapper-0.2.0-cp311-abi3-win_amd64.whl |
| atommapper-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details for atommapper-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| atommapper-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details for atommapper-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| atommapper-0.2.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for atommapper-0.2.0-cp311-abi3-macosx_11_0_arm64.whl |
| atommapper-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details for atommapper-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl |
Total release size: 1.7 MB
Release files / atommapper-0.2.0.tar.gz
| Download URL | atommapper-0.2.0.tar.gz |
|---|---|
| Size | 90.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f79fdb2693dc9b0cced0818db9a32cbdbfbf8e59e02a5fd1e558523c2eaa895
|
|
BLAKE2b-256 checksum How to use checksums |
7638b5a3e3e6e96c013106d7abcf0747c00183d98ca9c908af4b806a9cd84253
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / atommapper-0.2.0-cp311-abi3-win_amd64.whl
| Download URL | atommapper-0.2.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 245.7 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2ba3a41ee1d05a4a1d289b736c7dcf6dc420e60438cad602c0f76910f3f7306d
|
|
BLAKE2b-256 checksum How to use checksums |
74d9475114ab59b4d2be2109cb9b4d0d98228f83e98f19fa0b7ced6a7a9d381b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / atommapper-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | atommapper-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 350.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4aaf3e242470b229be147a75b0e828008df5ff63a6f786e806937dbcdabafdbd
|
|
BLAKE2b-256 checksum How to use checksums |
49ee456046320b7dfc25c86b99cb03235094561a1f6ec4645e4cbf1eebfc20c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / atommapper-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | atommapper-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 344.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
20cda01889d10b74449fae7c78c137d3eb015cc48f0d7385189c00c5d437a8d1
|
|
BLAKE2b-256 checksum How to use checksums |
adbc42ec5ea946bfef0ed8b71bccb87e85273abb934f09ca1b3bfee2d69efe3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / atommapper-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | atommapper-0.2.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 324.3 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2b33573f279e35c3170f772165b7e18a3c4314fa43f7a856f8601088c97c45b4
|
|
BLAKE2b-256 checksum How to use checksums |
5ebe688b15e71b482ce3672f94a59defc71c4f54d9f3dab97c19135838631dbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / atommapper-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | atommapper-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 337.4 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a4139b0e1f0e51c3b44512bfb026227144b16e96386c2634f18142bb1637266
|
|
BLAKE2b-256 checksum How to use checksums |
e44b7c5f8ded7b26a6089beff1acb75581583bbb5861ac099fa8d3ab95184695
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for atommapper 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for atommapper-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.