Skip to content

feat(merge): add command to merge two pangenome graphs - #192

Open
mmolari wants to merge 4 commits into
feat/mergefrom
feat/merge-cmd
Open

feat(merge): add command to merge two pangenome graphs#192
mmolari wants to merge 4 commits into
feat/mergefrom
feat/merge-cmd

Conversation

@mmolari

@mmolari mmolari commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Adds pangraph merge <LEFT_GRAPH> <RIGHT_GRAPH>, which combines two existing graphs into one. Covers §4.2 and §4.5 of dev/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 of PangraphBuildArgs into a GraphMergeParams struct in align/, which build and merge both flatten. The deep call chain (merge_graphs, solve_promise, reconsensus_graph, edit_consensus_and_realign, map_variations) now takes &GraphMergeParams, which also removes the align → commands::build dependency. No flags are added or removed from build; the only change to its help output is that -c/--circular now appears after -k instead of before -x.

Identifier relabeling (§3.4). Two independently built graphs always collide — Pangraph::singleton labels the first genome of every build with path, block and node id 0, and blocks that never merge keep that id — so graph_join panicked on every real input pair. Pangraph::relabel_in_place re-derives block and node ids as id((salt, old_id)) and renumbers path ids contiguously from an offset; make_disjoint_from applies 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. --verify matches genomes by name rather than by index or position, since neither survives a merge. The superseded bin/merge_two_graphs.rs is 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: build does not yet reject duplicate FASTA names, and the name-keyed verification is currently private to merge rather than shared with build.

@mmolari
mmolari temporarily deployed to refs/pull/192/merge August 10, 2026 12:48 — with GitHub Actions Inactive
@mmolari
mmolari temporarily deployed to refs/pull/192/merge August 10, 2026 13:16 — with GitHub Actions Inactive
@mmolari
mmolari temporarily deployed to refs/pull/192/merge August 10, 2026 13:35 — with GitHub Actions Inactive
@mmolari
mmolari deployed to refs/pull/192/merge August 10, 2026 13:40 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant