Skip to content

test: add happy-path test for compute_haplotype_statistics#29

Open
ameynert wants to merge 1 commit intomainfrom
am_test_compute_haplotype_statistics
Open

test: add happy-path test for compute_haplotype_statistics#29
ameynert wants to merge 1 commit intomainfrom
am_test_compute_haplotype_statistics

Conversation

@ameynert
Copy link
Copy Markdown
Collaborator

@ameynert ameynert commented Apr 17, 2026

Summary

  • Uses pre-committed chr1_100001_200000_haplotypes.ht and chr1_100001_200000.gnomad_afs.ht test data
  • Patches hl.init() (Spark context already running from session fixture)
  • Asserts both .hgdp.tsv and .gnomad.tsv output files are written with correct headers, row counts (1 freq × 1 window), and exact counts (24 unique haplotypes, 473 gnomAD variants at freq ≥ 0.005, window=5000)

Closes #24

Test plan

  • uv run --directory divref poe check-all passes (format/lint failures are pre-existing in untracked extract_gnomad_single_afs.py)
  • compute_haplotype_statistics reaches 100% test coverage

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for haplotype statistics computation to validate output file generation, data format integrity, and result accuracy.

Uses the committed chr1_100001_200000_haplotypes.ht and
chr1_100001_200000.gnomad_afs.ht test data. Asserts both output TSV
files are written with the correct headers, row counts, and exact
values for a single (frequency=0.005, window=5000) parameter combination.

Closes #24

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ameynert ameynert temporarily deployed to github-actions-snakemake-linting April 17, 2026 18:35 — with GitHub Actions Inactive
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8dc81a1-9a97-42a6-8ad6-8e96840f9958

📥 Commits

Reviewing files that changed from the base of the PR and between 316c402 and 71510c7.

📒 Files selected for processing (1)
  • divref/tests/tools/test_compute_haplotype_statistics.py

📝 Walkthrough

Walkthrough

A new test module is added to verify the compute_haplotype_statistics tool. The test constructs input paths, invokes the tool with mocked Hail initialization, and validates that expected TSV output files are created with correct headers and data rows containing specific expected values.

Changes

Cohort / File(s) Summary
Test Module Addition
divref/tests/tools/test_compute_haplotype_statistics.py
New test file exercising the compute_haplotype_statistics tool. Verifies output TSV files (HGDP and gnomAD) are created with expected column headers and validates row counts and parsed values for frequency cutoffs and window sizes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A test hops in with care so keen,
Checking haplotypes, frequencies seen,
TSV files, headers bright,
Data rows counted just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a happy-path test for the compute_haplotype_statistics tool, which matches the changeset.
Linked Issues check ✅ Passed The pull request directly addresses issue #24 by implementing a comprehensive test for compute_haplotype_statistics that validates headers, row counts, and expected haplotype/variant counts.
Out of Scope Changes check ✅ Passed All changes are focused on adding test coverage for compute_haplotype_statistics; no unrelated modifications to production code or other features are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch am_test_compute_haplotype_statistics

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Add tests for compute_haplotype_statistics

1 participant