aboutsummaryrefslogtreecommitdiff
path: root/scripts/precompute
diff options
context:
space:
mode:
authorPjotr Prins2024-05-13 11:42:36 +0200
committerPjotr Prins2024-05-13 11:42:36 +0200
commit8294b95324af7cb86b4abec6ee9d09b8684f137e (patch)
tree16be6a2372887472f9e2f9eddca084dfee9bbc4d /scripts/precompute
parentbbbd8742852984e44c934d5389a12bafcf00df99 (diff)
downloadgn-guile-8294b95324af7cb86b4abec6ee9d09b8684f137e.tar.gz
Start on json output for strains
Diffstat (limited to 'scripts/precompute')
-rwxr-xr-xscripts/precompute/list-traits-to-compute.scm32
1 files changed, 19 insertions, 13 deletions
diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm
index 37b3e6e..07e80e9 100755
--- a/scripts/precompute/list-traits-to-compute.scm
+++ b/scripts/precompute/list-traits-to-compute.scm
@@ -69,10 +69,17 @@ When that is the case we might as well write the phenotype file because we have
; (rnrs base)
(ice-9 getopt-long)
(ice-9 match)
+ (json)
(srfi srfi-1)
)
+(define (write-json id recs)
+ (display id)
+ (newline)
+ (display (scm->json (reverse recs)))
+ )
+
(define (write-phenotypes first-id num batch-size)
(call-with-db
(lambda (db)
@@ -94,27 +101,26 @@ When that is the case we might as well write the phenotype file because we have
(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 '())]
(for-each (lambda (r)
(let* [(data-id (assoc-ref r "Id"))
- (strain-id (assoc-ref r "StrainId"))
- (value (assoc-ref r "value"))
- (has-lst (assoc-ref nrecs data-id))
- (lst (if has-lst
- (acons strain-id value has-lst)
- '())
- )]
+ (strain-id (assoc-ref r "StrainId"))
+ (value (assoc-ref r "value"))
+ (has-lst (assoc-ref nrecs data-id))
+ (lst (if has-lst
+ (acons strain-id value has-lst)
+ '())
+ )]
(set! nrecs (assoc-set! nrecs data-id lst))))
id-traits)
(for-each (lambda (r)
- (if (has-bxd? (cdr r))
- (begin
- (display (car r))
- (newline))
- )) nrecs)
+ (match r
+ ((id . recs) (if (has-bxd? recs)
+ (write-json id recs)
+ ))
+ )) nrecs)
(if (> rest 0)
(run-list-traits-to-compute db rest (first (reverse data-ids)))) ;; start precompute
)))