refactor: flip default to new AncestryModel + cleave legacy (round 6) - #250
Merged
Merged
Conversation
get_common_snps/get_raw_files write side-effect files (.snplist, _flip.*, .log) next to the ref_panel/geno_path prefix they receive. The ref21_22_bfile and geno21_22_pfile fixtures were returning the committed golden/ prefix directly, so every test run dirtied the committed source tree with untracked plink byproducts. Copy the golden inputs into a tmp_path_factory dir and return that prefix instead; golden/ stays read-only. ref21_22_labels is read-only (no writes next to it) and is left unchanged.
Replace legacy-oracle tests in test_cohort.py with golden tests that compare split_cohort_by_ancestry output against committed fixtures (split_EUR/AFR pfiles, cohort_pruned_samples.parquet) instead of running genotools.ancestry.legacy.Ancestry at test time. Fixtures were generated once via a scratchpad script that asserted new==legacy for labels, pruned samples, and genotype content (compare_genotypes) before being committed, so the tests no longer import legacy and will survive its deletion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Round 6 of the refactor-hardening effort. Makes
refactor/maina legacy-free candidate for the real-data parity gate by flipping the default engine to the newAncestryModeland deleting the dead legacy modules.genotools/run_pipelinenow always use the newAncestryModelpath. Removed theuse_new_ancestryA/B switch, themain_new()entry point +genotools-newconsole script, the legacy_run_ancestry_predictionmethod, and theself._ancestry/from ..ancestry.legacy import Ancestrywiring.genotools/ancestry/legacy.py(no longer imported after the flip), the orphangenotools/gwas.py(shadowed by thegwas/package), and the obsoletetests/scripts/test_ancestry_ab.py.new == legacy(incl. split genotype content viacompare_genotypes); committed tests carry zero legacy imports. Input fixtures are staged into a temp dir per run so the committedgolden/dir stays read-only.upfront_checkskip-gap: re-implemented legacy's data-driven step auto-skips (deferred in round 5) ascore/validation.py::validate_inputreturning a typedValidationDecisions; the runner applies them (_filter_steps_by_decisions+ afilter_controlsoverride). The het-skip quirk (triggers on variant countvar.shape[0] < 50despite the "50 samples" warning text) is preserved intentionally for parity.validate_inputtakes primitive request flags to keepcore/decoupled fromcli/.Design + plan:
docs/superpowers/specs/2026-07-20-flip-default-cleave-legacy-design.md,docs/superpowers/plans/2026-07-20-flip-default-cleave-legacy.md.Still deferred to Phase 5/6:
genotools/utils.py+genotools/imputation.py(kept as a pair —imputation.pyimportsutils.shell_do) andcontainer/.Test plan
.venv-stablebaseline; QC + GWAS)genotools-new/use_new_ancestry/ancestry.legacy/ legacy_run_ancestry_prediction/gwas.pyreferences remain ingenotools/genotools --ancestryon synthetic data trained a newAncestryModel(GridSearchCV + UMAP) → produced split pfiles (AFR/EUR/CAH), JSON, and a saved model dir