aboutsummaryrefslogtreecommitdiff
path: root/scripts/precompute/precompute-hits.scm
blob: 22bf2d72733bd3ee99056f0439a5aafec82fcd0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! Run from base dir with

.guix-shell -- guile -L . -s ./scripts/precompute/precompute-hits.scm

!#

(use-modules (dbi dbi)
             (gn db mysql)
             (rnrs base)
             (ice-9 match)
             )

;; 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;"
;;
(define db (dbi-open "mysql" "webqtlout:webqtlout:db_webqtl:tcp:127.0.0.1:3306"))
(db-check db)
(dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3")
(db-check db)
; (display (dbi-get_status db_webqtl))
(let [(row  (dbi-get_row db))]
  (display row)
  )

(dbi-query db "SELECT StrainId,Strain.Name FROM Strain, StrainXRef WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = 1 AND Used_for_mapping='Y' ORDER BY StrainId;")
(db-check db)

(define (display-rows db)
  (let [(row  (dbi-get_row db))]
    (if row
        (begin
          (display row)
          (get-rows db)
          )
        #f
        )
  ))

(define (get-rows db list)
  (let [(row (dbi-get_row db))]
    (if row
        (get-rows db (append list `(,row)))
        list
        )))

(define (get-rows-apply db func list)
  (let [(row (dbi-get_row db))]
    (if row
        (get-rows-apply db func (append list `(,(func row))))
        list
        )))

; (display (get-rows db '()))

(display (get-rows-apply db (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "Name"))) '()))