Skip to content

test(cn,bloodtype,traits): check copy number, blood groups and the traits table in cargo test - #452

Open
geiresx wants to merge 7 commits into
GeiserX:mainfrom
geiresx:pgp/port-tests-cn-traits
Open

geiresx wants to merge 7 commits into
GeiserX:mainfrom
geiresx:pgp/port-tests-cn-traits

Conversation

@geiresx

@geiresx geiresx commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #411. Settles D1 (no Python in 1.0.0) for four test files, and keeps the blood-group, HPA and HNA rows of D3 under test.

Problem

Four Python files tested og cn, og bloodtype and og traits by running the binary as a subprocess: tests/test_hba_copy_number.py, tests/test_bloodtype_report.py, tests/test_bloodtype_hpa_hna.py and tests/test_traits_table.py, about 1,050 lines. 1.0.0 ships without Python, so these checks had to move. test_traits_table.py was also a tool: the e2e case traits-panel-1 and the "Adding a row" steps of the traits page ran its --fasta and --online modes.

Fix

Every check moves into cargo test, through each tool's own command line, in process. The four Python files are deleted.

Python check (on main) Now
test_hba_copy_number.py, all 21 checks: 4, 3, 2 and 5 genes, an estimate between counts, low or disagreeing flanks, the MAPQ 0 guard (none, 1%, 3%), no gene at all, the command line's refusals, the demo's HBA table rust/crates/og-cn/tests/port_tests_cn_traits.rs, 19 tests
test_bloodtype_report.py sections 1 to 14: markers against the rules, nothing planted, ABO, RhD from depth, Duffy and Kell, the VCF edge cases, a BAM without some contigs, null-row and HPA orientation, every null and rare HPA row positive and negative, gVCF records and blocks, null alleles, common variants, another ALT at a null row, two null copies rust/crates/og-bloodtype/tests/port_tests_cn_traits.rs, s01 to s14
test_bloodtype_hpa_hna.py sections 1 to 4: HPA and HNA sites at their GRCh38 positions, two-allele antigens at 0/0, 0/1 and 1/1, the meaning of a missing antigen, HNA-1 same file, s15 to s18
test_traits_table.py schema part: at least 30 rows, og traits check passes, a planted bad row fails rust/crates/og-steps/tests/traits_table.rs, 3 tests
test_traits_table.py --fasta and --online a new verb, og dev traits-sources (rust/crates/og-dev/src/traits_sources.rs), with unit tests on a synthetic FASTA and canned PubMed and dbSNP answers

The bloodtype test reads assets/bloodtype_markers.tsv with its own parser, not the crate's, so a reader bug cannot hide a table bug.

Files outside the three test paths, each needed by the switch or the deletion:

  • rust/crates/og-dev/src/traits_sources.rs, rust/crates/og-dev/src/lib.rs, rust/og/src/main.rs: the new og dev traits-sources verb and its usage line.
  • tests/e2e/traits-panel-1.sh: runs og dev traits-sources where it ran the Python file. Same checks, same controls.
  • docs/42-traits.md: the "Adding a row" steps name og traits check and og dev traits-sources.
  • docs/35-paralogs.md, docs/cn-loci.md, tests/demo/make_demo_sample.py, assets/traits.tsv (a header comment): they named the deleted files.
  • CHANGELOG.md: one line.

No pipeline output, option or file name changes.

Decision: the e2e scope table does not list rust/ paths for any case, so a later change to traits_sources.rs alone does not run traits-panel-1. Python's tests/test_traits_table.py had the same gap. This PR keeps the scope rules as they are; widening them is the e2e scope's own change.

