Cohorts: run_cohort — N subjects per run - #8
Merged
Conversation
…s + unique headers
…idge-hash, mid-loop failure safety
…st allele-weights exclusion
…ct mapping/bytes counts; empty-export schema
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
Adds
Experiment.run_cohort(genotypes, ...)— run N subjects, each with its own diploidGenotype, in one call. It is a Python loop around the existing single-subject genotype path (with_genotype→compile→run_records): each subject is compiled and run independently, records are tagged withsubject_idand given a namespacedsequence_id, and the per-subjectSimulationResult(with its own refdata) is collected into a newCohortResult. Follow-on #3 of the genotype roadmap.Python-only — zero
engine_rs/changes. No new engine behavior; orchestration over already-correct per-subject behavior.What's included
Experiment.run_cohort(genotypes, *, n_per_subject=1, seed=0, counts=None, strict=False, expose_provenance=False, validate_records=False, allow_curatable_refdata=None)— up-front validation, deterministic per-subject sub-seeds, clone-per-subject (copy.copy, never mutates the base experiment), per-subjectwith_metadatastamping.src/GenAIRR/cohort.py—CohortSubjectResult(frozen:subject_id,genotype,result,refdata,seed,count) andCohortResult: derived.subject_ids/.genotypes/.results,.result_for/.refdata_for, independent.records, combined.to_dataframe/.to_csv/.to_fasta(union columns; unique>{sequence_id}FASTA headers),__len__. Per-subject refdata stored explicitly (whichSimulationResultdoes not preserve).n_per_subjectfor all, or a parallelcountslist for varied repertoire sizes (incl.0— subject present with zero records). Mappings/str/bytesrejected.subject_0..N-1; mixed/duplicate (incl.1vs"1") raise. Resolved on snapshots only — caller genotypes never mutated.Behavior
with_genotype,restrict_alleles,recombine(*_allele_weights=...); not combined withreceptor_revision/clonal forks (parity with the single-subject genotype path). Reserved metadata keys (subject_id/sequence_id/haplotype) raise.validate_recordsand novel-allele truth calls correct even when subjects differ.seed.Test plan
tests/test_genotype_cohorts.py(21 tests): CohortResult accessors + independence, union/FASTA export, subject-id + counts resolution, happy path, determinism, no-base-mutation (incl. mid-loop failure), counts override/zero, mutual exclusions, cartridge-hash, mixed novel/plain subjects + per-subject refdata, per-subject validate, with_metadata parity + collision guard, empty-export schema, end-to-end.engine_rs/changes.