diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-14 03:45:38 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-14 03:45:38 +0000 |
| commit | f8b34ca82b40f9eda65fa3abab580a0ca8e66f49 (patch) | |
| tree | 3c4acb2d5cf4d8694c0851441a0ba51f6707b180 /src | |
| parent | 5c6f36f6d0155d73e3fb8d24aee1a6827a77ae97 (diff) | |
| download | genenetwork4-f8b34ca82b40f9eda65fa3abab580a0ca8e66f49.tar.gz | |
groups: the design in /groups/{group}, and a drift check against GN2's ParInfo
Two follow-ups to the parental-design endpoint.
/groups/{group} now carries the headline in its notes -- "Parental design:
C57BL/6J (maternal) x DBA/2J (paternal), F1s B6D2F1 / D2B6F1; a mapping excludes
the parents and F1s by default" -- plus a next link to the full design. "Which
cross is this?" is two strain names, and needing a second request to see them
was the only reason the endpoint had to be called first. A group with no
metadata says so in the same note, pointing at parents_and_f1s.json and at
`individuals.exclude`, rather than leaving the reader to wonder why nothing was
dropped.
The metadata is the same fact in two places (GN2's ParInfo, our JSON) and it
drifted once already, silently: the paternal/maternal labels were swapped
against GN2's unpacking, and nothing noticed because the exclusion rule takes
both strains regardless of role. scripts/check-parental-metadata.py parses
ParInfo with ast (no gn2 import) and compares it group by group, reporting
disagreements per role and treating groups the JSON knows but GN2 does not as
informational. tests/parental_metadata.rs runs it while a GN2 checkout is
present (GN2_CHECKOUT, or a sibling path) and skips once GN2 is retired -- at
which point the JSON is the only copy and there is nothing to drift from. It
reports 23 groups reproduced, 1 extra (BXD-Longevity).
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/groups.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/routes/groups.rs b/src/routes/groups.rs index e2ac7c7..dd59165 100644 --- a/src/routes/groups.rs +++ b/src/routes/groups.rs @@ -125,6 +125,45 @@ pub async fn group_by_name( .map_err(|e| ApiError::from_db(e, "group_by_name").with_request_id(rid.clone()))? .map(|detail| { let name = path_segment(&detail.name); + // The parental design is metadata a caller usually wants with the + // group itself: "which cross is this?" is answered by two strain + // names, not by a second request. The full design -- the F1s' + // individuals, what a mapping drops -- is the endpoint below. + let design = { + let directory = std::path::PathBuf::from(&Config::load().genotype_files_dir); + genotypes::parental_design(&directory, &detail.name, None, None) + }; + let design_note = { + let maternal = design + .maternal + .as_ref() + .map(|role| role.strain.clone()) + .unwrap_or_else(|| "unknown".to_string()); + let paternal = design + .paternal + .as_ref() + .map(|role| role.strain.clone()) + .unwrap_or_else(|| "unknown".to_string()); + let f1s: Vec<String> = design.f1s.iter().map(|role| role.strain.clone()).collect(); + if design.source == "metadata" { + format!( + "Parental design: {maternal} (maternal) x {paternal} (paternal){}; a \ + mapping excludes the parents and F1s by default (see \ + /groups/{name}/parents-and-f1s).", + if f1s.is_empty() { + String::new() + } else { + format!(", F1s {}", f1s.join(" / ")) + } + ) + } else { + format!( + "Parental design: not recorded for this group, so a mapping can only \ + drop individuals whose name contains `F1`; declare the parents in \ + parents_and_f1s.json or exclude them with `individuals.exclude`." + ) + } + }; Json( ctx.envelope(detail) .with_next( @@ -147,6 +186,11 @@ pub async fn group_by_name( &format!("/groups/{name}/genotypes"), "Genotype files this group can be mapped with, newest first", ) + .with_next( + &format!("/groups/{name}/parents-and-f1s"), + "The family's parental design: parents, F1s, and what a mapping drops", + ) + .with_note(&design_note) .with_links(crate::suggest::root_links()), ) }) |
