aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2024-06-28 05:31:26 -0500
committerPjotr Prins2024-06-28 05:31:26 -0500
commit80b1cd2379d83daf72963f2a634e67edc005dacb (patch)
treee5840ac80372c518823198a8e92114a318f19cb8
parent1b37b7738a4c756503ceaaa2645592521abd86f3 (diff)
downloadgn-guile-80b1cd2379d83daf72963f2a634e67edc005dacb.tar.gz
Need to get at dataset-id - next to trait-idHEADmain
-rwxr-xr-xscripts/precompute/list-traits-to-compute.scm18
1 files 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)