Add 128-bit genome encoding layer#2
Open
Spbd1 wants to merge 1 commit into
Open
Conversation
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.
Motivation
0 <= raw < 2**128to avoid silent corruption.random_genomecall sites.Description
pishiegen/genome/schema.pycontainingFieldSpec,FIELD_SPECS,FIELD_ORDER, and constantsGENOME_BITS,GENOME_MIN, andGENOME_MAX, with inclusive bit-range docstrings for each named field.pishiegen/genome/encoding.pyimplementingextract_bits,set_bits,validate_raw_genome, and a frozenGenome(raw: int)dataclass withvalidate(),get_field(),set_field(), andto_dict()methods and full validation.pishiegen/genome/decoder.pywithdecode_genome()that accepts either aGenomeinstance or a raw integer and returns the deterministic dictionary of decoded fields.pishiegen/genome/random_genome.pyproviding a seedable generator that returns aGenomewithGENOME_BITSrandom bits and a small module-wrapper to keepfrom pishiegen.genome import random_genomecall sites callable for legacy code that expects the older gene-list generator.tests/test_genome_encoding.pycovering valid range checks, field extraction correctness, non-corruptingset_field, and reproducible random genomes with a seed, plus docstrings in new modules describing bit ranges and intent.Testing
python -m pytest -qandPYTHONPATH=. pytest -q, and the test runs completed successfully (all tests passed).tests/test_genome_encoding.py, which passed and verifies range validation, extraction/setting semantics, and seeded reproducibility.Codex Task