From b1db013cc01c94e27edf982be9b027a2b0bb9712 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 18 Nov 2023 12:33:22 +0100 Subject: Get first BXD dataset for precompute --- scripts/precompute/precompute-hits.scm | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm index a6617d9..28dabc9 100755 --- a/scripts/precompute/precompute-hits.scm +++ b/scripts/precompute/precompute-hits.scm @@ -7,14 +7,19 @@ (use-modules (dbi dbi) (gn db mysql) (gn data strains) + (gn util convert) (rnrs base) (ice-9 match) + (srfi srfi-1) ) ;; potentially you want to test connection with mysql client: ;; ;; mysql -uwebqtlout -pwebqtlout -A -h 127.0.0.1 -P 3306 db_webqtl -e "show tables;" ;; +;; for now update Locus_old with +;; +;; update ProbeSetXRef set Locus_old=NULL; (call-with-db (lambda (db) @@ -38,8 +43,32 @@ ; ) ;(db-check2 db) ;(newline) - ;; get first dataset for precompute - (dbi-query db "select ProbeSetId, Locus, DataId from ProbeSetXRef where Locus_old is NULL LIMIT 1") - (display (get-row db)) + ;; ---- 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))))) + + '() + traits)) + (if (= 0 (length non-bxd)) + (begin + (display "WE HAVE OUR BXD DATASET for precompute!") + (display traits) + (newline) + )) ))) -- cgit v1.2.3