From 7631cf515ffe1a81424aa53ab7052a61a3ff2b4d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 5 Oct 2026 15:25:22 +0000 Subject: Add GET /groups/{group}/case-attributes Per-strain metadata beyond genotype/phenotype data (age, sex, treatment, etc.), backed by MariaDB CaseAttribute/CaseAttributeXRefNew. Combines GeneNetwork3's separate /case-attribute/{id}/names and /case-attribute/{id}/values (gn3.api.case_attributes) into one response -- neither list is large enough on its own to need splitting. This is the only one of GeneNetwork2/3/gn-guile with the concept at all: GeneNetwork2 delegates to GeneNetwork3 rather than storing case attributes itself, and gn-guile doesn't have it. db::get_group_case_attributes returns {names: [...], values: [{strain, case_attributes: {...}}]}; values is built by folding adjacent (strain, attribute, value) rows (ordered by strain name) rather than grouping afterwards, since SQL already guarantees the adjacency. Found and fixed a real bug while verifying this live: GeneNetwork3's own query joins CaseAttribute to CaseAttributeXRefNew on CaseAttributeId alone, but CaseAttributeId is not unique across groups -- it's a shared vocabulary (id 37 means "Epoch" for dozens of unrelated groups simultaneously); the actual key is (InbredSetId, CaseAttributeId). Confirmed against this database: without also joining on InbredSetId, BXD's result included a spurious "Strain": "Live" attribute belonging to a different, unrelated group. Fixed on genenetwork4's side by adding the missing join condition. A group with no case attributes defined returns 200 with both lists empty, not a 404 (the group itself exists) -- verified against LXS, a real group with zero CaseAttribute rows. tests/group_case_attributes.rs and its Python mirror cover BXD's 4 real attributes (asserting each strain has exactly those 4, not more, to catch the join bug above), the empty-group case, missing token, and unknown group. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index f524429..46c4211 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,6 +63,7 @@ pub fn app() -> Router { .routes(routes!(routes::groups::group_trait_info)) .routes(routes!(routes::groups::group_traits)) .routes(routes!(routes::groups::group_datasets)) + .routes(routes!(routes::groups::group_case_attributes)) .routes(routes!(routes::datasets::dataset_by_name)) .routes(routes!(routes::datasets::dataset_probesets)) .routes(routes!(routes::datasets::dataset_probeset_info)) -- cgit 1.4.1