From db5d1ea8c544a4f02786aa0552bdf402e97bd919 Mon Sep 17 00:00:00 2001 From: Samuel Pastva Date: Fri, 23 Aug 2024 10:02:43 +0200 Subject: [PATCH] Copy the known stable motifs into the inner succession diagram instead of re-computing. --- biobalm/_sd_algorithms/expand_source_blocks.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/biobalm/_sd_algorithms/expand_source_blocks.py b/biobalm/_sd_algorithms/expand_source_blocks.py index 78b7f1d..7341aee 100644 --- a/biobalm/_sd_algorithms/expand_source_blocks.py +++ b/biobalm/_sd_algorithms/expand_source_blocks.py @@ -172,11 +172,14 @@ def expand_source_blocks( for block, block_nodes in minimal_blocks: block_sd = sd.component_subdiagram(list(block), node) - # The succession diagram "restricted" to the considered block should have - # the same (restricted) successor nodes. - assert len( - block_sd.node_successors(block_sd.root(), compute=True) - ) == len(block_nodes) + # Instead of expanding the inner succession diagram "normally", we can + # copy the successors/stable motifs that we already know. This doesn't + # make too much of a difference unless the maximal trap space computation + # is complex, but that is sometimes true, especially for large networks. + for succ_id in block_nodes: + succ_motif = sd.edge_stable_motif(node, succ_id, reduced=True) + block_sd._ensure_node(block_sd.root(), succ_motif) # type: ignore + block_sd.node_data(block_sd.root())["expanded"] = True # We could also consider using `seeds` instead of `candidates` here. Ultimately, this # matters very rarely. The reasoning for why we use `candidates` is that we can (almost)