aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn/data/hits.scm6
-rwxr-xr-xscripts/precompute/list-traits-to-compute.scm34
2 files changed, 24 insertions, 16 deletions
diff --git a/gn/data/hits.scm b/gn/data/hits.scm
index 88dee11..a7ba45a 100644
--- a/gn/data/hits.scm
+++ b/gn/data/hits.scm
@@ -20,20 +20,22 @@
update-precompute!
hit-data-id
hit-probeset-id
+ hit-probesetfreeze-id
))
(define-record-type <hit>
- (make-hit data-id probeset-id)
+ (make-hit data-id probeset-id probesetfreeze-id)
hit?
(data-id hit-data-id)
(probeset-id hit-probeset-id)
+ (probesetfreeze-id hit-probesetfreeze-id)
)
(define (get-precompute-hits db first-id num)
(dbi-query db (string-append "select Locus, DataId, ProbeSetId, ProbeSetFreezeId from ProbeSetXRef where DataId>" (int-to-string first-id) " AND Locus_old is NULL ORDER BY DataId LIMIT " (format #f "~d" num)))
(map (lambda (r)
- (make-hit (assoc-ref r "DataId") (assoc-ref r "ProbeSetId")))
+ (make-hit (assoc-ref r "DataId") (assoc-ref r "ProbeSetId") (assoc-ref r "ProbeSetFreezeId")))
(get-rows db '())
))
diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm
index 199f457..9a548b7 100755
--- a/scripts/precompute/list-traits-to-compute.scm
+++ b/scripts/precompute/list-traits-to-compute.scm
@@ -108,17 +108,20 @@ The following is produced by gemma-wrapper as metadata
!#
-(define (write-json-ld id dataset-id recs)
+(define (write-json-ld id name trait trait-name probeset-id recs)
;; see also https://www.w3.org/2018/jsonld-cg-reports/json-ld/
(display id)
(display ":")
- (display dataset-id)
+ (display name)
+ (display ":")
+ (display trait-name)
(newline)
(let* [(traits (map (lambda (r)
(match r
[(strain-id . value) (cons (bxd-name strain-id) value)]
))
(reverse recs)))
+ (uri (format #f "https://genenetwork.org/show_trait?trait_id=~a&dataset=~a" trait-name name))
(sha256 (sha-256->string (sha-256 (string->utf8 (scm->json-string traits)))))
(json-data `(("@context" . "https://genenetwork.org/resource")
(type . traits)
@@ -128,8 +131,11 @@ The following is produced by gemma-wrapper as metadata
(time . ,(date->string (time-utc->date (current-time))))))
(data .
((,id .
- ((dataset . ,dataset-id)
- (traits . ,traits)))))))]
+ ((probeset-id . ,probeset-id)
+ (name . ,name)
+ (trait-name . ,trait-name)
+ (traits . ,traits)
+ (uri . ,uri)))))))]
(call-with-output-file (string-append (number->string id) ".json")
(lambda (port)
(put-string port (scm->json-string json-data))))
@@ -172,19 +178,19 @@ The following is produced by gemma-wrapper as metadata
id-traits)
;; --- create the json output as a file
(for-each (lambda (r h)
- ;; (let* [;; (probeset-id (assoc-ref hit "ProbeSetId"))
- ;; (data-id (assoc-ref hit "DataId"))
- ;; (data-id-str (int-to-string data-id))
- ;; (probesetfreeze-id (assoc-ref hit "ProbeSetFreezeId"))
- ;; (trait (get-trait db probeset-id))
- ;; (trait-name (assoc-ref trait "Name"))
- ;; (name (dataset-name db probesetfreeze-id))
- ;; ]
+ (let* [
+ (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"))
+ ]
(match r
((id . recs) (if (has-bxd? recs)
- (write-json-ld id (hit-probeset-id h) recs)
+ (write-json-ld id name trait trait-name probeset-id recs)
))
- )) nrecs hits)
+ ))) nrecs hits)
(if (> rest 0)
(run-list-traits-to-compute db rest (first (reverse data-ids)))) ;; start precompute
)))