about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-x.guix-shell2
-rw-r--r--gn/data/hits.scm13
-rw-r--r--gn/runner/gemma.scm29
-rwxr-xr-xscripts/precompute/precompute-hits.scm19
4 files changed, 50 insertions, 13 deletions
diff --git a/.guix-shell b/.guix-shell
index 502f4b1..9f5b009 100755
--- a/.guix-shell
+++ b/.guix-shell
@@ -4,4 +4,4 @@
 
 echo "Create a shell to run tools. In the container"
 
-guix shell -C -F --network coreutils guile guile-dbi guile-dbd-mysql guile-fibers guile-json guile-gnutls guile-readline guile-redis openssl nss-certs $*
+guix shell -C -F --network coreutils guile guile-dbi guile-dbd-mysql guile-fibers guile-json guile-gnutls guile-readline guile-redis openssl nss-certs gemma $*
diff --git a/gn/data/hits.scm b/gn/data/hits.scm
index f0a24f3..5108bd0 100644
--- a/gn/data/hits.scm
+++ b/gn/data/hits.scm
@@ -13,9 +13,18 @@
   #:use-module (web gn-uri)
 
   #:export (
-            get-next-hit-for-precompute
+            get-precompute-hit
+            set-precompute-hit-status!
             ))
 
-(define (get-next-hit-for-precompute db prev-id)
+(define (get-precompute-hit db prev-id)
   (dbi-query db (string-append "select Locus, DataId, ProbeSetId, ProbeSetFreezeId from ProbeSetXRef where DataId>" (int-to-string prev-id) " AND Locus_old is NULL ORDER BY DataId LIMIT 1"))
   (get-row db))
+
+(define (set-precompute-hit-status! db data-id-str status-str)
+  "Set status of precompute record - typically 'RUN' or 'NON-BXD'.
+This is a temporary measure to get precompute going.
+Note we are counting on automated MariaDB transactions to not compete."
+  (dbi-query db (string-append "UPDATE ProbeSetXRef SET Locus_old=\"" status-str "\" WHERE DataId=" data-id-str " AND Locus_old is NULL"))
+  (ensure db)
+  )
diff --git a/gn/runner/gemma.scm b/gn/runner/gemma.scm
new file mode 100644
index 0000000..31a14f7
--- /dev/null
+++ b/gn/runner/gemma.scm
@@ -0,0 +1,29 @@
+(define-module (gn runner gemma)
+  #: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)
+
+  #:export (
+            run-gemma
+            ))
+
+(define (run-gemma data-id name trait-name traits)
+  (if name
+      (display (string-append "WE HAVE OUR BXD DATASET " name " and trait " trait-name " for precompute!\n")))
+  (display data-id)
+  (display traits)
+  (newline)
+  ;; ---- write phenotype file
+  (call-with-output-file "test.tmp"
+    (lambda (port)
+      (write 12 port)
+      (newline port)
+      (write "HELLO" port)
+      ))
+
+  ;; ---- start GEMMA precompute
+  (system "gemma")
+  )
diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm
index d8170db..0bce8d7 100755
--- a/scripts/precompute/precompute-hits.scm
+++ b/scripts/precompute/precompute-hits.scm
@@ -10,6 +10,7 @@
              (gn data hits)
              (gn data strains)
              (gn util convert)
+             (gn runner gemma)
              (rnrs base)
              (ice-9 match)
              (srfi srfi-1)
@@ -54,7 +55,7 @@
    )
 
      (define (run-precompute db prev-id)
-       (let* [(hit (get-next-hit-for-precompute db prev-id))
+       (let* [(hit (get-precompute-hit db prev-id))
               (data-id (assoc-ref hit "DataId"))
               (data-id-str (int-to-string data-id))
               (probesetfreeze-id (assoc-ref hit "ProbeSetFreezeId"))
@@ -81,16 +82,14 @@
 
                           '()
                           traits))
-         (if (= 0 (length non-bxd))
+         ;; (if (= 0 (length non-bxd))
+         (if (eq? non-bxd '())
              (begin
-               (if name
-                   (display (string-append "WE HAVE OUR BXD DATASET " name " and trait " trait-name " for precompute!\n")))
-               (display data-id)
-               (display traits)
-               (newline)
-
-               ))
-         (run-precompute db data-id)
+               (set-precompute-hit-status! db data-id-str "GEMMA-START")
+               (run-gemma data-id name trait-name traits)))
+             ;; disable precompute if non-bxd, for now, so it won't try again
+             (set-precompute-hit-status! db data-id-str "NON-BXD")
+         ;;(run-precompute db data-id)
          ))
      (run-precompute db 0)
 )))