From 80b1cd2379d83daf72963f2a634e67edc005dacb Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 28 Jun 2024 05:31:26 -0500 Subject: Need to get at dataset-id - next to trait-id --- scripts/precompute/list-traits-to-compute.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm index 2c48d83..08ed48d 100755 --- a/scripts/precompute/list-traits-to-compute.scm +++ b/scripts/precompute/list-traits-to-compute.scm @@ -82,9 +82,11 @@ When that is the case we might as well write the phenotype file because we have ) -(define (write-json-ld id recs) +(define (write-json-ld id dataset-id recs) ;; see also https://www.w3.org/2018/jsonld-cg-reports/json-ld/ (display id) + (display ":") + (display dataset-id) (newline) (let* [(traits (map (lambda (r) (match r @@ -98,8 +100,10 @@ When that is the case we might as well write the phenotype file because we have (steps . ()) (sha256 . ((input-traits . ,sha256))) (time . ,(date->string (time-utc->date (current-time)))))) - (traits . - ((,id . ,traits)))))] + (data . + ((,id . + ((dataset . ,dataset-id) + (traits . ,traits)))))))] (call-with-output-file (string-append (number->string id) ".json") (lambda (port) (put-string port (scm->json-string json-data)))) @@ -110,6 +114,7 @@ When that is the case we might as well write the phenotype file because we have (lambda (db) (begin ;; (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) (let* [(count (if (< batch-size num) batch-size @@ -117,15 +122,14 @@ When that is the case we might as well write the phenotype file because we have (rest (- num count)) (hits (get-precompute-hits db prev-id count)) (data-ids (map (lambda (hit) - (let* [(data-id (assoc-ref hit "DataId")) - ; (data-id-str (int-to-string data-id)) - ] + (let* [(data-id (assoc-ref hit "DataId"))] data-id)) hits)) (data-str-ids (map (lambda (id) (string-append "Id=" (int-to-string id))) data-ids)) (data-ids-query (string-join data-str-ids " OR ")) (query (string-append "SELECT Id,StrainId,value FROM ProbeSetData WHERE " data-ids-query)) ] + (display query) (dbi-query db query) (let [(id-traits (get-rows db '())) (nrecs '())] @@ -143,7 +147,7 @@ When that is the case we might as well write the phenotype file because we have (for-each (lambda (r) (match r ((id . recs) (if (has-bxd? recs) - (write-json-ld id recs) + (write-json-ld id (findit data-ids) recs) )) )) nrecs) (if (> rest 0) -- cgit v1.2.3