Genotype population priors: Genotype.sample(...) - #6
Merged
Conversation
…ity (uniform prior)
…dation, usage_as_prior)
…ht viability, conditioned-HW docs - Fully validate allele_frequencies (nested + flat): unknown segment/gene/allele, non-Mapping / None / empty gene values, and usage_as_prior genes absent from the catalogue now raise instead of being silently ignored. (High) - Zero-weight chromosomes are never expressed: Genotype._is_viable requires a positive-weight complete haplotype, and the engine's SampleGenotypePass excludes zero-weight chromosomes from the viable set (no silent fall-back to a 0-weight chromosome). (High) - Docs: state that default ensure_viable=True yields HW *conditioned on viability*, not unconditional HW; tests pin conditioned vs unconditioned. - segments_to_sample rejects duplicates and is canonicalized to V/D/J order (order-invariant results). - Resample sub-seeds derived from a base RNG (no collision with seed+1). - Mapping checks at every layer -> clean ValueErrors (no leaked TypeError/AttributeError). - Perf: compute the cartridge content hash once and reuse across draws (no manifest recompute per resample).
4 tasks
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
Follow-on #1 to the merged genotype foundation. Adds
Genotype.sample(cfg, …)— draw a fully-specified diploid genotype from population priors instead of specifying every gene by hand.haplotype_deletion_prob) or assigned an allele from that gene's frequencies; homozygous/heterozygous/hemizygous/deleted emerge at the expected rates. Deterministic (seed).allele_usage); opt-inallele_frequencies="usage_as_prior"; segment-aware{segment:{gene:{allele:weight}}}(+ flat{gene:…}when unambiguous); zero weight excludes an allele; full name/weight validation.segments_to_samplemust cover required segments (no half-specified genotypes);ensure_viable=True(default) re-draws deterministically up tomax_resamplesuntil a complete haplotype exists, else a clearValueError;ensure_viable=Falseopt-out.Test plan
mkdocs --strictclean. No engine/Rust changes.