aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn/data/dataset.scm23
-rw-r--r--gn/data/hits.scm2
-rwxr-xr-xscripts/precompute/precompute-hits.scm22
3 files changed, 42 insertions, 5 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm
new file mode 100644
index 0000000..5e81d1e
--- /dev/null
+++ b/gn/data/dataset.scm
@@ -0,0 +1,23 @@
+(define-module (gn data dataset)
+ #:use-module (json)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
+ #:use-module (ice-9 iconv)
+ #:use-module (ice-9 receive)
+ #:use-module (ice-9 string-fun)
+ ;; #:use-module (gn db sparql)
+ #:use-module (dbi dbi)
+ #:use-module (gn db mysql)
+ #:use-module (gn data group)
+ #:use-module (gn util convert)
+ #:use-module (web gn-uri)
+
+ #:export (
+ dataset-name
+ ))
+
+(define (dataset-name db probesetfreeze-id)
+ (dbi-query db
+ (string-append
+ "select Name2 from ProbeSetFreeze where Id=" (int-to-string probesetfreeze-id) " limit 1;"))
+ (assoc-ref (get-row db) "Name2"))
diff --git a/gn/data/hits.scm b/gn/data/hits.scm
index a66eee5..f0a24f3 100644
--- a/gn/data/hits.scm
+++ b/gn/data/hits.scm
@@ -17,5 +17,5 @@
))
(define (get-next-hit-for-precompute db prev-id)
- (dbi-query db (string-append "select Locus, DataId, ProbeSetId from ProbeSetXRef where DataId>" (int-to-string prev-id) " AND Locus_old is NULL ORDER BY DataId LIMIT 1"))
+ (dbi-query db (string-append "select Locus, DataId, ProbeSetId, ProbeSetFreezeId from ProbeSetXRef where DataId>" (int-to-string prev-id) " AND Locus_old is NULL ORDER BY DataId LIMIT 1"))
(get-row db))
diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm
index 0088431..d8170db 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 dataset)
(gn data hits)
(gn data strains)
(gn util convert)
@@ -35,7 +36,7 @@
;(newline)
(define bxd-strains (bxd-strain-id-names #:map? #t))
- ;(display (assoc 64728 bxd-strains))
+ ;(display (assoc 64728 bxd-strains))
;(newline)
;(newline)
;(dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3")
@@ -47,15 +48,26 @@
;; ---- get first available dataset for precompute:
;; @@ order by dataid - recurse
+ (define (get-trait-name db probeset-id)
+ (dbi-query db (string-append "select Name,Symbol from ProbeSet where Id=" (int-to-string probeset-id) " limit 1"))
+ (get-row db)
+ )
(define (run-precompute db prev-id)
(let* [(hit (get-next-hit-for-precompute db prev-id))
- (data-id (assoc-ref hit "DataId"))]
+ (data-id (assoc-ref hit "DataId"))
+ (data-id-str (int-to-string data-id))
+ (probesetfreeze-id (assoc-ref hit "ProbeSetFreezeId"))
+ (probeset-id (assoc-ref hit "ProbeSetId"))
+ (trait (get-trait-name db probeset-id))
+ (trait-name (assoc-ref trait "Name"))
+ ]
(display hit)
(display data-id)
(newline)
+ (define name (dataset-name db probesetfreeze-id))
;; ---- Get strains and phenotypes for this dataset
- (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" (int-to-string data-id)))
+ (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" data-id-str))
(define traits (get-rows-apply db
(lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "value")))
'()))
@@ -71,10 +83,12 @@
traits))
(if (= 0 (length non-bxd))
(begin
- (display "WE HAVE OUR BXD DATASET for precompute!\n")
+ (if name
+ (display (string-append "WE HAVE OUR BXD DATASET " name " and trait " trait-name " for precompute!\n")))
(display data-id)
(display traits)
(newline)
+
))
(run-precompute db data-id)
))