synkit 1.6.5__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- synkit/CRN/Benchmark/__init__.py +53 -0
- synkit/CRN/Benchmark/crosschecks.py +13 -0
- synkit/CRN/Benchmark/kegg.py +12 -0
- synkit/CRN/Benchmark/networks.py +13 -0
- synkit/CRN/Benchmark/scaling.py +13 -0
- synkit/CRN/Benchmark/validate.py +13 -0
- synkit/CRN/Construct/__init__.py +16 -0
- synkit/CRN/Construct/abstract.py +668 -0
- synkit/CRN/Construct/arity.py +36 -0
- synkit/CRN/Construct/builder.py +619 -0
- synkit/CRN/Construct/derivation.py +63 -0
- synkit/CRN/Construct/flattener.py +100 -0
- synkit/CRN/Construct/keys.py +14 -0
- synkit/CRN/Construct/mixtures.py +117 -0
- synkit/CRN/Construct/rdkit_worker.py +69 -0
- synkit/CRN/Construct/smiles.py +99 -0
- synkit/CRN/Construct/state.py +31 -0
- synkit/CRN/Construct/strategy.py +75 -0
- synkit/CRN/Construct/worker.py +42 -0
- synkit/CRN/IO/__init__.py +36 -0
- synkit/CRN/IO/sbml.py +925 -0
- synkit/CRN/Pathway/__init__.py +72 -0
- synkit/CRN/Pathway/_adapter.py +333 -0
- synkit/CRN/Pathway/pathfinder.py +500 -0
- synkit/CRN/Pathway/reachability.py +796 -0
- synkit/CRN/Pathway/realizability.py +1322 -0
- synkit/CRN/Petrinet/__init__.py +93 -0
- synkit/CRN/Petrinet/analyzer.py +486 -0
- synkit/CRN/Petrinet/minimal_semiflows.py +436 -0
- synkit/CRN/Petrinet/net.py +1041 -0
- synkit/CRN/Petrinet/persistence.py +97 -0
- synkit/CRN/Petrinet/semiflows.py +483 -0
- synkit/CRN/Petrinet/siphon_search.py +402 -0
- synkit/CRN/Petrinet/structure.py +286 -0
- synkit/CRN/Props/__init__.py +130 -0
- synkit/CRN/Props/_rank.py +29 -0
- synkit/CRN/Props/deficiency.py +953 -0
- synkit/CRN/Props/dynamics.py +832 -0
- synkit/CRN/Props/helper.py +151 -0
- synkit/CRN/Props/stoich.py +751 -0
- synkit/CRN/Props/thermo.py +584 -0
- synkit/CRN/Query/__init__.py +66 -0
- synkit/CRN/Query/cache.py +41 -0
- synkit/CRN/Query/kegg_api.py +99 -0
- synkit/CRN/Query/kegg_extract.py +714 -0
- synkit/CRN/Query/kegg_impute.py +707 -0
- synkit/CRN/Query/kegg_parse.py +480 -0
- synkit/CRN/Query/to_syncrn.py +290 -0
- synkit/CRN/README.md +234 -0
- synkit/CRN/Structure/__init__.py +12 -0
- synkit/CRN/Structure/_graph_io.py +713 -0
- synkit/CRN/Structure/_matrices.py +88 -0
- synkit/CRN/Structure/_parse.py +544 -0
- synkit/CRN/Structure/reaction.py +237 -0
- synkit/CRN/Structure/rule.py +55 -0
- synkit/CRN/Structure/species.py +46 -0
- synkit/CRN/Structure/syncrn.py +929 -0
- synkit/CRN/Symmetry/__init__.py +20 -0
- synkit/CRN/Symmetry/_common.py +1059 -0
- synkit/CRN/Symmetry/_ir.py +940 -0
- synkit/CRN/Symmetry/automorphism.py +472 -0
- synkit/CRN/Symmetry/canon.py +441 -0
- synkit/CRN/Symmetry/isomorphism.py +412 -0
- synkit/CRN/Symmetry/symmetry.py +61 -0
- synkit/CRN/Symmetry/wl_canon.py +967 -0
- synkit/CRN/Visualize/__init__.py +11 -0
- synkit/CRN/Visualize/labels.py +113 -0
- synkit/CRN/Visualize/layout.py +708 -0
- synkit/CRN/Visualize/palette.py +292 -0
- synkit/CRN/Visualize/validation.py +122 -0
- synkit/CRN/Visualize/vis.py +1152 -0
- synkit/CRN/__init__.py +233 -0
- synkit/CRN/_build.py +50 -0
- synkit/CRN/_native_build.py +175 -0
- synkit/CRN/analysis.py +629 -0
- synkit/CRN/backend.py +74 -0
- synkit/CRN/cpp/CMakeLists.txt +58 -0
- synkit/CRN/cpp/algebra.cpp +46 -0
- synkit/CRN/cpp/closure.cpp +29 -0
- synkit/CRN/cpp/exact.h +55 -0
- synkit/CRN/cpp/pathway.cpp +46 -0
- synkit/CRN/cpp/semiflows.cpp +209 -0
- synkit/CRN/cpp/structural.cpp +240 -0
- synkit/CRN/cpp/symmetry.cpp +45 -0
- synkit/CRN/cpp/write_manifest.cmake +28 -0
- synkit/CRN/kinds.py +137 -0
- synkit/CRN/lib/synkit_crn.dll +0 -0
- synkit/CRN/lib/synkit_crn.json +33 -0
- synkit/CRN/native.py +388 -0
- synkit/CRN/native_analysis.py +459 -0
- synkit/Chem/Cluster/__init__.py +0 -0
- synkit/Chem/Cluster/butina.py +140 -0
- synkit/Chem/Fingerprint/__init__.py +0 -0
- synkit/Chem/Fingerprint/fp_calculator.py +155 -0
- synkit/Chem/Fingerprint/smiles_featurizer.py +258 -0
- synkit/Chem/Fingerprint/transformation_fp.py +139 -0
- synkit/Chem/Mapper/README.rst +43 -0
- synkit/Chem/Mapper/__init__.py +255 -0
- synkit/Chem/Mapper/_compat.py +130 -0
- synkit/Chem/Mapper/adapters/__init__.py +1 -0
- synkit/Chem/Mapper/adapters/prediction.py +126 -0
- synkit/Chem/Mapper/adapters/template.py +412 -0
- synkit/Chem/Mapper/chem/__init__.py +52 -0
- synkit/Chem/Mapper/chem/aam.py +673 -0
- synkit/Chem/Mapper/chem/blind.py +160 -0
- synkit/Chem/Mapper/chem/its.py +309 -0
- synkit/Chem/Mapper/chem/smiles.py +564 -0
- synkit/Chem/Mapper/graph/__init__.py +66 -0
- synkit/Chem/Mapper/graph/automorphism.py +395 -0
- synkit/Chem/Mapper/graph/blockcut.py +98 -0
- synkit/Chem/Mapper/graph/labeled_graph.py +104 -0
- synkit/Chem/Mapper/graph/refine.py +176 -0
- synkit/Chem/Mapper/graph/synkit_adapter.py +110 -0
- synkit/Chem/Mapper/io/__init__.py +13 -0
- synkit/Chem/Mapper/io/idxmapstr.py +82 -0
- synkit/Chem/Mapper/mapper.py +685 -0
- synkit/Chem/Mapper/reaction_search.py +554 -0
- synkit/Chem/Mapper/reporting/__init__.py +1 -0
- synkit/Chem/Mapper/reporting/alternatives.py +451 -0
- synkit/Chem/Mapper/reporting/analysis.py +681 -0
- synkit/Chem/Mapper/reporting/native_analysis.py +485 -0
- synkit/Chem/Mapper/reporting/spectrum.py +642 -0
- synkit/Chem/Mapper/solvers/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/__init__.py +141 -0
- synkit/Chem/Mapper/solvers/exact/assignment/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_certificate.py +113 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_domains.py +162 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_verification.py +58 -0
- synkit/Chem/Mapper/solvers/exact/assignment/incremental_assignment.py +247 -0
- synkit/Chem/Mapper/solvers/exact/certificate.py +128 -0
- synkit/Chem/Mapper/solvers/exact/core.py +183 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/bounds.py +319 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/exhaustive.py +179 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/inputs.py +283 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/records.py +242 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/search.py +1025 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/verify.py +378 -0
- synkit/Chem/Mapper/solvers/exact/edit_support.py +375 -0
- synkit/Chem/Mapper/solvers/exact/hybrid.py +224 -0
- synkit/Chem/Mapper/solvers/exact/hydrogen.py +264 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/branching.py +499 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/enumerate.py +1050 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/enumeration_result.py +30 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/kernel.py +256 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/milp.py +194 -0
- synkit/Chem/Mapper/solvers/exact/native/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/native/build.py +154 -0
- synkit/Chem/Mapper/solvers/exact/native/candidates.py +593 -0
- synkit/Chem/Mapper/solvers/exact/native/canonical.py +396 -0
- synkit/Chem/Mapper/solvers/exact/native/disk_frontier.py +415 -0
- synkit/Chem/Mapper/solvers/exact/native/frontier.py +390 -0
- synkit/Chem/Mapper/solvers/exact/native/hydrogen_quotient.py +213 -0
- synkit/Chem/Mapper/solvers/exact/native/its.py +528 -0
- synkit/Chem/Mapper/solvers/exact/native/native_distance.cpp +2803 -0
- synkit/Chem/Mapper/solvers/exact/native/orbit_aggregation.py +328 -0
- synkit/Chem/Mapper/solvers/exact/native/parallel.py +205 -0
- synkit/Chem/Mapper/solvers/exact/native/pmcd.py +203 -0
- synkit/Chem/Mapper/solvers/exact/native/runtime.py +40 -0
- synkit/Chem/Mapper/solvers/exact/native/search.py +294 -0
- synkit/Chem/Mapper/solvers/exact/native/separator.py +224 -0
- synkit/Chem/Mapper/solvers/exact/native_build.py +12 -0
- synkit/Chem/Mapper/solvers/exact/pabs/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/pabs/cost_lattice.py +43 -0
- synkit/Chem/Mapper/solvers/exact/pabs/factor_spectrum.py +110 -0
- synkit/Chem/Mapper/solvers/exact/pabs/multi_shell.py +368 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation.py +679 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_bounds.py +436 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_limits.py +13 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_search.py +856 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_symmetry.py +66 -0
- synkit/Chem/Mapper/solvers/exact/pabs/residual_typed_bonds.py +136 -0
- synkit/Chem/Mapper/solvers/exact/pabs/reward_frontier.py +201 -0
- synkit/Chem/Mapper/solvers/exact/pabs/separator_bound.py +258 -0
- synkit/Chem/Mapper/solvers/exact/pabs/separator_spectrum.py +308 -0
- synkit/Chem/Mapper/solvers/exact/pabs/sparse_reward_bound.py +207 -0
- synkit/Chem/Mapper/solvers/exact/pabs/suffix_spectrum.py +299 -0
- synkit/Chem/Mapper/solvers/exact/search.py +55 -0
- synkit/Chem/Mapper/solvers/exact/seeds/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed.py +104 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed_fragments.py +148 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed_relaxation.py +181 -0
- synkit/Chem/Mapper/solvers/exact/symmetry.py +223 -0
- synkit/Chem/Mapper/solvers/native/__init__.py +4 -0
- synkit/Chem/Mapper/solvers/native/assignment.py +99 -0
- synkit/Chem/Mapper/solvers/native/astar.py +22 -0
- synkit/Chem/Mapper/solvers/native/build.py +385 -0
- synkit/Chem/Mapper/solvers/native/classification.py +641 -0
- synkit/Chem/Mapper/solvers/native/core.py +378 -0
- synkit/Chem/Mapper/solvers/native/cpp/CMakeLists.txt +120 -0
- synkit/Chem/Mapper/solvers/native/cpp/examples/map_reaction.cpp +29 -0
- synkit/Chem/Mapper/solvers/native/cpp/examples/slap_graph.cpp +63 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/assignment/assignment.h +18 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/astar/astar.h +18 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/astar/bound.h +33 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/core/pmcd_witness.h +16 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/core/runtime.h +130 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/hydrogen/hydrogen.h +73 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/mapper.h +175 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/mces/mces.h +9 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/pabs/seed.h +34 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/reaction/reaction.h +30 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/sepdp/sepdp.h +21 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/slap.h +72 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/solvers/solvers.h +16 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/symmetry/classification.h +140 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/symmetry/cpabs.h +33 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/assignment/abb.cpp +302 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/CMakeLists.txt +12 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/README.md +47 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/astar.cpp +228 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/astar_graph.cpp +37 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/bound.cpp +212 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/core/dispatch.cpp +272 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/core/pmcd_witness.cpp +36 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/hydrogen/hydrogen.cpp +380 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/mces/README.md +57 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/mces/mces.cpp +287 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/bridge.cpp +334 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/chemical_floor.inc +181 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/endpoint_symmetry.inc +104 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/exact_helpers.h +20 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_assignment_certificate.h +165 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_certificate.h +125 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_model.h +365 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_provider.inc +319 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_rounding.inc +170 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_test_hooks.h +342 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/objective_reduction.inc +137 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/overlap_dual.inc +351 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/profile_seed.inc +214 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/seed_heuristics.inc +640 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/sparse_embedding.cpp +430 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/sparse_root_lp.h +176 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/test_hooks.inc +262 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/reaction/reaction.cpp +611 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/sepdp/README.md +61 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/sepdp/sepdp.cpp +253 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/slap.cpp +810 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/formulation.h +138 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/maxsat.cpp +526 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/ortools.cpp +475 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/seed.h +80 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/weighted_cnf.h +256 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/README.md +43 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/dfs.cpp +123 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/edit_support.cpp +224 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification.cpp +553 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification_pipeline.cpp +124 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification_stream.h +13 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/cpabs.cpp +455 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/edge_deck.cpp +743 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/COPYRIGHT +44 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/LICENSE-2.0.txt +202 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naugraph.c +732 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naurng.c +94 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naurng.h +49 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nausparse.c +1771 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nausparse.h +133 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nautil.c +750 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naututil.h +355 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nauty.c +1256 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nauty.h +1544 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/schreier.c +1131 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/schreier.h +70 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/sorttemplates.c +580 -0
- synkit/Chem/Mapper/solvers/native/hydrogen.py +711 -0
- synkit/Chem/Mapper/solvers/native/implicit.py +506 -0
- synkit/Chem/Mapper/solvers/native/implicit_certificate.py +187 -0
- synkit/Chem/Mapper/solvers/native/implicit_preparation.py +309 -0
- synkit/Chem/Mapper/solvers/native/lib/synkit_mapper.dll +0 -0
- synkit/Chem/Mapper/solvers/native/mces.py +16 -0
- synkit/Chem/Mapper/solvers/native/reaction.py +179 -0
- synkit/Chem/Mapper/solvers/native/reaction_build.py +277 -0
- synkit/Chem/Mapper/solvers/native/reaction_text.py +26 -0
- synkit/Chem/Mapper/solvers/native/runtime.py +242 -0
- synkit/Chem/Mapper/solvers/native/sepdp.py +47 -0
- synkit/Chem/Mapper/solvers/native/slap.py +266 -0
- synkit/Chem/Mapper/solvers/native/solvers.py +67 -0
- synkit/Chem/Mapper/solvers/native/stereo.py +86 -0
- synkit/Chem/Mapper/solvers/native/supporting.py +34 -0
- synkit/Chem/Mapper/solvers/native/symmetry.py +91 -0
- synkit/Chem/Mapper/solvers/slap/__init__.py +29 -0
- synkit/Chem/Mapper/solvers/slap/lap.py +174 -0
- synkit/Chem/Mapper/solvers/slap/sequential.py +696 -0
- synkit/Chem/Mapper/validation/__init__.py +1 -0
- synkit/Chem/Mapper/validation/aam_validator.py +442 -0
- synkit/Chem/Mapper/validation/annotations.py +274 -0
- synkit/Chem/Mapper/validation/bonds.py +124 -0
- synkit/Chem/Mapper/validation/cohorts.py +72 -0
- synkit/Chem/Mapper/validation/identifiability.py +150 -0
- synkit/Chem/Mapper/validation/numerical_scope.py +36 -0
- synkit/Chem/Mapper/validation/orbits.py +137 -0
- synkit/Chem/Molecule/__init__.py +0 -0
- synkit/Chem/Molecule/_chirality_loci.py +165 -0
- synkit/Chem/Molecule/_chirality_types.py +231 -0
- synkit/Chem/Molecule/_helical_loci.py +167 -0
- synkit/Chem/Molecule/_stereo_axis_evidence.py +202 -0
- synkit/Chem/Molecule/_stereo_element_detection.py +193 -0
- synkit/Chem/Molecule/_stereo_orientation_constraints.py +511 -0
- synkit/Chem/Molecule/_tetrahedral_carriers.py +63 -0
- synkit/Chem/Molecule/atom_features.py +379 -0
- synkit/Chem/Molecule/chirality.py +1041 -0
- synkit/Chem/Molecule/cip_assignment.py +569 -0
- synkit/Chem/Molecule/cip_ranking.py +843 -0
- synkit/Chem/Molecule/coordinate_stereo.py +503 -0
- synkit/Chem/Molecule/derived_stereo_naming.py +165 -0
- synkit/Chem/Molecule/descriptors.py +452 -0
- synkit/Chem/Molecule/formula.py +249 -0
- synkit/Chem/Molecule/global_stereo.py +175 -0
- synkit/Chem/Molecule/graph_annotator.py +300 -0
- synkit/Chem/Molecule/standardize.py +817 -0
- synkit/Chem/Molecule/stereo_evidence.py +179 -0
- synkit/Chem/Molecule/stereo_perception.py +1032 -0
- synkit/Chem/Molecule/valence.py +123 -0
- synkit/Chem/Reaction/Mapper/__init__.py +44 -0
- synkit/Chem/Reaction/__init__.py +20 -0
- synkit/Chem/Reaction/aam_validator.py +5 -0
- synkit/Chem/Reaction/balance_check.py +138 -0
- synkit/Chem/Reaction/canon_rsmi.py +249 -0
- synkit/Chem/Reaction/cleaning.py +58 -0
- synkit/Chem/Reaction/deionize.py +199 -0
- synkit/Chem/Reaction/explicit_h_audit.py +232 -0
- synkit/Chem/Reaction/fix_aam.py +64 -0
- synkit/Chem/Reaction/neutralize.py +207 -0
- synkit/Chem/Reaction/radical_wildcard.py +224 -0
- synkit/Chem/Reaction/standardize.py +203 -0
- synkit/Chem/Reaction/tautomerize.py +205 -0
- synkit/Chem/__init__.py +1 -0
- synkit/Chem/utils.py +315 -0
- synkit/Data/__init__.py +0 -0
- synkit/Data/aldol.json.gz +1 -0
- synkit/Data/gen_partial_aam.py +147 -0
- synkit/Data/paracetamol.json.gz +1 -0
- synkit/Graph/Canon/__init__.py +16 -0
- synkit/Graph/Canon/_native/__init__.py +13 -0
- synkit/Graph/Canon/_native/build.py +93 -0
- synkit/Graph/Canon/_native/lib/synkit_canon.dll +0 -0
- synkit/Graph/Canon/_native/prepare.py +49 -0
- synkit/Graph/Canon/_native/runtime.py +140 -0
- synkit/Graph/Canon/_native/search.py +137 -0
- synkit/Graph/Canon/canon_algs.py +228 -0
- synkit/Graph/Canon/canon_graph.py +531 -0
- synkit/Graph/Canon/cpp/CMakeLists.txt +42 -0
- synkit/Graph/Canon/cpp/README.md +123 -0
- synkit/Graph/Canon/cpp/examples/canonical_graph.cpp +16 -0
- synkit/Graph/Canon/cpp/include/synkit_canon/canon.h +85 -0
- synkit/Graph/Canon/cpp/src/canonical.cpp +391 -0
- synkit/Graph/Canon/cpp/src/symmetry.h +83 -0
- synkit/Graph/Canon/cpp/tests/symmetry.cpp +93 -0
- synkit/Graph/Canon/exact.py +1020 -0
- synkit/Graph/Canon/exact_refinement.py +368 -0
- synkit/Graph/Canon/nauty.py +143 -0
- synkit/Graph/Context/__init__.py +0 -0
- synkit/Graph/Context/hier_context.py +244 -0
- synkit/Graph/Context/radius_expand.py +252 -0
- synkit/Graph/FG/__init__.py +19 -0
- synkit/Graph/FG/api.py +39 -0
- synkit/Graph/FG/audit.py +155 -0
- synkit/Graph/FG/catalog.py +919 -0
- synkit/Graph/FG/detector.py +288 -0
- synkit/Graph/FG/model.py +97 -0
- synkit/Graph/FG/recognizers.py +274 -0
- synkit/Graph/FG/ring_system.py +154 -0
- synkit/Graph/Feature/Descriptors/topology.py +857 -0
- synkit/Graph/Feature/Fingerprint/__init__.py +0 -0
- synkit/Graph/Feature/Fingerprint/wl_rxn_fps.py +222 -0
- synkit/Graph/Feature/__init__.py +5 -0
- synkit/Graph/Feature/graph_descriptors.py +323 -0
- synkit/Graph/Feature/graph_fps.py +96 -0
- synkit/Graph/Feature/graph_signature.py +239 -0
- synkit/Graph/Feature/hash_fps.py +133 -0
- synkit/Graph/Feature/morgan_fps.py +88 -0
- synkit/Graph/Feature/path_fps.py +81 -0
- synkit/Graph/Feature/wl_hash.py +134 -0
- synkit/Graph/Fusion/__init__.py +85 -0
- synkit/Graph/Fusion/candidate.py +559 -0
- synkit/Graph/Fusion/constructor.py +877 -0
- synkit/Graph/Fusion/identity.py +184 -0
- synkit/Graph/Fusion/interface.py +700 -0
- synkit/Graph/Fusion/search.py +241 -0
- synkit/Graph/Hyrogen/__init__.py +6 -0
- synkit/Graph/Hyrogen/_misc.py +591 -0
- synkit/Graph/Hyrogen/hcomplete.py +995 -0
- synkit/Graph/Hyrogen/hcomplete_legacy.py +368 -0
- synkit/Graph/Hyrogen/hcompletion_algorithms.py +713 -0
- synkit/Graph/Hyrogen/hextend.py +570 -0
- synkit/Graph/Hyrogen/hextend_legacy.py +215 -0
- synkit/Graph/ITS/__init__.py +4 -0
- synkit/Graph/ITS/its_builder.py +120 -0
- synkit/Graph/ITS/its_construction.py +719 -0
- synkit/Graph/ITS/its_decompose.py +572 -0
- synkit/Graph/ITS/its_destruction.py +331 -0
- synkit/Graph/ITS/its_expand.py +1251 -0
- synkit/Graph/ITS/its_relabel.py +187 -0
- synkit/Graph/ITS/its_reverter.py +356 -0
- synkit/Graph/ITS/normalize_aam.py +145 -0
- synkit/Graph/ITS/partial_its.py +238 -0
- synkit/Graph/ITS/rc_extractor.py +656 -0
- synkit/Graph/ITS/stereo.py +74 -0
- synkit/Graph/MTG/__init__.py +107 -0
- synkit/Graph/MTG/gluing.py +451 -0
- synkit/Graph/MTG/history.py +928 -0
- synkit/Graph/MTG/inventory.py +118 -0
- synkit/Graph/MTG/local.py +447 -0
- synkit/Graph/MTG/mcs_matcher.py +246 -0
- synkit/Graph/MTG/mtg.py +611 -0
- synkit/Graph/MTG/mtg_explore.py +74 -0
- synkit/Graph/MTG/observation.py +209 -0
- synkit/Graph/MTG/process.py +577 -0
- synkit/Graph/MTG/queries.py +66 -0
- synkit/Graph/MTG/realization.py +95 -0
- synkit/Graph/MTG/series_parallel.py +107 -0
- synkit/Graph/MTG/utils.py +424 -0
- synkit/Graph/Matcher/__init__.py +10 -0
- synkit/Graph/Matcher/approx_mcs.py +1264 -0
- synkit/Graph/Matcher/auto_est.py +736 -0
- synkit/Graph/Matcher/automorphism.py +314 -0
- synkit/Graph/Matcher/batch_cluster.py +224 -0
- synkit/Graph/Matcher/dedup_matches.py +247 -0
- synkit/Graph/Matcher/graph_cluster.py +191 -0
- synkit/Graph/Matcher/graph_matcher.py +312 -0
- synkit/Graph/Matcher/graph_morphism.py +421 -0
- synkit/Graph/Matcher/mcs_matcher.py +804 -0
- synkit/Graph/Matcher/multi_turbo_iso.py +186 -0
- synkit/Graph/Matcher/orbit.py +284 -0
- synkit/Graph/Matcher/partial_matcher.py +694 -0
- synkit/Graph/Matcher/sing.py +544 -0
- synkit/Graph/Matcher/subgraph_matcher.py +812 -0
- synkit/Graph/Matcher/turbo_iso.py +272 -0
- synkit/Graph/Matcher/wl_sel.py +537 -0
- synkit/Graph/Mech/__init__.py +26 -0
- synkit/Graph/Mech/conversion.py +1466 -0
- synkit/Graph/Mech/conversion_debug.py +237 -0
- synkit/Graph/Mech/electron_accounting.py +200 -0
- synkit/Graph/Mech/lwg_editor.py +406 -0
- synkit/Graph/Mech/lwg_ops.py +313 -0
- synkit/Graph/Morphism/__init__.py +99 -0
- synkit/Graph/Morphism/constraints.py +460 -0
- synkit/Graph/Morphism/llg.py +999 -0
- synkit/Graph/Morphism/morphism.py +349 -0
- synkit/Graph/Morphism/stereo.py +258 -0
- synkit/Graph/Morphism/stereo_morphism.py +383 -0
- synkit/Graph/Morphism/stereo_morphism_helpers.py +957 -0
- synkit/Graph/Morphism/stereo_morphism_types.py +117 -0
- synkit/Graph/Stereo/__init__.py +376 -0
- synkit/Graph/Stereo/_descriptor_core.py +207 -0
- synkit/Graph/Stereo/_descriptor_serialization.py +138 -0
- synkit/Graph/Stereo/canonical.py +648 -0
- synkit/Graph/Stereo/changes.py +964 -0
- synkit/Graph/Stereo/composition.py +391 -0
- synkit/Graph/Stereo/configured.py +946 -0
- synkit/Graph/Stereo/couplings.py +245 -0
- synkit/Graph/Stereo/descriptors.py +1030 -0
- synkit/Graph/Stereo/enumeration.py +597 -0
- synkit/Graph/Stereo/extended_descriptors.py +406 -0
- synkit/Graph/Stereo/global_configured.py +152 -0
- synkit/Graph/Stereo/global_stereo.py +304 -0
- synkit/Graph/Stereo/identity.py +648 -0
- synkit/Graph/Stereo/interchange.py +496 -0
- synkit/Graph/Stereo/legacy.py +460 -0
- synkit/Graph/Stereo/matching.py +899 -0
- synkit/Graph/Stereo/native.py +154 -0
- synkit/Graph/Stereo/orbits.py +668 -0
- synkit/Graph/Stereo/outcomes.py +99 -0
- synkit/Graph/Stereo/pairwise.py +350 -0
- synkit/Graph/Stereo/rdkit_adapter.py +662 -0
- synkit/Graph/Stereo/rdkit_identity.py +118 -0
- synkit/Graph/Stereo/rdkit_resonance.py +140 -0
- synkit/Graph/Stereo/reaction_interchange.py +266 -0
- synkit/Graph/Stereo/semantics.py +296 -0
- synkit/Graph/Stereo/supports.py +257 -0
- synkit/Graph/Stereo/wire.py +339 -0
- synkit/Graph/Wildcard/__init__.py +0 -0
- synkit/Graph/Wildcard/fuse_graph.py +156 -0
- synkit/Graph/Wildcard/graph_wc.py +303 -0
- synkit/Graph/Wildcard/its_merge.py +857 -0
- synkit/Graph/Wildcard/radwc.py +114 -0
- synkit/Graph/Wildcard/wc_matcher.py +576 -0
- synkit/Graph/Wildcard/wildcard.py +225 -0
- synkit/Graph/__init__.py +17 -0
- synkit/Graph/canon_graph.py +14 -0
- synkit/Graph/syn_graph.py +199 -0
- synkit/Graph/utils.py +324 -0
- synkit/IO/__init__.py +4 -0
- synkit/IO/chem_converter.py +1059 -0
- synkit/IO/combinatorial/__init__.py +8 -0
- synkit/IO/combinatorial/gml_to_graph.py +223 -0
- synkit/IO/combinatorial/graph_to_gml.py +280 -0
- synkit/IO/combinatorial/graph_to_smarts.py +186 -0
- synkit/IO/combinatorial/smarts_expander.py +147 -0
- synkit/IO/combinatorial/smarts_generalizer.py +133 -0
- synkit/IO/combinatorial/smarts_to_graph.py +179 -0
- synkit/IO/conversion.py +42 -0
- synkit/IO/data_io.py +269 -0
- synkit/IO/data_process.py +143 -0
- synkit/IO/debug.py +73 -0
- synkit/IO/gml_to_nx.py +150 -0
- synkit/IO/graph_to_mol.py +199 -0
- synkit/IO/mol_to_graph.py +1105 -0
- synkit/IO/mol_to_graph_chemistry.py +545 -0
- synkit/IO/nx_to_gml.py +209 -0
- synkit/IO/smiles_to_id.py +123 -0
- synkit/Mechanism/__init__.py +151 -0
- synkit/Mechanism/adapters.py +136 -0
- synkit/Mechanism/audit.py +323 -0
- synkit/Mechanism/benchmark.py +638 -0
- synkit/Mechanism/compatibility.py +13 -0
- synkit/Mechanism/drawing.py +85 -0
- synkit/Mechanism/electron_models.py +725 -0
- synkit/Mechanism/equivalence.py +521 -0
- synkit/Mechanism/evidence.py +262 -0
- synkit/Mechanism/interchange.py +141 -0
- synkit/Mechanism/model.py +918 -0
- synkit/Mechanism/neighbor_stereo.py +312 -0
- synkit/Mechanism/radical_data.py +740 -0
- synkit/Mechanism/replay.py +986 -0
- synkit/Mechanism/schema.py +264 -0
- synkit/Mechanism/stereo_state.py +416 -0
- synkit/Mechanism/symbols.py +91 -0
- synkit/Rule/Apply/__init__.py +35 -0
- synkit/Rule/Apply/conditions.py +45 -0
- synkit/Rule/Apply/dpo.py +998 -0
- synkit/Rule/Apply/rule_matcher.py +218 -0
- synkit/Rule/Apply/validation.py +354 -0
- synkit/Rule/Compose/__init__.py +106 -0
- synkit/Rule/Compose/_identity.py +43 -0
- synkit/Rule/Compose/composition.py +976 -0
- synkit/Rule/Compose/laws.py +439 -0
- synkit/Rule/Compose/search.py +771 -0
- synkit/Rule/Compose/synrule.py +170 -0
- synkit/Rule/Modify/__init__.py +0 -0
- synkit/Rule/Modify/implict_rule.py +56 -0
- synkit/Rule/Modify/longest_path.py +92 -0
- synkit/Rule/Modify/molecule_rule.py +115 -0
- synkit/Rule/Modify/prune_templates.py +78 -0
- synkit/Rule/Modify/rule_utils.py +194 -0
- synkit/Rule/Modify/strip_rule.py +97 -0
- synkit/Rule/__init__.py +28 -0
- synkit/Rule/generic_stereo.py +884 -0
- synkit/Rule/stereo_identity.py +271 -0
- synkit/Rule/syn_rule.py +1090 -0
- synkit/Synthesis/MSR/__init__.py +0 -0
- synkit/Synthesis/MSR/path_finder.py +239 -0
- synkit/Synthesis/Metrics/__init__.py +0 -0
- synkit/Synthesis/Metrics/_base.py +52 -0
- synkit/Synthesis/Metrics/_plot.py +129 -0
- synkit/Synthesis/Metrics/_ranking.py +179 -0
- synkit/Synthesis/RBL/__init__.py +80 -0
- synkit/Synthesis/RBL/engine.py +1249 -0
- synkit/Synthesis/RBL/matching.py +652 -0
- synkit/Synthesis/RBL/overlap.py +336 -0
- synkit/Synthesis/RBL/pipeline.py +376 -0
- synkit/Synthesis/RBL/policy.py +139 -0
- synkit/Synthesis/RBL/proof.py +370 -0
- synkit/Synthesis/RBL/reaction.py +506 -0
- synkit/Synthesis/RBL/state.py +169 -0
- synkit/Synthesis/RBL/validation.py +1060 -0
- synkit/Synthesis/Reactor/__init__.py +60 -0
- synkit/Synthesis/Reactor/core/__init__.py +1 -0
- synkit/Synthesis/Reactor/core/engine.py +967 -0
- synkit/Synthesis/Reactor/core/product.py +621 -0
- synkit/Synthesis/Reactor/core/rewrite.py +561 -0
- synkit/Synthesis/Reactor/core/strategy.py +44 -0
- synkit/Synthesis/Reactor/matching/__init__.py +1 -0
- synkit/Synthesis/Reactor/matching/mixin.py +920 -0
- synkit/Synthesis/Reactor/matching/policy.py +345 -0
- synkit/Synthesis/Reactor/matching/symmetry.py +309 -0
- synkit/Synthesis/Reactor/output/__init__.py +1 -0
- synkit/Synthesis/Reactor/output/deduplication.py +703 -0
- synkit/Synthesis/Reactor/output/policy.py +16 -0
- synkit/Synthesis/Reactor/output/serialization.py +485 -0
- synkit/Synthesis/Reactor/output/structural.py +893 -0
- synkit/Synthesis/Reactor/stereo/__init__.py +1 -0
- synkit/Synthesis/Reactor/stereo/assignment.py +35 -0
- synkit/Synthesis/Reactor/stereo/mixin.py +780 -0
- synkit/Synthesis/Reactor/variants/__init__.py +1 -0
- synkit/Synthesis/Reactor/variants/imbalanced.py +180 -0
- synkit/Synthesis/Reactor/variants/partial.py +84 -0
- synkit/Synthesis/Reactor/workflow/__init__.py +1 -0
- synkit/Synthesis/Reactor/workflow/batch.py +550 -0
- synkit/Synthesis/Reactor/workflow/benchmark.py +143 -0
- synkit/Synthesis/Reactor/workflow/postprocess.py +267 -0
- synkit/Synthesis/Reactor/workflow/rule_filter.py +210 -0
- synkit/Synthesis/__init__.py +0 -0
- synkit/Synthesis/reactor_utils.py +316 -0
- synkit/Utils/__init__.py +0 -0
- synkit/Utils/utils.py +172 -0
- synkit/Vis/__init__.py +91 -0
- synkit/Vis/crn/__init__.py +40 -0
- synkit/Vis/epd/__init__.py +20 -0
- synkit/Vis/epd/arrows.py +425 -0
- synkit/Vis/epd/chem.py +197 -0
- synkit/Vis/epd/constants.py +83 -0
- synkit/Vis/epd/layout.py +283 -0
- synkit/Vis/epd/mapping.py +51 -0
- synkit/Vis/epd/models.py +136 -0
- synkit/Vis/epd/render.py +543 -0
- synkit/Vis/epd/utils.py +108 -0
- synkit/Vis/epd/visualizer.py +811 -0
- synkit/Vis/graph_visualizer.py +375 -0
- synkit/Vis/its/__init__.py +19 -0
- synkit/Vis/its/drawer.py +615 -0
- synkit/Vis/its_drawer.py +35 -0
- synkit/Vis/molecule/__init__.py +31 -0
- synkit/Vis/molecule/drawer.py +563 -0
- synkit/Vis/molecule/reaction.py +285 -0
- synkit/Vis/molecule_drawer.py +33 -0
- synkit/Vis/mtg/__init__.py +17 -0
- synkit/Vis/mtg/drawer.py +769 -0
- synkit/Vis/mtg_drawer.py +34 -0
- synkit/Vis/pdf_writer.py +146 -0
- synkit/Vis/reaction/__init__.py +19 -0
- synkit/Vis/reaction/rule.py +141 -0
- synkit/Vis/reaction/rxn.py +532 -0
- synkit/Vis/reaction_drawer.py +41 -0
- synkit/Vis/space/__init__.py +17 -0
- synkit/Vis/space/chemical.py +80 -0
- synkit/Vis/space/embedding.py +87 -0
- synkit/Vis/vis_synedu/Vis/__init__.py +7 -0
- synkit/Vis/vis_synedu/Vis/dpo.py +862 -0
- synkit/Vis/vis_synedu/rxn_vis.py +377 -0
- synkit/Vis/vis_synedu/vis.py +501 -0
- synkit/Vis/visual_drawer.py +215 -0
- synkit/Vis/visual_model.py +520 -0
- synkit/__init__.py +3 -0
- synkit/_native.py +91 -0
- synkit/examples.py +50 -0
- synkit/version.py +23 -0
- synkit-1.6.5.dist-info/METADATA +156 -0
- synkit-1.6.5.dist-info/RECORD +636 -0
- synkit-1.6.5.dist-info/WHEEL +4 -0
- synkit-1.6.5.dist-info/licenses/LICENSE +21 -0
- synkit-1.6.5.dist-info/licenses/synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/COPYRIGHT +44 -0
- synkit-1.6.5.dist-info/licenses/synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/LICENSE-2.0.txt +202 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""Exact typed partial-overlap search for verified RBL fusion."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from time import monotonic
|
|
7
|
+
from typing import Any, Hashable, Mapping, Sequence
|
|
8
|
+
|
|
9
|
+
import networkx as nx
|
|
10
|
+
|
|
11
|
+
from synkit.Graph.Fusion import (
|
|
12
|
+
FusionInterface,
|
|
13
|
+
FusionInterfaceError,
|
|
14
|
+
FusionInterfaceIssueCode,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class TypedOverlapLimits:
|
|
20
|
+
"""Explicit finite bounds for one typed-overlap enumeration."""
|
|
21
|
+
|
|
22
|
+
max_states: int = 250_000
|
|
23
|
+
max_overlaps: int = 50_000
|
|
24
|
+
timeout_seconds: float | None = None
|
|
25
|
+
|
|
26
|
+
def __post_init__(self) -> None:
|
|
27
|
+
if self.max_states <= 0 or self.max_overlaps <= 0:
|
|
28
|
+
raise ValueError("Typed-overlap limits must be positive.")
|
|
29
|
+
if self.timeout_seconds is not None and self.timeout_seconds <= 0:
|
|
30
|
+
raise ValueError("timeout_seconds must be positive or None.")
|
|
31
|
+
|
|
32
|
+
def to_dict(self) -> dict[str, int | float | None]:
|
|
33
|
+
return {
|
|
34
|
+
"max_states": self.max_states,
|
|
35
|
+
"max_overlaps": self.max_overlaps,
|
|
36
|
+
"timeout_seconds": self.timeout_seconds,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class TypedOverlapCertificate:
|
|
42
|
+
"""Replayable accounting for an admitted finite interface universe."""
|
|
43
|
+
|
|
44
|
+
complete: bool
|
|
45
|
+
termination: str
|
|
46
|
+
states_explored: int
|
|
47
|
+
overlaps_emitted: int
|
|
48
|
+
anchored_pairs: tuple[tuple[Hashable, Hashable], ...]
|
|
49
|
+
anchor_conflicts: tuple[tuple[Hashable, Hashable], ...]
|
|
50
|
+
source_nodes: int
|
|
51
|
+
target_nodes: int
|
|
52
|
+
candidate_pairs: int
|
|
53
|
+
limits: TypedOverlapLimits
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> dict[str, Any]:
|
|
56
|
+
return {
|
|
57
|
+
"complete": self.complete,
|
|
58
|
+
"termination": self.termination,
|
|
59
|
+
"states_explored": self.states_explored,
|
|
60
|
+
"overlaps_emitted": self.overlaps_emitted,
|
|
61
|
+
"anchored_pairs": [
|
|
62
|
+
[repr(left), repr(right)] for left, right in self.anchored_pairs
|
|
63
|
+
],
|
|
64
|
+
"anchor_conflicts": [
|
|
65
|
+
[repr(left), repr(right)] for left, right in self.anchor_conflicts
|
|
66
|
+
],
|
|
67
|
+
"source_nodes": self.source_nodes,
|
|
68
|
+
"target_nodes": self.target_nodes,
|
|
69
|
+
"candidate_pairs": self.candidate_pairs,
|
|
70
|
+
"limits": self.limits.to_dict(),
|
|
71
|
+
"universe": (
|
|
72
|
+
"all injective typed partial overlaps containing every "
|
|
73
|
+
"compatible unique provenance anchor"
|
|
74
|
+
),
|
|
75
|
+
"quotient": "none",
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass(frozen=True)
|
|
80
|
+
class TypedOverlapResult:
|
|
81
|
+
mappings: tuple[Mapping[Hashable, Hashable], ...]
|
|
82
|
+
certificate: TypedOverlapCertificate
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _endpoint_scalar(value: Any) -> Any:
|
|
86
|
+
if isinstance(value, (tuple, list)) and len(value) == 2:
|
|
87
|
+
return value[0] if value[0] == value[1] else None
|
|
88
|
+
return value
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _is_wildcard(value: Any, wildcard_element: Any) -> bool:
|
|
92
|
+
scalar = (
|
|
93
|
+
wildcard_element[0]
|
|
94
|
+
if isinstance(wildcard_element, (tuple, list))
|
|
95
|
+
else wildcard_element
|
|
96
|
+
)
|
|
97
|
+
return value in {wildcard_element, scalar}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _mapping_key(mapping: Mapping[Hashable, Hashable]) -> tuple[Any, ...]:
|
|
101
|
+
return tuple(sorted(((repr(left), repr(right)) for left, right in mapping.items())))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _unique_provenance_pairs(
|
|
105
|
+
forward: nx.Graph,
|
|
106
|
+
backward: nx.Graph,
|
|
107
|
+
source_nodes: Sequence[Hashable],
|
|
108
|
+
target_nodes: Sequence[Hashable],
|
|
109
|
+
*,
|
|
110
|
+
provenance_key: str,
|
|
111
|
+
) -> tuple[tuple[Hashable, Hashable], ...]:
|
|
112
|
+
left: dict[Any, list[Hashable]] = {}
|
|
113
|
+
right: dict[Any, list[Hashable]] = {}
|
|
114
|
+
for node in source_nodes:
|
|
115
|
+
value = _endpoint_scalar(forward.nodes[node].get(provenance_key))
|
|
116
|
+
if value not in {None, 0}:
|
|
117
|
+
left.setdefault(value, []).append(node)
|
|
118
|
+
for node in target_nodes:
|
|
119
|
+
value = _endpoint_scalar(backward.nodes[node].get(provenance_key))
|
|
120
|
+
if value not in {None, 0}:
|
|
121
|
+
right.setdefault(value, []).append(node)
|
|
122
|
+
return tuple(
|
|
123
|
+
sorted(
|
|
124
|
+
(
|
|
125
|
+
(left[value][0], right[value][0])
|
|
126
|
+
for value in left.keys() & right.keys()
|
|
127
|
+
if len(left[value]) == len(right[value]) == 1
|
|
128
|
+
),
|
|
129
|
+
key=lambda item: (repr(item[0]), repr(item[1])),
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def enumerate_typed_overlaps( # noqa: C901
|
|
135
|
+
forward: nx.Graph,
|
|
136
|
+
backward: nx.Graph,
|
|
137
|
+
*,
|
|
138
|
+
node_keys: Sequence[str],
|
|
139
|
+
edge_keys: Sequence[str],
|
|
140
|
+
element_key: str = "element",
|
|
141
|
+
wildcard_element: Any = ("*", "*"),
|
|
142
|
+
provenance_key: str = "atom_map",
|
|
143
|
+
limits: TypedOverlapLimits | None = None,
|
|
144
|
+
) -> TypedOverlapResult:
|
|
145
|
+
"""Enumerate every admitted partial injection within explicit limits.
|
|
146
|
+
|
|
147
|
+
Unique, compatible atom-map identities are treated as authoritative
|
|
148
|
+
provenance anchors. Remaining nodes may be included or skipped; therefore
|
|
149
|
+
smaller admissible interfaces are not hidden behind a maximum-cardinality
|
|
150
|
+
objective. Typed wildcard leaves are part of this declared universe and
|
|
151
|
+
are also completed by the exact port-assignment stage when needed.
|
|
152
|
+
"""
|
|
153
|
+
active = limits or TypedOverlapLimits()
|
|
154
|
+
source_nodes = tuple(forward.nodes)
|
|
155
|
+
target_nodes = tuple(backward.nodes)
|
|
156
|
+
|
|
157
|
+
def admitted(mapping: Mapping[Hashable, Hashable]) -> bool:
|
|
158
|
+
if not mapping:
|
|
159
|
+
return False
|
|
160
|
+
try:
|
|
161
|
+
FusionInterface.from_mapping(
|
|
162
|
+
forward,
|
|
163
|
+
backward,
|
|
164
|
+
mapping,
|
|
165
|
+
node_keys=node_keys,
|
|
166
|
+
edge_keys=edge_keys,
|
|
167
|
+
element_key=element_key,
|
|
168
|
+
wildcard_element=wildcard_element,
|
|
169
|
+
)
|
|
170
|
+
except FusionInterfaceError:
|
|
171
|
+
return False
|
|
172
|
+
return True
|
|
173
|
+
|
|
174
|
+
def extendable(mapping: Mapping[Hashable, Hashable]) -> bool:
|
|
175
|
+
"""Accept a partial arm when only a future owner incidence is absent."""
|
|
176
|
+
if not mapping:
|
|
177
|
+
return True
|
|
178
|
+
try:
|
|
179
|
+
FusionInterface.from_mapping(
|
|
180
|
+
forward,
|
|
181
|
+
backward,
|
|
182
|
+
mapping,
|
|
183
|
+
node_keys=node_keys,
|
|
184
|
+
edge_keys=edge_keys,
|
|
185
|
+
element_key=element_key,
|
|
186
|
+
wildcard_element=wildcard_element,
|
|
187
|
+
)
|
|
188
|
+
except FusionInterfaceError as error:
|
|
189
|
+
return bool(error.issues) and all(
|
|
190
|
+
issue.code is FusionInterfaceIssueCode.OWNER_OUTSIDE_INTERFACE
|
|
191
|
+
for issue in error.issues
|
|
192
|
+
)
|
|
193
|
+
return True
|
|
194
|
+
|
|
195
|
+
def potentially_compatible(source: Hashable, target: Hashable) -> bool:
|
|
196
|
+
if extendable({source: target}):
|
|
197
|
+
return True
|
|
198
|
+
source_wildcard = _is_wildcard(
|
|
199
|
+
forward.nodes[source].get(element_key), wildcard_element
|
|
200
|
+
)
|
|
201
|
+
target_wildcard = _is_wildcard(
|
|
202
|
+
backward.nodes[target].get(element_key), wildcard_element
|
|
203
|
+
)
|
|
204
|
+
return source_wildcard or target_wildcard
|
|
205
|
+
|
|
206
|
+
domains: dict[Hashable, tuple[Hashable, ...]] = {}
|
|
207
|
+
for source in source_nodes:
|
|
208
|
+
domains[source] = tuple(
|
|
209
|
+
target
|
|
210
|
+
for target in target_nodes
|
|
211
|
+
if potentially_compatible(source, target)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
anchors: dict[Hashable, Hashable] = {}
|
|
215
|
+
anchor_conflicts: list[tuple[Hashable, Hashable]] = []
|
|
216
|
+
anchor_source_nodes = tuple(
|
|
217
|
+
node
|
|
218
|
+
for node in source_nodes
|
|
219
|
+
if not _is_wildcard(
|
|
220
|
+
forward.nodes[node].get(element_key), wildcard_element
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
anchor_target_nodes = tuple(
|
|
224
|
+
node
|
|
225
|
+
for node in target_nodes
|
|
226
|
+
if not _is_wildcard(
|
|
227
|
+
backward.nodes[node].get(element_key), wildcard_element
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
for source, target in _unique_provenance_pairs(
|
|
231
|
+
forward,
|
|
232
|
+
backward,
|
|
233
|
+
anchor_source_nodes,
|
|
234
|
+
anchor_target_nodes,
|
|
235
|
+
provenance_key=provenance_key,
|
|
236
|
+
):
|
|
237
|
+
proposed = {**anchors, source: target}
|
|
238
|
+
if target not in anchors.values() and extendable(proposed):
|
|
239
|
+
anchors[source] = target
|
|
240
|
+
else:
|
|
241
|
+
anchor_conflicts.append((source, target))
|
|
242
|
+
|
|
243
|
+
optional_sources = tuple(
|
|
244
|
+
sorted(
|
|
245
|
+
(node for node in source_nodes if node not in anchors),
|
|
246
|
+
key=lambda node: (
|
|
247
|
+
_is_wildcard(
|
|
248
|
+
forward.nodes[node].get(element_key), wildcard_element
|
|
249
|
+
),
|
|
250
|
+
len(domains[node]),
|
|
251
|
+
repr(node),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
mappings: list[dict[Hashable, Hashable]] = []
|
|
256
|
+
seen: set[tuple[Any, ...]] = set()
|
|
257
|
+
states = 0
|
|
258
|
+
complete = True
|
|
259
|
+
termination = "exhausted"
|
|
260
|
+
started = monotonic()
|
|
261
|
+
|
|
262
|
+
def limit_reached() -> bool:
|
|
263
|
+
nonlocal complete, termination
|
|
264
|
+
if states >= active.max_states:
|
|
265
|
+
complete = False
|
|
266
|
+
termination = "state_limit"
|
|
267
|
+
return True
|
|
268
|
+
if len(mappings) >= active.max_overlaps:
|
|
269
|
+
complete = False
|
|
270
|
+
termination = "overlap_limit"
|
|
271
|
+
return True
|
|
272
|
+
if (
|
|
273
|
+
active.timeout_seconds is not None
|
|
274
|
+
and monotonic() - started >= active.timeout_seconds
|
|
275
|
+
):
|
|
276
|
+
complete = False
|
|
277
|
+
termination = "timeout"
|
|
278
|
+
return True
|
|
279
|
+
return False
|
|
280
|
+
|
|
281
|
+
def visit(
|
|
282
|
+
index: int,
|
|
283
|
+
current: dict[Hashable, Hashable],
|
|
284
|
+
used_targets: set[Hashable],
|
|
285
|
+
) -> None:
|
|
286
|
+
nonlocal states
|
|
287
|
+
if limit_reached():
|
|
288
|
+
return
|
|
289
|
+
states += 1
|
|
290
|
+
if index == len(optional_sources):
|
|
291
|
+
if current and admitted(current):
|
|
292
|
+
key = _mapping_key(current)
|
|
293
|
+
if key not in seen:
|
|
294
|
+
seen.add(key)
|
|
295
|
+
mappings.append(dict(current))
|
|
296
|
+
return
|
|
297
|
+
|
|
298
|
+
source = optional_sources[index]
|
|
299
|
+
# Stronger overlaps are visited first but do not exclude the skip
|
|
300
|
+
# branch, which is essential for all-partial-overlap completeness.
|
|
301
|
+
for target in domains[source]:
|
|
302
|
+
if target in used_targets:
|
|
303
|
+
continue
|
|
304
|
+
current[source] = target
|
|
305
|
+
if extendable(current):
|
|
306
|
+
used_targets.add(target)
|
|
307
|
+
visit(index + 1, current, used_targets)
|
|
308
|
+
used_targets.remove(target)
|
|
309
|
+
del current[source]
|
|
310
|
+
if limit_reached():
|
|
311
|
+
return
|
|
312
|
+
visit(index + 1, current, used_targets)
|
|
313
|
+
|
|
314
|
+
visit(0, dict(anchors), set(anchors.values()))
|
|
315
|
+
mappings.sort(key=lambda mapping: (-len(mapping), _mapping_key(mapping)))
|
|
316
|
+
certificate = TypedOverlapCertificate(
|
|
317
|
+
complete=complete,
|
|
318
|
+
termination=termination,
|
|
319
|
+
states_explored=states,
|
|
320
|
+
overlaps_emitted=len(mappings),
|
|
321
|
+
anchored_pairs=tuple(anchors.items()),
|
|
322
|
+
anchor_conflicts=tuple(anchor_conflicts),
|
|
323
|
+
source_nodes=len(source_nodes),
|
|
324
|
+
target_nodes=len(target_nodes),
|
|
325
|
+
candidate_pairs=sum(map(len, domains.values())),
|
|
326
|
+
limits=active,
|
|
327
|
+
)
|
|
328
|
+
return TypedOverlapResult(tuple(mappings), certificate)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
__all__ = [
|
|
332
|
+
"TypedOverlapCertificate",
|
|
333
|
+
"TypedOverlapLimits",
|
|
334
|
+
"TypedOverlapResult",
|
|
335
|
+
"enumerate_typed_overlaps",
|
|
336
|
+
]
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"""Top-level orchestration and post-processing for the RBL engine."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional, Union
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from typing import Self
|
|
9
|
+
except ImportError:
|
|
10
|
+
from typing_extensions import Self
|
|
11
|
+
|
|
12
|
+
import networkx as nx
|
|
13
|
+
|
|
14
|
+
from synkit.Chem.Reaction.radical_wildcard import RadicalWildcardAdder
|
|
15
|
+
from synkit.Graph.Wildcard.graph_wc import GraphCollectionSelector
|
|
16
|
+
from synkit.Synthesis.RBL.validation import FusionIssueCode
|
|
17
|
+
from synkit.Synthesis.RBL.policy import (
|
|
18
|
+
OverlapScope,
|
|
19
|
+
ProofLevel,
|
|
20
|
+
RBLSearchPolicy,
|
|
21
|
+
SearchScope,
|
|
22
|
+
TerminationPolicy,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
ITSLike = Any
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RBLPipelineMixin:
|
|
29
|
+
"""Coordinate RBL post-processing and the public process pipeline."""
|
|
30
|
+
|
|
31
|
+
def _postprocess_single(
|
|
32
|
+
self,
|
|
33
|
+
graph: ITSLike,
|
|
34
|
+
*,
|
|
35
|
+
replace_wc: bool,
|
|
36
|
+
rw_adder: Optional[RadicalWildcardAdder] = None,
|
|
37
|
+
diagnostic_context: Optional[Dict[str, Any]] = None,
|
|
38
|
+
) -> Optional[str]:
|
|
39
|
+
"""Post-process a single fused ITS graph to a fused RSMI string.
|
|
40
|
+
|
|
41
|
+
Pipeline:
|
|
42
|
+
|
|
43
|
+
1. ITS → RSMI
|
|
44
|
+
2. Radical wildcard decoration
|
|
45
|
+
3. RSMI → ITS
|
|
46
|
+
4. (Optionally) wildcard → H replacement
|
|
47
|
+
5. ITS → RSMI
|
|
48
|
+
|
|
49
|
+
:param graph: Fused ITS graph to post-process.
|
|
50
|
+
:type graph: ITSLike
|
|
51
|
+
:param replace_wc: If ``True``, wildcard atoms are converted to
|
|
52
|
+
hydrogen before the final ITS→RSMI step.
|
|
53
|
+
:type replace_wc: bool
|
|
54
|
+
:param rw_adder: Optional pre-instantiated wildcard adder. If
|
|
55
|
+
``None``, a new one is constructed.
|
|
56
|
+
:type rw_adder: RadicalWildcardAdder or None
|
|
57
|
+
:return: Final fused reaction SMILES or ``None`` if any step fails.
|
|
58
|
+
:rtype: Optional[str]
|
|
59
|
+
"""
|
|
60
|
+
self._latest_postprocessed_its = None
|
|
61
|
+
self._latest_output_validation = None
|
|
62
|
+
if rw_adder is None:
|
|
63
|
+
rw_adder = self.wildcard_adder_cls()
|
|
64
|
+
|
|
65
|
+
# Verified forward/backward applications already carry typed radical
|
|
66
|
+
# completion ports. Preserve the graph that the pushout certified and
|
|
67
|
+
# materialize those ports directly, avoiding a lossy graph/string/
|
|
68
|
+
# graph round trip before validation.
|
|
69
|
+
if self.verified_mode and isinstance(graph, nx.Graph):
|
|
70
|
+
diagnostics_before = len(self._diagnostics["fusion"])
|
|
71
|
+
its_back = graph.copy()
|
|
72
|
+
if replace_wc:
|
|
73
|
+
its_back = self.replace_wildcard_with_H(its_back)
|
|
74
|
+
rsmi_final = self._safe_its_to_rsmi(
|
|
75
|
+
its_back,
|
|
76
|
+
fmt="tuple",
|
|
77
|
+
explicit_hydrogen=replace_wc,
|
|
78
|
+
)
|
|
79
|
+
if rsmi_final is not None:
|
|
80
|
+
validation = self._validate_fusion_output(
|
|
81
|
+
rsmi_final,
|
|
82
|
+
allow_wildcards=not replace_wc,
|
|
83
|
+
source="postprocess",
|
|
84
|
+
context=diagnostic_context,
|
|
85
|
+
)
|
|
86
|
+
if validation.valid:
|
|
87
|
+
self._latest_postprocessed_its = its_back
|
|
88
|
+
return rsmi_final
|
|
89
|
+
# Some older prepared templates require the historical radical
|
|
90
|
+
# normalization before they become serializable. Fall back
|
|
91
|
+
# transactionally; failed speculative diagnostics must not turn
|
|
92
|
+
# a successfully normalized candidate into an incomplete run.
|
|
93
|
+
del self._diagnostics["fusion"][diagnostics_before:]
|
|
94
|
+
self._latest_output_validation = None
|
|
95
|
+
|
|
96
|
+
rsmi1 = self._safe_its_to_rsmi(
|
|
97
|
+
graph,
|
|
98
|
+
fmt="tuple",
|
|
99
|
+
explicit_hydrogen=self.explicit_h,
|
|
100
|
+
)
|
|
101
|
+
if rsmi1 is None:
|
|
102
|
+
self._record_fusion_failure(
|
|
103
|
+
FusionIssueCode.SERIALIZATION_FAILED,
|
|
104
|
+
"Could not serialize the fused ITS before post-processing.",
|
|
105
|
+
source="postprocess",
|
|
106
|
+
context=diagnostic_context,
|
|
107
|
+
)
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
# Radical completion can create the same isolated wildcard spectator
|
|
111
|
+
# on both endpoints. Remove only that side-symmetric multiset before
|
|
112
|
+
# materialising the remaining wildcards as hydrogen.
|
|
113
|
+
rsmi1 = self._strip_balanced_isolated_wildcards(rsmi1)
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
rsmi2 = rw_adder.transform(rsmi1)
|
|
117
|
+
except Exception as exc: # pragma: no cover - defensive
|
|
118
|
+
self.logger.debug("Radical wildcard decoration (single) failed: %s", exc)
|
|
119
|
+
self._record_fusion_failure(
|
|
120
|
+
FusionIssueCode.POSTPROCESS_FAILED,
|
|
121
|
+
"Radical wildcard decoration failed during post-processing.",
|
|
122
|
+
source="postprocess",
|
|
123
|
+
context={**(diagnostic_context or {}), "error": type(exc).__name__},
|
|
124
|
+
)
|
|
125
|
+
return None
|
|
126
|
+
|
|
127
|
+
its_back = self._safe_rsmi_to_its(rsmi2)
|
|
128
|
+
if its_back is None:
|
|
129
|
+
self._record_fusion_failure(
|
|
130
|
+
FusionIssueCode.POSTPROCESS_FAILED,
|
|
131
|
+
"Could not parse the wildcard-decorated reaction.",
|
|
132
|
+
source="postprocess",
|
|
133
|
+
context=diagnostic_context,
|
|
134
|
+
)
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
if isinstance(its_back, nx.Graph) and replace_wc:
|
|
138
|
+
its_back = self.replace_wildcard_with_H(its_back)
|
|
139
|
+
|
|
140
|
+
rsmi_final = self._safe_its_to_rsmi(
|
|
141
|
+
its_back,
|
|
142
|
+
fmt="tuple",
|
|
143
|
+
explicit_hydrogen=replace_wc,
|
|
144
|
+
)
|
|
145
|
+
if rsmi_final is None:
|
|
146
|
+
self._record_fusion_failure(
|
|
147
|
+
FusionIssueCode.SERIALIZATION_FAILED,
|
|
148
|
+
"Could not serialize the materialized fusion endpoint.",
|
|
149
|
+
source="postprocess",
|
|
150
|
+
context=diagnostic_context,
|
|
151
|
+
)
|
|
152
|
+
return None
|
|
153
|
+
|
|
154
|
+
validation = self._validate_fusion_output(
|
|
155
|
+
rsmi_final,
|
|
156
|
+
allow_wildcards=not replace_wc,
|
|
157
|
+
source="postprocess",
|
|
158
|
+
context=diagnostic_context,
|
|
159
|
+
)
|
|
160
|
+
if not validation.valid:
|
|
161
|
+
return None
|
|
162
|
+
self._latest_postprocessed_its = its_back
|
|
163
|
+
return rsmi_final
|
|
164
|
+
|
|
165
|
+
# ------------------------------------------------------------------
|
|
166
|
+
# Full RBL pipeline: forward + backward + fusion
|
|
167
|
+
# ------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
def process( # noqa: C901
|
|
170
|
+
self,
|
|
171
|
+
rsmi: str,
|
|
172
|
+
template: Union[str, nx.Graph, ITSLike],
|
|
173
|
+
*,
|
|
174
|
+
replace_wc: bool = True,
|
|
175
|
+
fast_paths_only: Optional[bool] = None,
|
|
176
|
+
) -> Self:
|
|
177
|
+
"""Run the full RBL pipeline on a reaction RSMI and a template.
|
|
178
|
+
|
|
179
|
+
1. Split the reaction into reactants/products via ``'>>'``.
|
|
180
|
+
2. Optionally attempt a quick-check (:meth:`_quick_check`) if
|
|
181
|
+
early-stop or fast-paths-only logic is active. On success,
|
|
182
|
+
store the solution as the sole entry in :attr:`fused_rsmis`.
|
|
183
|
+
3. Prepare the template via :meth:`prepare_template`.
|
|
184
|
+
4. Run forward and backward template application via :meth:`react`.
|
|
185
|
+
5. Optionally attempt :meth:`_early_stop_on_nonwildcard` to exploit
|
|
186
|
+
ITS graphs that contain no wildcard atoms at all, with canonical
|
|
187
|
+
reactant/product verification.
|
|
188
|
+
6. If fast-path-only logic is active and no solution was found in
|
|
189
|
+
steps 2–5, return without running fusion.
|
|
190
|
+
7. Otherwise, run :meth:`_fuse_and_postprocess` with streaming
|
|
191
|
+
early-stop behaviour controlled by :attr:`early_stop`.
|
|
192
|
+
|
|
193
|
+
When ``fast_paths_only`` (argument or attribute) is ``True``,
|
|
194
|
+
only steps 1–6 are executed and the expensive fusion stage is
|
|
195
|
+
skipped entirely.
|
|
196
|
+
|
|
197
|
+
:param rsmi: Input reaction SMILES.
|
|
198
|
+
:type rsmi: str
|
|
199
|
+
:param template: Template as reaction SMILES, graph or ITS-like.
|
|
200
|
+
:type template: str | nx.Graph | ITSLike
|
|
201
|
+
:param replace_wc: If ``True``, replace wildcard atoms by hydrogen
|
|
202
|
+
during final post-processing.
|
|
203
|
+
:type replace_wc: bool
|
|
204
|
+
:param fast_paths_only: Optional per-call override of the
|
|
205
|
+
engine-level :attr:`fast_paths_only` flag. If ``None``,
|
|
206
|
+
the attribute value is used.
|
|
207
|
+
:type fast_paths_only: bool or None
|
|
208
|
+
:return: The current engine instance.
|
|
209
|
+
:rtype: RBLEngine
|
|
210
|
+
:raises ValueError: If the reaction string does not contain ``'>>'``
|
|
211
|
+
or if template preparation fails.
|
|
212
|
+
"""
|
|
213
|
+
try:
|
|
214
|
+
reactants, products = rsmi.split(">>", 1)
|
|
215
|
+
except ValueError as exc:
|
|
216
|
+
raise ValueError(
|
|
217
|
+
f"Invalid reaction string {rsmi!r}: expected 'reactants>>products'."
|
|
218
|
+
) from exc
|
|
219
|
+
|
|
220
|
+
self._reset_run_state()
|
|
221
|
+
self._last_reaction = rsmi
|
|
222
|
+
self._last_reactants = reactants
|
|
223
|
+
self._last_products = products
|
|
224
|
+
|
|
225
|
+
# Resolve the compatibility override into the same explicit policy.
|
|
226
|
+
if fast_paths_only is None:
|
|
227
|
+
policy = self.search_policy
|
|
228
|
+
elif fast_paths_only:
|
|
229
|
+
policy = RBLSearchPolicy(
|
|
230
|
+
SearchScope.FAST_PATHS_ONLY,
|
|
231
|
+
TerminationPolicy.FIRST_VALID,
|
|
232
|
+
OverlapScope.NONE,
|
|
233
|
+
ProofLevel.NONE,
|
|
234
|
+
self.search_policy.acceptance_task,
|
|
235
|
+
)
|
|
236
|
+
else:
|
|
237
|
+
policy = RBLSearchPolicy(
|
|
238
|
+
SearchScope.FUSION,
|
|
239
|
+
self.search_policy.termination,
|
|
240
|
+
self.search_policy.overlap_scope,
|
|
241
|
+
self.search_policy.proof_level,
|
|
242
|
+
self.search_policy.acceptance_task,
|
|
243
|
+
)
|
|
244
|
+
self._active_search_policy = policy
|
|
245
|
+
fast_only = policy.scope is SearchScope.FAST_PATHS_ONLY
|
|
246
|
+
stop_first = policy.termination is TerminationPolicy.FIRST_VALID
|
|
247
|
+
# Candidate generation and termination are independent. Wider search
|
|
248
|
+
# profiles retain candidates available to the fast profile;
|
|
249
|
+
# FIRST_VALID controls only whether a valid candidate returns early.
|
|
250
|
+
run_fast_paths = True
|
|
251
|
+
|
|
252
|
+
self.logger.debug(
|
|
253
|
+
"Processing reaction: %s (early_stop=%s, fast_paths_only=%s, "
|
|
254
|
+
"implicit_temp=%s, explicit_h=%s, embed_threshold=%d)",
|
|
255
|
+
rsmi,
|
|
256
|
+
stop_first,
|
|
257
|
+
fast_only,
|
|
258
|
+
self.implicit_temp,
|
|
259
|
+
self.explicit_h,
|
|
260
|
+
self.embed_threshold,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
# Quick-check path (cheap SynReactor + standardizer)
|
|
264
|
+
quick_solution: Optional[str] = None
|
|
265
|
+
if run_fast_paths:
|
|
266
|
+
quick_solution = self._quick_check(rsmi, template)
|
|
267
|
+
|
|
268
|
+
if quick_solution is not None:
|
|
269
|
+
validation = self._validate_fusion_output(
|
|
270
|
+
quick_solution,
|
|
271
|
+
allow_wildcards=not replace_wc,
|
|
272
|
+
source="quick_check",
|
|
273
|
+
)
|
|
274
|
+
if validation.valid:
|
|
275
|
+
if stop_first:
|
|
276
|
+
self.logger.debug(
|
|
277
|
+
"Quick-check path taken; skipping wider RBL search."
|
|
278
|
+
)
|
|
279
|
+
self._forward_its = []
|
|
280
|
+
self._backward_its = []
|
|
281
|
+
self._fused_its = []
|
|
282
|
+
self._fused_rsmis = [quick_solution]
|
|
283
|
+
# _record_stop has already been called in _quick_check
|
|
284
|
+
return self
|
|
285
|
+
quick_graph = self._safe_rsmi_to_its(quick_solution)
|
|
286
|
+
if isinstance(quick_graph, nx.Graph):
|
|
287
|
+
self._fused_its = [quick_graph]
|
|
288
|
+
self._fused_rsmis = [quick_solution]
|
|
289
|
+
else:
|
|
290
|
+
self._record_fusion_failure(
|
|
291
|
+
FusionIssueCode.SERIALIZATION_FAILED,
|
|
292
|
+
"A valid quick-check candidate could not be represented "
|
|
293
|
+
"as an ITS graph for exhaustive candidate collection.",
|
|
294
|
+
source="quick_check",
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
if not validation.valid:
|
|
298
|
+
self.logger.debug(
|
|
299
|
+
"Quick-check candidate failed the shared fusion contract; "
|
|
300
|
+
"continuing with the RBL pipeline."
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
# Full RBL pipeline setup (up to ITS generation)
|
|
304
|
+
self.prepare_template(template)
|
|
305
|
+
pattern = self._template_its
|
|
306
|
+
if pattern is None:
|
|
307
|
+
raise ValueError("Template preparation failed; no ITS representation.")
|
|
308
|
+
|
|
309
|
+
fw_its = self._run_reaction(reactants, pattern, invert=False)
|
|
310
|
+
bw_its = self._run_reaction(products, pattern, invert=True)
|
|
311
|
+
|
|
312
|
+
self._forward_its = fw_its
|
|
313
|
+
self._backward_its = bw_its
|
|
314
|
+
|
|
315
|
+
# Early-stop second stage: exploit ITS graphs without wildcards
|
|
316
|
+
if run_fast_paths:
|
|
317
|
+
found_fast = self._early_stop_on_nonwildcard(
|
|
318
|
+
fw_its,
|
|
319
|
+
bw_its,
|
|
320
|
+
replace_wc=replace_wc,
|
|
321
|
+
stop_first=stop_first,
|
|
322
|
+
)
|
|
323
|
+
if found_fast and stop_first:
|
|
324
|
+
return self
|
|
325
|
+
|
|
326
|
+
# If we are in fast-path-only mode and non-wildcard early-stop
|
|
327
|
+
# failed, we *do not* run the expensive fusion stage.
|
|
328
|
+
if fast_only:
|
|
329
|
+
self._record_stop(
|
|
330
|
+
mode="fast_paths_only",
|
|
331
|
+
reason="fast_paths_no_solution",
|
|
332
|
+
metadata={
|
|
333
|
+
"n_fw": len(fw_its),
|
|
334
|
+
"n_bw": len(bw_its),
|
|
335
|
+
"fast_paths_only": fast_only,
|
|
336
|
+
"early_stop": stop_first,
|
|
337
|
+
},
|
|
338
|
+
)
|
|
339
|
+
self.logger.debug(
|
|
340
|
+
"Fast-path-only mode: no quick-check or non-wildcard "
|
|
341
|
+
"solution; skipping fusion."
|
|
342
|
+
)
|
|
343
|
+
return self
|
|
344
|
+
|
|
345
|
+
# Filter: keep only ITS graphs that *contain* wildcard atoms
|
|
346
|
+
sel_fw = GraphCollectionSelector(self._forward_its)
|
|
347
|
+
sel_fw.select_wc(
|
|
348
|
+
wildcard=self.wildcard_element,
|
|
349
|
+
select_with_wc=True,
|
|
350
|
+
)
|
|
351
|
+
self._forward_its = sel_fw.filtered
|
|
352
|
+
|
|
353
|
+
sel_bw = GraphCollectionSelector(self._backward_its)
|
|
354
|
+
sel_bw.select_wc(
|
|
355
|
+
wildcard=self.wildcard_element,
|
|
356
|
+
select_with_wc=True,
|
|
357
|
+
)
|
|
358
|
+
self._backward_its = sel_bw.filtered
|
|
359
|
+
|
|
360
|
+
# Full fusion + post-processing (only when fast-path-only is False)
|
|
361
|
+
direct_graphs = tuple(self._fused_its)
|
|
362
|
+
direct_rsmis = tuple(self._fused_rsmis)
|
|
363
|
+
self._fuse_and_postprocess(
|
|
364
|
+
self._forward_its,
|
|
365
|
+
self._backward_its,
|
|
366
|
+
replace_wc=replace_wc,
|
|
367
|
+
early_stop=stop_first,
|
|
368
|
+
max_pairs=self.max_pairs,
|
|
369
|
+
initial_graphs=direct_graphs,
|
|
370
|
+
initial_rsmis=direct_rsmis,
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
__all__ = ["RBLPipelineMixin"]
|