From c49852be64533ad5deccfaf64a52017ba3744823 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 May 2024 04:12:58 -0500 Subject: Add json meta record --- scripts/precompute/list-traits-to-compute.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm index 75e121a..7e0660d 100755 --- a/scripts/precompute/list-traits-to-compute.scm +++ b/scripts/precompute/list-traits-to-compute.scm @@ -76,20 +76,26 @@ When that is the case we might as well write the phenotype file because we have (ice-9 textual-ports) (json) (srfi srfi-1) + (srfi srfi-19) ; time ) (define (write-json id recs) (display id) (newline) - (call-with-output-file (string-append (number->string id) ".json") - (lambda (port) - (put-string port (scm->json-string (map (lambda (r) + (let* [(traits (map (lambda (r) (match r [(strain-id . value) (cons (bxd-name strain-id) value)] )) - (reverse recs)))))) - ) + (reverse recs))) + (json-data `((meta . + ((id . ,id) + (time . ,(date->string (time-utc->date (current-time)))))) + (traits . ,traits)))] + (call-with-output-file (string-append (number->string id) ".json") + (lambda (port) + (put-string port (scm->json-string json-data)))) + )) (define (write-phenotypes first-id num batch-size) (call-with-db -- cgit v1.2.3