Skip to main content

SynDOKU

PyPI version Conda version Docker Pulls Docker Image Version License Release Last Commit CI Documentation Status Dependency PRs Stars

SynDOKU addresses the constrained realizability of abstract reaction networks. Given an abstract network and a set of known molecules, it finds a bijection from abstract entities to molecules such that every assigned reaction is atom-balanced. The assignment may additionally be constrained by a prescribed set of graph-transformation rules.

This balanced-bijection problem is NP-complete. SynDOKU solves practical instances with a backtrack-and-prune algorithm inspired by the VF2 family of subgraph-isomorphism algorithms. Constraint propagation reduces candidate domains throughout the search, while chemical validation rejects assignments that violate atom balance or the allowed reaction rules.

Backtracking solver

Load one of the bundled problems and pass it to the backtracking solver:

from syndoku.models import ProblemJSON
from syndoku.validation.atom_balance import AtomBalance
from syndoku.solvers import make_solver

problem, _ = ProblemJSON.load(
    "data/toy_instances.json",
    example_id="ex_1",
)

solver = make_solver("bt", atom=AtomBalance())
result = solver.solve(problem, stop_at_first=True)
print(result.solutions)

The implementation is available as syndoku.solvers.backtrack.BacktrackSolver.

Run your own problem

Start in a notebook by defining the abstract reactions and supplying one candidate molecule for each abstract entity. The solver infers the entities from the reaction strings, then searches for a one-to-one assignment.

from syndoku.models import ProblemBuilder
from syndoku.solvers import make_solver
from syndoku.validation import AtomBalance

problem = ProblemBuilder.from_strings(
    reactions=[
        "A+B>>C",
        "C+D>>E",
        "E+F>>G",
    ],
    molecular_structures=[
        "C#C",
        "[H][H]",
        "C=C",
        "[H]C#N",
        "CCC#N",
        "O",
        "CCC(=O)N",
    ],
)

solver = make_solver("bt", atom=AtomBalance())
result = solver.solve(problem, stop_at_first=False)

print(f"{len(result.solutions)} solution(s) in {result.elapsed_sec:.3f} s")
for solution in result.solutions:
    print(solution)

If you have reaction templates, pass them to ProblemBuilder.from_strings through rules=... and construct the solver with temp=TemplateValidation() as well.

For command-line use, install the package and save the same problem as JSON. The syndoku command accepts this schema:

{
  "network": {
    "reactions": [
      "A+B>>C",
      "C+D>>E",
      "E+F>>G"
    ]
  },
  "molecules": [
    "C#C",
    "[H][H]",
    "C=C",
    "[H]C#N",
    "CCC#N",
    "O",
    "CCC(=O)N"
  ],
  "rules": []
}

For a plain SMILES list, SynDOKU derives each molecular formula and uses the canonical SMILES as its candidate ID. Formula-only records are also supported:

"molecules": ["C2H2", "H2", "C2H4"]

The explicit {"id": ..., "formula": ..., "smiles": ...} representation remains available when custom candidate IDs are needed. Do not mix plain SMILES and formula strings in one list.

Save this as prob.json, then run it from the repository root. By default, the command stops at the first valid assignment:

syndoku prob.json

Use --all-solutions to enumerate every assignment. A JSON file containing multiple examples additionally requires --example-id:

syndoku prob.json --all-solutions
syndoku data/toy_instances.json --example-id ex_9

The command automatically enables template validation when the JSON contains non-empty rules.

Benchmarks

Run the KEGG M00001 benchmark with:

python -m syndoku.benchmarks.kegg --configs B15

Run all NOG backtracking ablations (B0 through B16) on every seeded network with:

python -m syndoku.benchmarks.nog.run_ablation

The runner checkpoints to results/nog_ablation/ablation.csv and resumes by default. Use --configs, --sizes, or --seeds to run a subset.

Contributing

Publication

On the realizability of abstract reaction networks with real molecules and reactions

License

This project is licensed under the Apache License 2.0. See LICENSE for details.

Acknowledgments

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

Metadata

Release files for syndoku 0.3.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 syndoku 0.3.0
File Size Uploaded Provenance Actions
syndoku-0.3.0.tar.gz 221.1 kB With provenance Details for syndoku-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for syndoku 0.3.0
File Interpreter ABI Platform Actions
syndoku-0.3.0-py3-none-any.whl Python 3 none any Details for syndoku-0.3.0-py3-none-any.whl

Total release size: 478.5 kB

Release files / syndoku-0.3.0.tar.gz

Download URL syndoku-0.3.0.tar.gz
Size 221.1 kB
Tags Source
SHA-256 checksum
How to use checksums
da85f288f01bd8a8cf3d7ba6d210543d1279cb7ced3e834c85e2e719028ef4ed
BLAKE2b-256 checksum
How to use checksums
6191e687542de200ce926e408204627362fa6b7e5ad76537b9637b5daaa7397a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 3, 2026.

Transparency log

Release files / syndoku-0.3.0-py3-none-any.whl

Download URL syndoku-0.3.0-py3-none-any.whl
Size 257.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25cd443367140f5e40348c898e00f0e5857ec75df5ff495b188e04e922e6eaad
BLAKE2b-256 checksum
How to use checksums
ecce36da0523896d6fa997e0653d56014921bf542b13641d8cab46cfe507f03e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 3, 2026.

Transparency log

Security for syndoku 0.3.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for syndoku-0.3.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 Aug 3, 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.3.0 This release

2 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