aboutsummaryrefslogtreecommitdiff
path: root/gn/data/strains.scm
blob: 241ecda34ed0aa0c0d4eaeaf5a10babb367f588c (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
(define-module (gn data strains)
  #: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 (web gn-uri)

  #:export (
            strain-id-names
            bxd-strain-id-names
            ))

(define* (strain-id-names inbred-set #:key (map? #f))
  "Return assoc list of tuples of strain id+names:
   ((4 . BXD1) (5 . BXD2) (6 . BXD5) (7 . BXD6)...

map? will say whether the strains/individuals are used for mapping.
"
  (call-with-db
   (lambda (db)
     (dbi-query db (string-append "SELECT StrainId,Strain.Name FROM Strain, StrainXRef WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = " (format #f "~d" inbred-set)
                                  (if map?
                                      " AND Used_for_mapping='Y'"
                                      "")
                                  " ORDER BY StrainId;"))
      (get-rows-apply db (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "Name"))) '()))))

(define* (bxd-strain-id-names #:key (map? #f))
  "Return assoc list of tuples of strain id + names. Same as strain-id-names, but just for the BXD"
   (strain-id-names 1))