aboutsummaryrefslogtreecommitdiff
path: root/gn/data
diff options
context:
space:
mode:
authorPjotr Prins2023-11-17 11:09:17 +0100
committerPjotr Prins2023-11-17 11:09:17 +0100
commitc401f66de2dbcbc41dd9551490563543092de242 (patch)
tree8e9eab92738389a8e4e73280a52ec5f11ea6f45b /gn/data
parent678d976260c6f566166e0459a425d5ef296b002f (diff)
downloadgn-guile-c401f66de2dbcbc41dd9551490563543092de242.tar.gz
First implementation of DB handler
Diffstat (limited to 'gn/data')
-rw-r--r--gn/data/strains.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/gn/data/strains.scm b/gn/data/strains.scm
new file mode 100644
index 0000000..275c4cd
--- /dev/null
+++ b/gn/data/strains.scm
@@ -0,0 +1,22 @@
+(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-names
+ ))
+
+(define (strain-names)
+ (call-with-db
+ (lambda (db)
+ (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;")
+ (get-rows-apply db (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "Name"))) '()))))