fix(build): make graph construction invariant under input FASTA order - #190
Draft
mmolari wants to merge 9 commits into
Draft
fix(build): make graph construction invariant under input FASTA order#190mmolari wants to merge 9 commits into
mmolari wants to merge 9 commits into
Conversation
…ties deterministic
…onfounded comparison
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.
pangraph build gave a different graph depending only on the order the input FASTA files were listed.
Block ids derive from input position, are passed to minimap2 as sequence names, and -X (MM_F_NO_DUAL) picks the direction of each pair by strcmp on those names. Argument order thus
decided query vs reference for every pair, and assign_anchor_block privileged the reference, so its consensus won and propagated into the merged block. Independently, neighbor
joining resolved Q-matrix ties by row order — which for three taxa is always tied, since every off-diagonal entry is identically -(D₁₂+D₁₃+D₂₃) — so the inferred topology also
followed the command line.
Changes
content. Both backends feed blocks in this order and recover ids by lookup.
Guarantee: graph structure is a pure function of the input sequence set, the tree topology and the alignment parameters. BlockId values still derive from fasta.index, so output JSON
is not byte-identical across orders — only the structure is.
Validation
All six permutations of the reproducer now give 512 blocks (was 452–509) with byte-identical consensus and depth multisets, and the same under a sibling-swapped tree. Without
--guide-tree they likewise collapse to one answer. Each test assertion was checked against reverted code. Fixtures (data/test_graph.json, plasmids.json) are unchanged; tests and
clippy are clean.
Full investigation, measurements and rejected alternatives: notes/n00_build_order_dependence.typ.