SynDOKU
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": [
{"id": "C#C", "formula": "C2H2", "smiles": "C#C"},
{"id": "[H][H]", "formula": "H2", "smiles": "[H][H]"},
{"id": "C=C", "formula": "C2H4", "smiles": "C=C"},
{"id": "[H]C#N", "formula": "CHN", "smiles": "[H]C#N"},
{"id": "CCC#N", "formula": "C3H5N", "smiles": "CCC#N"},
{"id": "O", "formula": "H2O", "smiles": "O"},
{"id": "CCC(=O)N", "formula": "C3H7NO", "smiles": "CCC(=O)N"}
],
"rules": []
}
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).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syndoku-0.2.0.tar.gz.
File metadata
- Download URL: syndoku-0.2.0.tar.gz
- Upload date:
- Size: 221.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de6d1742ba80e2cbc3c65d7770f5d8102ae4d07f7472b2db6eec98f986e10139
|
|
| MD5 |
ad407ef0a3c615e467c3b7f02762d194
|
|
| BLAKE2b-256 |
0acaf586bcb39632a96190ef504e71ae4c8d1aebbbd138a2d7ec38a7d83688f7
|
Provenance
The following attestation bundles were made for syndoku-0.2.0.tar.gz:
Publisher:
publish-package.yml on tuyetminhphan/SynDOKU
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syndoku-0.2.0.tar.gz -
Subject digest:
de6d1742ba80e2cbc3c65d7770f5d8102ae4d07f7472b2db6eec98f986e10139 - Sigstore transparency entry: 2291310668
- Sigstore integration time:
-
Permalink:
tuyetminhphan/SynDOKU@cd128f997db3ca75cd06fa61d3fe0a120129e0ce -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tuyetminhphan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@cd128f997db3ca75cd06fa61d3fe0a120129e0ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file syndoku-0.2.0-py3-none-any.whl.
File metadata
- Download URL: syndoku-0.2.0-py3-none-any.whl
- Upload date:
- Size: 257.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b681fabf9e6aaa4ccd681564b6f632d42e6102790f747c1f1e3843d920b8e13c
|
|
| MD5 |
3962902c15df62cad6c94b9313dbb0ed
|
|
| BLAKE2b-256 |
b2a009a999d21e1b2dc2e64b9d9786da8a878ece4178972451aebb3f6f364b06
|
Provenance
The following attestation bundles were made for syndoku-0.2.0-py3-none-any.whl:
Publisher:
publish-package.yml on tuyetminhphan/SynDOKU
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syndoku-0.2.0-py3-none-any.whl -
Subject digest:
b681fabf9e6aaa4ccd681564b6f632d42e6102790f747c1f1e3843d920b8e13c - Sigstore transparency entry: 2291310689
- Sigstore integration time:
-
Permalink:
tuyetminhphan/SynDOKU@cd128f997db3ca75cd06fa61d3fe0a120129e0ce -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tuyetminhphan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@cd128f997db3ca75cd06fa61d3fe0a120129e0ce -
Trigger Event:
release
-
Statement type: