feat(merge): add command to merge two pangenome graphs - #192
Open
mmolari wants to merge 4 commits into
Open
Conversation
mmolari
temporarily deployed
to
refs/pull/192/merge
August 10, 2026 12:48 — with
GitHub Actions
Inactive
mmolari
temporarily deployed
to
refs/pull/192/merge
August 10, 2026 13:16 — with
GitHub Actions
Inactive
mmolari
temporarily deployed
to
refs/pull/192/merge
August 10, 2026 13:35 — with
GitHub Actions
Inactive
mmolari
force-pushed
the
feat/merge-cmd
branch
from
August 10, 2026 13:40
c23358c to
5c9645f
Compare
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.
Adds
pangraph merge <LEFT_GRAPH> <RIGHT_GRAPH>, which combines two existing graphs into one. Covers §4.2 and §4.5 ofdev/design/merge.md.Arguments (§4.2). The five parameters that actually govern a merger —
aln_args,alignment_kernel,max_self_map,extra_band_width,max_alignment_attempts— move out ofPangraphBuildArgsinto aGraphMergeParamsstruct inalign/, whichbuildandmergeboth flatten. The deep call chain (merge_graphs,solve_promise,reconsensus_graph,edit_consensus_and_realign,map_variations) now takes&GraphMergeParams, which also removes thealign → commands::builddependency. No flags are added or removed frombuild; the only change to its help output is that-c/--circularnow appears after-kinstead of before-x.Identifier relabeling (§3.4). Two independently built graphs always collide —
Pangraph::singletonlabels the first genome of every build with path, block and node id0, and blocks that never merge keep that id — sograph_joinpanicked on every real input pair.Pangraph::relabel_in_placere-derives block and node ids asid((salt, old_id))and renumbers path ids contiguously from an offset;make_disjoint_fromapplies it to the second graph, leaving the first untouched. This was implemented here rather than as a separate PR because the command is not testable without it.The command (§4.5). Loads both graphs, checks them (backend availability, non-empty, duplicate genome names across and within the inputs, a warning on mixed circularity), relabels the second, merges, optionally verifies, and writes the result.
--verifymatches genomes by name rather than by index or position, since neither survives a merge. The supersededbin/merge_two_graphs.rsis removed.Four integration tests: homologous graphs (all genomes round-trip, and blocks end up shared across the two inputs), appending a single genome, unrelated graphs (the case where colliding small ids survive), and rejection of duplicate genome names.
Still open, tracked in the roadmap:
builddoes not yet reject duplicate FASTA names, and the name-keyed verification is currently private tomergerather than shared withbuild.