Skip to content

Gbz name validation - #38

Merged
DonFreed merged 2 commits into
devfrom
gbz-name-validation
Sep 13, 2026
Merged

DonFreed merged 2 commits into
devfrom
gbz-name-validation

Conversation

@DonFreed

Copy link
Copy Markdown
Contributor

Improve pangenome validation

DonFreed and others added 2 commits September 12, 2026 12:46
A wrong `--pangenome_ref_name` was silent: `vg haplotypes --set-reference`
only warns, the sampled graph loses its reference paths, `vg convert -Q`
writes no rGFA tags and `pgutil lift` exits 0 with every read unmapped.

Read the reference name and contig prefix from the GBWT metadata in the
GBZ header instead (new `pangenome_meta` module, well under a second per
graph). The backbone reference is the unfragmented reference sample. Make
`--pangenome_ref_name` and `--pangenome_contig_prefix` hidden overrides
that must agree with the graph, check the backbone contigs and build
against the reference FASTA, replace the `grch38.gbz` filename-suffix
check, apply the GRCh38 contig-length check only to GRCh38 backbones, and
add `check-sample-gbz` / `check-sample-gfa` jobs to both DAGs so a
sampled graph or GFA without the reference fails the run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lo4R3WSNwCYMcKzvGKCqSs
`validate_grch38_contigs` compared the reference index and the `--pop_vcf`
with a hard-coded table of the 25 GRCh38 chromosome lengths, so it only ran
for a GRCh38 backbone and never looked at the 170 unplaced contigs the HPRC
graph also carries. Drop the table and compare the two files instead: every
contig of the backbone reference detected in the GBZ must carry the same
length in the `--pop_vcf` header as in the reference FASTA index. A CHM13
graph is now checked the same way a GRCh38 one is, a contig absent from the
pop VCF or without a length is an error, and the message names the first ten
offenders with both lengths. Only the hidden `--skip_contig_checks` flag
bypasses the check; `--skip_pangenome_name_checks` does not.

The pop VCF header is now parsed in pure Python. `vcf_contigs` and `vcf_id`
shelled out to `bcftools view -h`, and `vcf_contigs` returned a fake
three-contig dictionary in dry runs, which left the dry run checking nothing
and the real run checking everything. `read_vcf_header` opens the file with
`gzip` when its first two bytes say so -- the extension is not trusted -- and
stops at the first line that is not a header line, so the body is never read:
the header of the 10 GB population VCF parses in about 1 ms. Dry runs now
parse it too, and fall back only when the file cannot be read at all, which
is what the unit tests and the placeholder files behind them need. The
`SentieonVcfID` comparison follows the same rule, so a dry run catches a pop
VCF that does not belong with the model bundle.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RWPD3suVQRpMZbJHijXhao
@DonFreed
DonFreed merged commit 4756e9e into dev Sep 13, 2026
12 checks passed
@DonFreed
DonFreed deleted the gbz-name-validation branch September 13, 2026 21:09
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