aboutsummaryrefslogtreecommitdiff
path: root/scripts/precompute
diff options
context:
space:
mode:
authorPjotr Prins2023-11-19 14:53:12 +0100
committerPjotr Prins2023-11-19 14:53:12 +0100
commitcd868747703585661efac3b85a423b6dae9b71c2 (patch)
tree1eb7eb14514d7a127a16aa7fcf4bd0a26a4f9292 /scripts/precompute
parentb1db013cc01c94e27edf982be9b027a2b0bb9712 (diff)
downloadgn-guile-cd868747703585661efac3b85a423b6dae9b71c2.tar.gz
Iterate precompute datasets
Diffstat (limited to 'scripts/precompute')
-rwxr-xr-xscripts/precompute/precompute-hits.scm62
1 files changed, 35 insertions, 27 deletions
diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm
index 28dabc9..0088431 100755
--- a/scripts/precompute/precompute-hits.scm
+++ b/scripts/precompute/precompute-hits.scm
@@ -6,6 +6,7 @@
(use-modules (dbi dbi)
(gn db mysql)
+ (gn data hits)
(gn data strains)
(gn util convert)
(rnrs base)
@@ -34,8 +35,8 @@
;(newline)
(define bxd-strains (bxd-strain-id-names #:map? #t))
- (display (assoc 64728 bxd-strains))
- (newline)
+ ;(display (assoc 64728 bxd-strains))
+ ;(newline)
;(newline)
;(dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3")
;(let [(row (get-row db))]
@@ -44,31 +45,38 @@
;(db-check2 db)
;(newline)
;; ---- get first available dataset for precompute:
- (dbi-query db "select Locus, DataId, ProbeSetId from ProbeSetXRef where Locus_old is NULL LIMIT 1")
- (define hit (get-row db))
- (display hit)
- (define data-id (assoc-ref hit "DataId"))
- (display data-id)
- (newline)
- ;; ---- Get strains and phenotypes for this dataset
- (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" (int-to-string data-id)))
- (define traits (get-rows-apply db
- (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "value")))
- '()))
- ;; ---- Now we need to make sure that all strains belong to BXD
- (define non-bxd (fold
- (lambda (strain lst)
- (let ([id (car strain)])
- (if (assoc id bxd-strains)
- lst
- (append lst `(,id)))))
+ ;; @@ order by dataid - recurse
+
+
+ (define (run-precompute db prev-id)
+ (let* [(hit (get-next-hit-for-precompute db prev-id))
+ (data-id (assoc-ref hit "DataId"))]
+ (display hit)
+ (display data-id)
+ (newline)
+ ;; ---- Get strains and phenotypes for this dataset
+ (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" (int-to-string data-id)))
+ (define traits (get-rows-apply db
+ (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "value")))
+ '()))
+ ;; ---- Now we need to make sure that all strains belong to BXD
+ (define non-bxd (fold
+ (lambda (strain lst)
+ (let ([id (car strain)])
+ (if (assoc id bxd-strains)
+ lst
+ (append lst `(,id)))))
- '()
- traits))
- (if (= 0 (length non-bxd))
- (begin
- (display "WE HAVE OUR BXD DATASET for precompute!")
- (display traits)
- (newline)
+ '()
+ traits))
+ (if (= 0 (length non-bxd))
+ (begin
+ (display "WE HAVE OUR BXD DATASET for precompute!\n")
+ (display data-id)
+ (display traits)
+ (newline)
+ ))
+ (run-precompute db data-id)
))
+ (run-precompute db 0)
)))