aboutsummaryrefslogtreecommitdiff
path: root/gn
diff options
context:
space:
mode:
Diffstat (limited to 'gn')
-rw-r--r--gn/data/hits.scm6
-rw-r--r--gn/db/mysql.scm15
2 files changed, 17 insertions, 4 deletions
diff --git a/gn/data/hits.scm b/gn/data/hits.scm
index 91be81f..a66eee5 100644
--- a/gn/data/hits.scm
+++ b/gn/data/hits.scm
@@ -9,7 +9,13 @@
#: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 (
+ get-next-hit-for-precompute
))
+
+(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"))
+ (get-row db))
diff --git a/gn/db/mysql.scm b/gn/db/mysql.scm
index fb7093a..760e578 100644
--- a/gn/db/mysql.scm
+++ b/gn/db/mysql.scm
@@ -18,7 +18,8 @@
get-row
get-rows
get-rows-apply
- check
+ has-result?
+ ensure
;db-open
;db-query
;db-get-row
@@ -36,7 +37,7 @@
(define (call-with-db thunk)
(thunk (db-open)))
-(define (check db)
+(define (ensure db)
"Use DBI-style handle to report an error. On error the program will stop."
(match (dbi-get_status db)
((stat . msg) (if (= stat 0)
@@ -46,15 +47,21 @@
(newline)
(assert stat))))))
+(define (has-result? db)
+ "Return #t or #f if result is valid"
+ (match (dbi-get_status db)
+ ((stat . msg) (= stat 0))))
+
(define (get-row db)
+ "Return record and #f is it was the last one"
(dbi-get_row db))
(define (get-rows db list)
"After running dbi-query we can fetch all rows and return them as a list of records, which is an alist:
(dbi-query db \"SELECT StrainId,Strain.Name FROM Strain, StrainXRef WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = 1 ORDER BY StrainId;\")
- (db-check db)
- (display (db-get-rows db '()))
+ (ensure db)
+ (display (get-rows db '()))
(((StrainId . 4) (Name . BXD1)) ((StrainId . 5) (Name . BXD2))...
"