Skip to content

stats: shortcut diploid 0/0 genotypes in do_sample_stats - #2619

Open
BenjaminDEMAILLE wants to merge 1 commit into
samtools:developfrom
BenjaminDEMAILLE:perf/stats-homref-shortcut
Open

BenjaminDEMAILLE wants to merge 1 commit into
samtools:developfrom
BenjaminDEMAILLE:perf/stats-homref-shortcut

Conversation

@BenjaminDEMAILLE

@BenjaminDEMAILLE BenjaminDEMAILLE commented Nov 24, 2026 •

Copy link
Copy Markdown

For diploid int8 GT, I noticed that a 0/0 only increments smpl_homRR and the HWE ref count, and the AD/VAF part does nothing for it. So I count it directly instead of going through bcf_gt_type() and sample_gt_stats(). The output doesn't change.

With stats -s - on 1000G chr22 (287k sites, 500 samples), I went from 1.09s to 0.47s on BCF and from 2.65s to 1.84s on VCF.gz. make test passes.

I adapted it from pasta (https://github.com/DylanCosto/pasta, MIT).

I've listed this with my other performance PRs in samtools/htslib#2175.

Assisted-by: Claude:claude-opus-5-5

A diploid int8 0/0 only bumps smpl_homRR and the HWE ref count, so do
that directly instead of bcf_gt_type() + sample_gt_stats().  Output is
unchanged.

stats -s - on 1000G chr22 (287k sites, 500 samples): BCF 1.09s -> 0.47s,
VCF.gz 2.65s -> 1.84s.

Idea from pasta (https://github.com/DylanCosto/pasta, MIT).

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Benjamin Demaille <benjamin.demaille@icloud.com>

This branch has not been deployed

No deployments
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