From fb22ae84c143a27ddc4699327e8aff6c93a0bf6c Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 24 Nov 2023 09:07:55 +0100 Subject: Fetch genotype inds from json file --- .gitignore | 1 + .guix-shell | 2 +- gn/data/genotype.scm | 23 +++++++++++++++++++++++ gn/runner/gemma.scm | 9 ++++++--- scripts/precompute/precompute-hits.scm | 6 ++++++ 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 gn/data/genotype.scm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..047b170 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +BXD.* diff --git a/.guix-shell b/.guix-shell index 9f5b009..988e529 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 gemma $* +guix shell -C -D -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/genotype.scm b/gn/data/genotype.scm new file mode 100644 index 0000000..c7cb63c --- /dev/null +++ b/gn/data/genotype.scm @@ -0,0 +1,23 @@ +(define-module (gn data genotype) + #: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 (gn util convert) + + #:export ( + geno-inds-bxd + )) + +(define (geno-inds-bxd fn) + (let [(js (call-with-input-file fn + (lambda (port) + (json->scm port))))] + (vector->list (assoc-ref (car (vector->list (assoc-ref js "genofile"))) "sample_list")) +)) diff --git a/gn/runner/gemma.scm b/gn/runner/gemma.scm index 31a14f7..d9e43eb 100644 --- a/gn/runner/gemma.scm +++ b/gn/runner/gemma.scm @@ -17,13 +17,16 @@ (display traits) (newline) ;; ---- write phenotype file - (call-with-output-file "test.tmp" + (call-with-output-file "pheno.txt" (lambda (port) (write 12 port) (newline port) (write "HELLO" port) )) + ;; set up with ./.guix-shell -- guile -L . -s ./scripts/precompute/precompute-hits.scm - ;; ---- start GEMMA precompute - (system "gemma") + ;; ---- to start GEMMA precompute inside container + ;; env LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib/ guile -L . -s ./scripts/precompute/precompute-hits.scm + ;; --- First we compute K + (system (string-append "env GEMMA_COMMAND=/gemma/bin/gemma /gemma-wrapper/bin/gemma-wrapper --debug -- -gk -g BXD.8_geno.txt.gz -p pheno.txt -a BXD.8_snps.txt" )) ) diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm index 0bce8d7..e8ba0a2 100755 --- a/scripts/precompute/precompute-hits.scm +++ b/scripts/precompute/precompute-hits.scm @@ -7,6 +7,7 @@ (use-modules (dbi dbi) (gn db mysql) (gn data dataset) + (gn data genotype) (gn data hits) (gn data strains) (gn util convert) @@ -16,6 +17,11 @@ (srfi srfi-1) ) + +(define inds (geno-inds-bxd "BXD.json")) +(display inds) +(assert (= 235 (length inds))) + ;; 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;" -- cgit v1.2.3