From e912c87deaf220fd5fce1299d669e8fa992b5338 Mon Sep 17 00:00:00 2001 From: Pjotr Date: Wed, 7 Oct 2026 10:42:51 +0000 Subject: * src/routes/search.rs (search): add lod, locus, and sort/order. Search hits gain `lod` (lrs / 4.61) and `locus` (the peak marker name, looked up in PublishXRef in one batched query; null when the database is unavailable). `sort=lrs|lod` with `order=asc|desc` ranks hits: gn3 is asked for its first 1000 matches, those are ranked, then `limit` applies. * src/db.rs (LRS_PER_LOD, lod, get_publish_loci): add the shared LRS-to-LOD constant and the locus lookup; TraitInfo and ProbeSetInfo gain `lod`, computed in SQL from the same constant. * tests/search.rs, test/python/test_search.py: add the "highest LOD, locus marker and additive effect for serotonin in BXD male midbrain" scenario over a recorded production fixture, plus sort/order tests. * tests/group_trait_info.rs, tests/dataset_probeset_info.rs and their Python mirrors: assert lod (and locus for trait 17985). * README.md (Endpoints): document sort, order, lod and locus. Co-Authored-By: Claude Sonnet 5.5 --- test/python/test_group_trait_info.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/python/test_group_trait_info.py') diff --git a/test/python/test_group_trait_info.py b/test/python/test_group_trait_info.py index d5a0761..1e4fab8 100644 --- a/test/python/test_group_trait_info.py +++ b/test/python/test_group_trait_info.py @@ -36,6 +36,21 @@ class GroupTraitInfoTest(ServerTestCase): finally: conn.close() + def test_group_trait_info_reports_lod_and_locus(self): + # The "highest LOD ... serotonin in BXD male midbrain" trait: see + # test_search.py. `lod` is `lrs` / 4.61. + if not database_reachable(): + self.skipTest("no database on 127.0.0.1:3306") + + response, body = self.get("/groups/BXD/traits/17985") + self.assertEqual(response.status, 200) + + info = json.loads(body) + self.assertEqual(info["locus"], "rsm10000012461") + self.assertAlmostEqual(info["lod"], info["lrs"] / 4.61) + self.assertAlmostEqual(info["lod"], 2.603, places=3) + self.assertAlmostEqual(info["additive"], -1.3041, places=4) + def test_group_trait_info_bxd_returns_phenotype_and_publication(self): if not database_reachable(): self.skipTest("no database on 127.0.0.1:3306") -- cgit 1.4.1