SLAPMapper Atom-to-atom Mapping
- class slapmapper.aam.aam.SlapAAM(binary=True)
Bases:
SlapMapperSequential LAP-based approximate mapper for a pair of labeled graphs.
The algorithm reduces the problem of matching two labeled graphs to a sequence of label refinement steps coupled with solving a series of linear assignment problems (LAPs). Labels are progressively refined using neighborhood information, and branching is introduced when multiple symmetrically distinct LAP solutions are available. Symmetry-breaking heuristics can be applied to choose a representative mapping among multiple symmetrically equivalent ones.
- Parameters:
binary (bool, optional (default=False)) – If True, all edge weights are converted to 0/1 prior to evaluation. This yields a purely structural matcher based only on adjacency.
- results
- List of matching results. Each dictionary contains:
"lgp": the pair of refined LabeledGraph objects"val": cumulative LAP cost, which coincides with the original graph matching cost when all symmetries are broken."lap_sols": LAP solutions for each label"cd": chemical distance computed from cumulative LAP cost"base": (if interactive) base index for user prompts"choices": (if interactive) record of the user-selected mapping, written in the index mapping string format"smiles": (if mapped from SMILES) mapped reaction SMILES"mapping": (if mapped from 3D structures) mapping in the index mapping string format
- Type:
list[dict]
- minval
Minimum cumulative LAP cost encountered.
- Type:
int
- binary
Whether binary edge processing is used.
- Type:
bool
- get_maps(lgp, break_sym_targets=None, interactive=False, base=None)
Almost the same as
SlapMapper.get_maps()but each element inself.resultsadditionally contains the chemical distance (‘cd’) value computed from the cumulative LAP cost (‘val’). Users may usemap_smiles()ormap_3d()methods instead of calling this method directly.
- map_smiles(rxn_smiles, add_Hs=True, break_sym='heavy', interactive=False)
Compute AAMs from a reaction SMILES string.
RDKit is used to convert the SMILES representation of a reaction into a pair of labeled graphs. SLAP-based matching is then applied, followed by optional symmetry-breaking.
- Parameters:
rxn_smiles (str) – Reaction SMILES string of the form
"A>>B". Partial mappings annotated using atom map numbers (e.g."[C:1]") are allowed for imposing constraints on the mapping.add_Hs (bool, optional (default=True)) – If True, explicit hydrogens are added before graph construction.
break_sym ({"heavy", "all"} or list[int], optional (default="heavy")) – Strategy for symmetry-breaking: -
"heavy": break symmetry only on non-hydrogen atoms -"all": break symmetry on all atoms - list[int] : explicit atom indices of the reactant graphinteractive (bool, optional (default=False)) – Enable interactive selection of symmetry-breaking choices.
Notes
Requires RDKit.
After mapping, each result dictionary contains:
r["smiles"] : str Reaction SMILES annotated with mapped atom indices.
- map_3d(files_react, files_prod, ase_read_kwargs={}, break_sym='heavy', constraints=None, base=0, bond_scale=1.2, interactive=False)
Compute AAMs from 3D molecular structures.
The input structures are read using ASE, converted into labeled graphs. SLAP-based matching is then applied, followed by optional symmetry-breaking.
- Parameters:
files_react (list[str] or str) – Filename(s) of the reactant structure(s).
files_prod (list[str] or str) – Filename(s) of the product structure(s).
ase_read_kwargs (dict, optional (default={})) – Keyword arguments forwarded to
ase.io.read.break_sym ({"heavy", "all"} or list[int], optional (default="heavy")) – Symmetry-breaking strategy (same as in
map_smiles()).constraints (str or None, optional (default=None)) – The index mapping string for imposing constraints on the mapping.
base (int or None , optional (default=0)) – Base index for atom numbering in
constraintsand interactive prompts.bond_scale (float, optional (default=1.2)) – Multiplier used when determining adjacency from interatomic distances based on covalent radii.
interactive (bool, optional (default=False)) – Enable interactive selection of symmetry-breaking choices.
Notes
Notes
Requires ASE.
After mapping, each result dictionary contains:
r["mapping"] : str Mapping in the index mapping string format.