From f2e8c637307146a6796c56b0d654427f9c567aa8 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 7 Jul 2024 15:17:48 +0200 Subject: precompute: making sure order is correct - validating results --- scripts/precompute/list-traits-to-compute.scm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'scripts/precompute/list-traits-to-compute.scm') diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm index 61ce755..fbe89a6 100755 --- a/scripts/precompute/list-traits-to-compute.scm +++ b/scripts/precompute/list-traits-to-compute.scm @@ -131,7 +131,8 @@ The following is produced by gemma-wrapper as metadata (time . ,(date->string (time-utc->date (current-time)))))) (data . ((,id . - ((probesetfreeze-id . ,probesetfreeze-id) + ((group . "BXD") + (probesetfreeze-id . ,probesetfreeze-id) (probeset-id . ,probeset-id) (name . ,name) (trait-name . ,trait-name) @@ -150,6 +151,7 @@ The following is produced by gemma-wrapper as metadata ;; (let [(bxd-strains (memo-bxd-strain-id-names #:used-for-mapping? #t))] (display "writing-phenotypes...") (define (run-list-traits-to-compute db num prev-id) + ;; ---- Build a query to collect num traits (let* [(count (if (< batch-size num) batch-size num)) @@ -164,7 +166,7 @@ The following is produced by gemma-wrapper as metadata ] (display query) (dbi-query db query) - ;; ---- Walk each resulting trait + ;; ---- Walk each resulting trait and build a hash of data-id and list of trait values (let [(id-traits (get-rows db '())) (nrecs '())] (for-each (lambda (r) @@ -178,21 +180,20 @@ The following is produced by gemma-wrapper as metadata )] (set! nrecs (assoc-set! nrecs data-id lst)))) id-traits) - ;; --- create the json output as a file - (for-each (lambda (r h) + ;; --- create the json output as a file by walking traits and hits + (for-each (lambda (h) (let* [ + (id (hit-data-id h)) (probeset-id (hit-probeset-id h)) - ;; (data-id-str (int-to-string id)) (probesetfreeze-id (hit-probesetfreeze-id h)) (name (dataset-name db probesetfreeze-id)) (trait (get-trait db probeset-id)) (trait-name (assoc-ref trait "Name")) + (recs (assoc-ref nrecs id)) ] - (match r - ((id . recs) (if (has-bxd? recs) + (if (has-bxd? recs) (write-json-ld id name trait trait-name probesetfreeze-id probeset-id recs) - )) - ))) nrecs hits) + ))) hits) (if (> rest 0) (run-list-traits-to-compute db rest (first (reverse data-ids)))) ;; start precompute ))) -- cgit v1.2.3