From 564fed3c6295b596fe9288fc674f70c1fa3a2a95 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 29 Jun 2024 04:29:06 -0500 Subject: for-each can take multiple lists, nice! --- scripts/precompute/list-traits-to-compute.scm | 35 ++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm index 08ed48d..5c3dfa3 100755 --- a/scripts/precompute/list-traits-to-compute.scm +++ b/scripts/precompute/list-traits-to-compute.scm @@ -81,6 +81,26 @@ When that is the case we might as well write the phenotype file because we have (srfi srfi-19) ; time ) +#! + +The following is produced by gemma-wrapper as metadata + + "meta": { + "type": "gemma-wrapper", + "version": "0.99.7-pre1", + "population": "BXD", + "name": "HC_U_0304_R", + "trait": "101500_at", + "url": "https://genenetwork.org/show_trait?trait_id=101500_at&dataset=HC_U_0304_R", + "archive_GRM": "46bfba373fe8c19e68be6156cad3750120280e2e-gemma-cXX.tar.xz", + "archive_GWA": "779a54a59e4cd03608178db4068791db4ca44ab3-gemma-GWA.tar.xz", + "dataid": 75629, + "probesetid": 1097, + "probesetfreezeid": 7 + } + +!# + (define (write-json-ld id dataset-id recs) ;; see also https://www.w3.org/2018/jsonld-cg-reports/json-ld/ @@ -131,6 +151,7 @@ When that is the case we might as well write the phenotype file because we have ] (display query) (dbi-query db query) + ;; ---- Walk each resulting trait (let [(id-traits (get-rows db '())) (nrecs '())] (for-each (lambda (r) @@ -144,12 +165,14 @@ When that is the case we might as well write the phenotype file because we have )] (set! nrecs (assoc-set! nrecs data-id lst)))) id-traits) - (for-each (lambda (r) - (match r - ((id . recs) (if (has-bxd? recs) - (write-json-ld id (findit data-ids) recs) - )) - )) nrecs) + ;; --- create the json output as a file + (for-each (lambda (r hit) + (let [(probeset-id (assoc-ref hit "ProbeSetId"))] + (match r + ((id . recs) (if (has-bxd? recs) + (write-json-ld id probeset-id recs) + )) + ))) nrecs hits) (if (> rest 0) (run-list-traits-to-compute db rest (first (reverse data-ids)))) ;; start precompute ))) -- cgit v1.2.3