Extract minimum assembly pathways as directed acyclic graphs of fragments - #153
Merged
Conversation
jdaymude
force-pushed
the
extract-pathways
branch
from
July 28, 2026 21:51
905b14d to
b09d68e
Compare
jdaymude
force-pushed
the
extract-pathways
branch
from
July 29, 2026 01:21
6be9fb2 to
3767b0b
Compare
jdaymude
force-pushed
the
extract-pathways
branch
from
July 29, 2026 05:17
eff9331 to
9518804
Compare
Garrett-Pz
reviewed
Aug 10, 2026
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #22, enabling minimum assembly pathway extraction. Subsumes #146 and #147.
There's a lot to talk about here, but the TL;DR is this: we now finally support assembly pathway reconstruction, we do so in a reasonably efficient way (5–20% performance overhead to search when reconstructing pathways, negligible performance differences if pathway reconstruction is disabled), and our pathway data format is more informative and interoperable with downstream tools than what's out there right now.
Specifying Assembly Pathway Reconstruction
There are several interface-level changes:
--pathwaysoptionindex_searchfunction now takes a mandatorymax_pathways: Option<usize>parameterindex_searchfunction now takes amax_pathways: int/Noneparameter (defaultNone)All of these basically work the same way:
--pathwaysis not set (CLI) ormax_pathways = None(Rust/Python), assembly pathway reconstruction is disabled and things mostly work as before.--pathways n(CLI) ormax_pathways = n(Rust/Python) for some integern > 0, we return at mostnminimum assembly pathways discovered during assembly index search.--pathways 0(CLI) ormax_pathways = 0(Rust/Python), we return all minimum assembly pathways discovered during assembly index search.Note that the last of these settings does not necessarily return all possible minimum assembly pathways. When search optimizations like bounding and memoization are enabled, we prune any search states that cannot yield a better bound on the assembly index. This includes assembly states that may attain equally good assembly index bounds, and in particular, those that would attain the true assembly index after one such state is already found. These states may also potentially yield minimum assembly pathways, but they are pruned for search efficiency.
Assembly Pathway Representation
Assembly pathways are represented as directed, acyclic multigraphs (DAGs) whose nodes are molecular graph fragments and whose edges represent joining operations. Our data structure is similar to what you would need for the Croninlab visualization, but with a few additional improvements. Formally:
CCsingle bonds together to form aCCCand then joins another singleCCbond to that structure to form aCCCCchain, theCCfragment will only be represented once as a node in the DAG.Pathways are returned as follows:
Example Output for Anthracene
index_searchfunction returns aVec<Pathway>, where thePathwaystruct represents a single assembly pathway as apetgraph::Digraphwhose nodes/edges are labeled bybit_set::BitSets indexing their fragments' bonds, following the specifications above.index_searchfunction returns alist[str]containing the DOT-formatted string representations of all reconstructed assembly pathways, appearing exactly as they do in the CLI output.This data format is particularly nice for the Python interface, which can load these DOT strings up in graphviz, parse the node and edge labels as sets using Python's
ast.literal_eval, and then throw those sets into RDKit'sPathToSubmolto get the actual molecular fragments used in the assembly pathway and visualize them. This PR does not implement this functionality (it's big enough as is), but sets up all the necessary data structures.Performance Impact
When assembly pathway reconstruction is disabled, search performance is not impacted:
Benchmark 06e6582 (this PR) vs. a992612 (current main) as a baseline
A new benchmark,
bench_removal_orders, compares search performance across three scenarios: (1) assembly pathway reconstruction disabled, (2) reconstructing one minimum assembly pathway discovered during search, and (3) reconstructing all minimum assembly pathways discovered during search. The raw data is below, but search incurs a 5–20% overhead when collecting match removal orders for later assembly pathway reconstruction. The overhead is smaller when fewer match removal orders are collected (e.g., forcoconut_55, the overhead is 11.84% for one match removal order but 15.94% for all).Benchmark 06e6582 (this PR) on search with assembly pathway reconstruction enabled
Algorithm Details
Tracking match removal orders during search was something we were already doing; #149 and #150 handled the necessary setup to be used for assembly pathway reconstruction. Our reconstruction algorithm is an efficient implementation of the duplicate/remnant algorithm described in the Supporting Information of Seet et al. (2025).