Skip to main content

Endpoint-conditioned electron-flow mechanism search

Project description

SynEltra

SynEltra

A framework for electron-flow mechanism generation from atom-mapped reaction SMILES.

SynEltra builds imaginary transition-state (ITS) graphs from mapped reactions, enumerates electron-pushing trajectories via beam search, ranks them by electronic scoring, and renders them as Nature-style arrow-pushing figures.


Installation

conda env create -f env.yaml
conda activate syneltra-env
pip install -e .

Requirements: Python ≥ 3.11, SynKit ≥ 1.3.2, RDKit, NetworkX, NumPy, Matplotlib.


Quick Start

One-line trajectory search

from syneltra import rsmi_to_trajs

rsmi = "[CH3:1][Br:2].[OH-:3]>>[CH3:1][OH:3].[Br-:2]"

trajs = rsmi_to_trajs(rsmi)          # sorted best-first
best  = trajs[0]                     # top-ranked mechanism

graphs      = best.graphs()          # RC-context graphs per step (list[nx.Graph])
graphs_full = best.graphs(full=True) # full molecular graphs
transitions = best.transitions       # list[Transition] — arrow sequence

print(f"Found {len(trajs)} trajectories, {len(transitions)} steps in best")
for i, t in enumerate(transitions):
    print(f"  [{i+1}] {t.kind}  {t.src}{t.dst}")

rsmi_to_trajs parameters

Parameter Default Description
rsmi Atom-mapped reaction SMILES (reactants>>products)
family None "polar", "pericyclic", or "radical". Auto-inferred when None.
k 0 Context-expansion radius for the workspace builder
max_depth 20 Maximum arrow-step depth for beam search
beam_width 64 Beam width; wider = more diverse trajectories, higher cost
max_results 20 Max trajectories returned before ranking
electronic_mode "fmo-hsab-resonance" Electronic scoring mode ("consensus", etc.)

Visualization

import matplotlib.pyplot as plt
from syneltra import rsmi_to_trajs, rsmi_to_reaction_bundle
from syneltra.visualization import MechanismVisualizer

rsmi   = "[CH3:1][Br:2].[OH-:3]>>[CH3:1][OH:3].[Br-:2]"
bundle = rsmi_to_reaction_bundle(rsmi)
trajs  = rsmi_to_trajs(rsmi)
best   = trajs[0]
viz    = MechanismVisualizer()

Reactant + ITS panel (default)

fig = viz.visualize_trajectory(
    reactant_graph=bundle.reactant_graph,
    transitions=best.transitions,
    its_graph=bundle.its,
    product_graph=bundle.product_graph,
    title="SN2: MeBr + OH⁻",
)
plt.show()

Step-by-step elementary panels

fig = viz.visualize_trajectory(
    reactant_graph=bundle.reactant_graph,
    transitions=best.transitions,
    its_graph=bundle.its,
    all_graphs=best.graphs(full=True),  # required for this mode
    product_graph=bundle.product_graph,
    title="SN2: step-by-step",
    show_elementary_steps=True,
    arrows_per_step=1,
)
plt.show()

Iterate over all ranked trajectories

for i, traj in enumerate(trajs):
    fig = viz.visualize_trajectory(
        reactant_graph=bundle.reactant_graph,
        transitions=traj.transitions,
        its_graph=bundle.its,
        product_graph=bundle.product_graph,
        title=f"Trajectory {i+1}/{len(trajs)}",
        fade_non_rc=True,
        use_rc_glow=True,
    )
    plt.show()

Key visualize_trajectory options

Parameter Default Description
fade_non_rc False Fade non-reaction-centre bonds
use_rc_glow True Soft halo around changed bonds
show_elementary_steps False One panel per arrow group
arrows_per_step 2 Arrows per panel (elementary mode)
show_atom_map True Show atom-map badges
step_labels True Label individual arrows
gap 3.0 Horizontal spacing between panels

Low-level API

from syneltra import (
    rsmi_to_reaction_graphs,   # → (reactant_graph, product_graph)
    rsmi_to_its,               # → ITS nx.Graph
    rsmi_to_reaction_bundle,   # → ReactionGraphBundle
    build_endpoint_states_from_its,
    MechanismEnumerator,
    ITSPlanner,
)

# Build graphs manually
r_graph, p_graph = rsmi_to_reaction_graphs(rsmi)

# Enumerate without ranking
from syneltra import MechanismEnumerator, rsmi_to_its
its = rsmi_to_its(rsmi)
trajs = MechanismEnumerator().enumerate_from_its(its, max_depth=10, beam_width=32)

Supported reaction families

Family Vocabulary Notes
polar LP-/B+, B-/LP+, B-/B+ Ionic / heterolytic; default fallback
pericyclic B-/B+ only Concerted bond-flow (Diels-Alder, sigmatropic, …)
radical above + B-/2R•, 2R•-/B+, R•/B-/B+, R•-/H-/R•+ Homolytic / chain processes

Project structure

syneltra/
├── chemistry/      # IO, ITS construction, endpoint states
├── constraints/    # Arrow-plan validity constraints
├── core/           # Config, models (Trajectory, StateSnapshot, …)
├── mechanism/      # Operators, planner, vocabulary, pruner
├── ranker/         # Trajectory ranking by electronic score
├── scoring/        # FMO, HSAB, resonance scoring functions
├── search/         # Beam-search enumerator
└── visualization/  # MechanismVisualizer, arrow rendering

Contributing

Publication

SYnEltra:

License

This project is licensed under MIT License - see the License file for details.

Acknowledgments

This project has received funding from the European Unions Horizon Europe Doctoral Network programme under the Marie-Skłodowska-Curie grant agreement No 101072930 (TACsy -- Training Alliance for Computational)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syneltra-0.1.0b1.tar.gz (189.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syneltra-0.1.0b1-py3-none-any.whl (217.4 kB view details)

Uploaded Python 3

File details

Details for the file syneltra-0.1.0b1.tar.gz.

File metadata

  • Download URL: syneltra-0.1.0b1.tar.gz
  • Upload date:
  • Size: 189.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for syneltra-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 69e875b9fb9ca870f219062059d0047dfc1a0371f22a268c5fca98f6ca195d5b
MD5 af9479da243de336b815c1bbfb068481
BLAKE2b-256 a00a2739853452a2979622917638e3e7f2e5dce3522bb335833a64c6b986a00c

See more details on using hashes here.

Provenance

The following attestation bundles were made for syneltra-0.1.0b1.tar.gz:

Publisher: publish-package.yml on TieuLongPhan/SynEltra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file syneltra-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: syneltra-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 217.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for syneltra-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 e537cdb4c9bb80b962abb56de059901faaf29144a64e45739e2731777b8b8f8a
MD5 60e1ebf9564cdf8d5d8196e0487ba0bb
BLAKE2b-256 a29e7cc3971b1c4ff7cd1f766bea51524b25b1b4f5b7c7f5c02ebe6844ae941d

See more details on using hashes here.

Provenance

The following attestation bundles were made for syneltra-0.1.0b1-py3-none-any.whl:

Publisher: publish-package.yml on TieuLongPhan/SynEltra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page