about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-10-15 12:04:46 +0000
committerPjotr <wrk@bosa.lan>2026-10-15 12:04:46 +0000
commitacdcb3a7ddfdfadf91531599f87190c451fd8624 (patch)
treecfc9b9a381842b27ff98750ceaa93272c7a7aee0 /tests
parent6de7a3440048f870463f0c4ceb6efa86dc2d57da (diff)
downloadgenenetwork4-acdcb3a7ddfdfadf91531599f87190c451fd8624.tar.gz
rqtl: return marker rows positionally, columns in meta.columns
Same space-saving shape as the gemma commit: /compute/rqtl's markers
are now positional arrays (name, chr, pos, lod, plus any 4-way-cross
extra effect columns trailing) instead of one keyed object per row,
with the fixed column names in meta.columns.

Also fixes tests/gemma.rs, which still asserted the old keyed shape
from the gemma change -- missed in that commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/gemma.rs21
-rw-r--r--tests/rqtl.rs8
2 files changed, 21 insertions, 8 deletions
diff --git a/tests/gemma.rs b/tests/gemma.rs
index 0e0d313..6374023 100644
--- a/tests/gemma.rs
+++ b/tests/gemma.rs
@@ -134,16 +134,27 @@ async fn compute_gemma_maps_a_qtl_from_the_bxd_fixtures() {
     assert!(!rows.is_empty(), "expected at least one mapped marker");
     // BXD_snps.txt has 7320 markers; every one should have a row.
     assert_eq!(rows.len(), 7320);
-    let first = &rows[0];
-    assert!(first.get("chr").is_some(), "{first}");
-    assert!(first.get("rs").is_some(), "{first}");
+
+    // Rows are positional now; look up each column's index via
+    // meta.columns rather than a fixed offset, since it varies with lmm.
+    let envelope: Value = serde_json::from_slice(&bytes).unwrap();
+    let columns: Vec<&str> = envelope["meta"]["columns"]
+        .as_array()
+        .expect("meta.columns")
+        .iter()
+        .map(|c| c.as_str().unwrap())
+        .collect();
+    let index_of = |name: &str| columns.iter().position(|c| *c == name);
+    assert!(index_of("chr").is_some(), "{columns:?}");
+    assert!(index_of("rs").is_some(), "{columns:?}");
     // lmm defaults to 9 (GeneNetwork's convention); observed to behave
     // like LRT, carrying p_lrt rather than p_wald.
-    assert!(first.get("p_lrt").is_some(), "{first}");
+    assert!(index_of("p_lrt").is_some(), "{columns:?}");
+    let first = &rows[0];
+    assert!(first[index_of("chr").unwrap()].is_number(), "{first}");
 
     // The notes carry the exact gemma-wrapper invocations used, not
     // just a generic description.
-    let envelope: Value = serde_json::from_slice(&bytes).unwrap();
     let notes = envelope["notes"].as_array().unwrap();
     let kinship_note = notes.iter().find(|n| n.as_str().unwrap().starts_with("Kinship:"));
     let gwa_note = notes.iter().find(|n| n.as_str().unwrap().starts_with("GWA:"));
diff --git a/tests/rqtl.rs b/tests/rqtl.rs
index c341254..1364eee 100644
--- a/tests/rqtl.rs
+++ b/tests/rqtl.rs
@@ -62,12 +62,14 @@ async fn compute_rqtl_maps_a_qtl_from_the_bxd_riset_fixture() {
     let markers = data["markers"].as_array().unwrap();
     // The fixture has 6 markers (3 per chromosome, 2 chromosomes).
     assert_eq!(markers.len(), 6);
-    assert_eq!(markers[0]["name"], "rs31443144");
-    assert_eq!(markers[0]["chr"], "1");
-    assert!(markers[0]["lod"].as_f64().unwrap() >= 0.0);
+    // Rows are positional (name, chr, pos, lod); see meta.columns.
+    assert_eq!(markers[0][0], "rs31443144");
+    assert_eq!(markers[0][1], "1");
+    assert!(markers[0][3].as_f64().unwrap() >= 0.0);
     assert!(data["permutation"].is_null(), "nperm defaults to 0: {data}");
 
     let envelope: Value = serde_json::from_slice(&bytes).unwrap();
+    assert_eq!(envelope["meta"]["columns"], serde_json::json!(["name", "chr", "pos", "lod"]));
     let notes = envelope["notes"].as_array().unwrap();
     let rscript_note = notes.iter().find(|n| n.as_str().unwrap().starts_with("Rscript"));
     assert!(rscript_note.is_some(), "{notes:?}");