Skip to main content

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–102× 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.3×. 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 with their shared core aligned and atoms and bonds highlighted as removed, added, or changed

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 time 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, or time limit 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(time_limit_s=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(time_limit_s=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
time_limit_s 60.0 Wall-clock limit measured from the start of the call --timeout
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

Work budgets make the stopping point reproducible, provided the wall-clock limit does not intervene. Clock-limited results depend on machine speed and load. The time limit is not a hard process deadline: parsing, stereo perception, and result assembly are not interrupted. The optional global check described below has its own additional budget.

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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for atommapper 0.1.0
File Size Uploaded Provenance Actions
atommapper-0.1.0.tar.gz 68.7 kB With provenance Details for atommapper-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for atommapper 0.1.0
File Actions
atommapper-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for atommapper-0.1.0-cp311-abi3-win_amd64.whl
atommapper-0.1.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.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
atommapper-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for atommapper-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
atommapper-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for atommapper-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
atommapper-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for atommapper-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 1.6 MB

Release files / atommapper-0.1.0.tar.gz

Download URL atommapper-0.1.0.tar.gz
Size 68.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f2b8c0ba813747afbbdc37a7c0ede61efd3822e04bffc59c0ec8fb4b9e0c75ec
BLAKE2b-256 checksum
How to use checksums
35d3b3d70e4a56b1dafb60fa497b991559399cef0af2f52a5eb7550087342015
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 17, 2026.

Transparency log

Release files / atommapper-0.1.0-cp311-abi3-win_amd64.whl

Download URL atommapper-0.1.0-cp311-abi3-win_amd64.whl
Size 221.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
64ba2c9e3f0759d873aec147b18136f196e9cd4d87fa93d903771df4edba8fa8
BLAKE2b-256 checksum
How to use checksums
ffc167d1e219330b66566df0b18da816488dc29556b33fe404ba986126d19380
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 17, 2026.

Transparency log

Release files / atommapper-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL atommapper-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 326.2 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0196c800d8629df479dca541ea9846495f5e9d224599e3d6bfce0623afdf4cb6
BLAKE2b-256 checksum
How to use checksums
6aff6ef328a85fdd16f872f047e8e8547fd00f0a0ad8e1d6ac666258da2d7ee2
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 17, 2026.

Transparency log

Release files / atommapper-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL atommapper-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 322.0 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
eb462d5fbd460279773b3b898d5c8dc5d485e2d62382efaa1558eab65348f9c7
BLAKE2b-256 checksum
How to use checksums
6fed0e2982cae8315c2f99448797c967e85d9d9747233732dd6ec6cee10baf6e
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 17, 2026.

Transparency log

Release files / atommapper-0.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL atommapper-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 301.5 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ea64186f9c5477f218f57e7a705cd104fe73ca6fdd24abe255063da912f5f57a
BLAKE2b-256 checksum
How to use checksums
fb174b2435fc6654c8ab049a5646aa54bdd4d41b6e2f18aaa50512f97bac1bcc
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 17, 2026.

Transparency log

Release files / atommapper-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL atommapper-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 314.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3663baee201588aec0960aa9d058871b29b68e07a29e0baf8c164966835456a8
BLAKE2b-256 checksum
How to use checksums
483b9887904004c749e7a735231eea9fd7cf517ff6d46f059032bfd2d8b0e53d
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 17, 2026.

Transparency log

Security for atommapper 0.1.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.

Select from 6 files

Attestation for atommapper-0.1.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 17, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page