How it was checked

  • Red first. Commit 24f5d15 planted four faults: the HBA row's MAPQ 0 guard set to 0, KEL_02N03 with REF and ALT swapped, the lactase row's REF set to N, and an off-by-one in the FASTA read of og dev traits-sources. Guard's cargo test --workspace --no-fail-fast went red on each, and on nothing else: https://github.com/GeiserX/OwnGenome/actions/runs/43745565116/job/132907983428 (step "cargo test"). The six red targets: og-bloodtype port_tests_cn_traits (s08), og-cn port_tests_cn_traits (3 tests) and its lib (hba_counts_and_guards), og-dev lib (3 traits_sources tests), og-steps traits_table (the_table_passes_og_traits_check) and its lib (4 traits tests that read the shipped table). The next commit reverts them; the tree is the same as before the plant.
  • cargo fmt --check, cargo clippy --workspace --all-targets --all-features -D warnings and cargo doc -D warnings pass.
  • The table part of traits-panel-1 ran on the fixture reference with the new verb: 25 rows checked against the FASTA, 38 PubMed ids and 36 rsIDs looked up, all pass; the planted copy fails and names both the wrong base and the missing PubMed id.
  • Time. The four Python files took 3.0 s together on main (0.16 s, 1.54 s, 0.17 s, 1.12 s), each starting og many times. The cargo tests run in about 2.7 s (og-bloodtype 2.5 s, og-cn under 0.1 s, og-steps and og-dev under 0.1 s).
  • Upstream fast checks on the final head: FAST_CHECKS_LINE.

Beads: D1, D3.

The 21 checks of tests/test_hba_copy_number.py (four, three, two and five
genes, the not-assessed cases, the MAPQ 0 guard, the command line's refusals
and the demo's HBA table) now run in og-cn's cargo test through og cn's
command line, in process. The Python file is gone; the docs that named it
name the cargo test.

Bead: D1
The checks of tests/test_bloodtype_report.py (red cell systems, RhD from
depth, the VCF edge cases, null-row orientation, every null and rare HPA row
positive and negative, gVCF records and blocks) and of
tests/test_bloodtype_hpa_hna.py (platelet and neutrophil sites, two-allele
antigens, meanings, HNA-1) now run in og-bloodtype's cargo test through
og bloodtype's command line, in process. The marker table is read by the
test itself, not by the crate's reader. Both Python files are gone.

Bead: D1
Bead: D3
…sources

The schema part of tests/test_traits_table.py (at least 30 rows, og traits
check passes, a planted bad row fails) runs in og-steps' cargo test. Its
--fasta and --online modes, which the e2e case traits-panel-1 and the
curation guide in docs/42-traits.md use, are a new verb, og dev
traits-sources, with unit tests on a synthetic FASTA and canned PubMed and
dbSNP answers. The Python file is gone.

Bead: D1
Temporary: the HBA row's MAPQ 0 guard at 0, KEL_02N03 with REF and ALT
swapped, the lactase row's ref N, and an off-by-one in og dev
traits-sources' FASTA read. Each must turn its crate's cargo test red in
CI; the next commit reverts this one.

Bead: D1
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9078a1d and 6a5fe7f.

Files ignored due to path filters: 1

  • assets/traits.tsv is excluded by !**/*.tsv
Files selected for processing: 16

  • CHANGELOG.md
  • docs/35-paralogs.md
  • docs/42-traits.md
  • docs/cn-loci.md
  • rust/crates/og-bloodtype/tests/port_tests_cn_traits.rs
  • rust/crates/og-cn/tests/port_tests_cn_traits.rs
  • rust/crates/og-dev/src/lib.rs
  • rust/crates/og-dev/src/traits_sources.rs
  • rust/crates/og-steps/tests/traits_table.rs
  • rust/og/src/main.rs
  • tests/demo/make_demo_sample.py
  • tests/e2e/traits-panel-1.sh
  • tests/test_bloodtype_hpa_hna.py
  • tests/test_bloodtype_report.py
  • tests/test_hba_copy_number.py
  • tests/test_traits_table.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Reverts the previous commit: the ported tests went red on each planted
control in CI and are green without them.

Bead: D1
@geiresx

geiresx commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

2 participants