diff options
Diffstat (limited to 'gn')
-rw-r--r-- | gn/data/hits.scm | 22 | ||||
-rw-r--r-- | gn/db/sources/wikidata.scm | 29 | ||||
-rw-r--r-- | gn/db/sparql.scm | 3 | ||||
-rw-r--r-- | gn/runner/gemma.scm | 19 |
4 files changed, 61 insertions, 12 deletions
diff --git a/gn/data/hits.scm b/gn/data/hits.scm index f7ce49e..85c4912 100644 --- a/gn/data/hits.scm +++ b/gn/data/hits.scm @@ -5,6 +5,7 @@ #:use-module (ice-9 iconv) #:use-module (ice-9 receive) #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-9) ;; #:use-module (gn db sparql) #:use-module (dbi dbi) #:use-module (gn db mysql) @@ -17,11 +18,26 @@ get-precompute-hit set-precompute-hit-status! update-precompute! + hit-data-id + hit-probeset-id + hit-probesetfreeze-id )) -(define (get-precompute-hits db prev-id num) - (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 " (format #f "~d" num))) - (get-rows db '())) + +(define-record-type <hit> + (make-hit data-id probeset-id probesetfreeze-id) + hit? + (data-id hit-data-id) + (probeset-id hit-probeset-id) + (probesetfreeze-id hit-probesetfreeze-id) + ) + +(define (get-precompute-hits db first-id num) + (dbi-query db (string-append "select Locus, DataId, ProbeSetId, ProbeSetFreezeId from ProbeSetXRef where DataId>" (int-to-string first-id) " AND Locus_old is NULL ORDER BY DataId LIMIT " (int-to-string num))) + (map (lambda (r) + (make-hit (assoc-ref r "DataId") (assoc-ref r "ProbeSetId") (assoc-ref r "ProbeSetFreezeId"))) + (get-rows db '()) + )) (define (get-precompute-hit db prev-id) (car (get-precompute-hits db prev-id 1))) diff --git a/gn/db/sources/wikidata.scm b/gn/db/sources/wikidata.scm new file mode 100644 index 0000000..7397426 --- /dev/null +++ b/gn/db/sources/wikidata.scm @@ -0,0 +1,29 @@ +#! + +Wikidata queries + +!# + +(define-module (gn db sources wikidata) +) + +(define ps-encoded-by "ps:P702") +(define wdt-instance-of "wdt:P31") +(define wdt-in-taxon "wdt:P703") +(define wd-human "wd:Q15978631") +(define wd-mouse "wd:Q83310") +(define wd-rat "wd:Q184224") +(define wd-gene "wd:Q7187") + +(define (wikidata_query_geneids gene_name) + "Return the wikidata identifiers pointing to genes of listed species" + (string-append + "SELECT DISTINCT ?wikidata_id + WHERE { + ?wikidata_id " wdt-instance-of " " wd-gene "; + " wdt-in-taxon " ?species . + VALUES (?species) { (" wd-human " ) ( " wd-mouse" ) ( " wd-rat" ) } . + ?wikidata_id rdfs:label \"" gene_name "\"@en . + } +" + )) diff --git a/gn/db/sparql.scm b/gn/db/sparql.scm index b7d94f3..f03389b 100644 --- a/gn/db/sparql.scm +++ b/gn/db/sparql.scm @@ -2,7 +2,7 @@ Module for handling SPARQL primitives. -Note that GN queries should go into gn/data - this is currently not +Note that GN queries should go into gn/db/sources - this is currently not the case. !# @@ -18,6 +18,7 @@ the case. #:use-module (web request) #:use-module (web uri) #:use-module (gn cache memoize) + #:use-module (gn db sources wikidata) #:use-module (web gn-uri) #:export (memo-sparql-species diff --git a/gn/runner/gemma.scm b/gn/runner/gemma.scm index 69991dd..9a5c0fc 100644 --- a/gn/runner/gemma.scm +++ b/gn/runner/gemma.scm @@ -39,24 +39,27 @@ )) ) -(define (invoke-gemma-wrapper-loco name trait-name pheno-fn) +(define (invoke-gemma-wrapper-loco name trait-name trait-fn pheno-fn geno-fn) "Create a tmpdir and invoke gemma-wrapper using parallel LOCO. Note that at this point we use a number of defaults for BXD" (let* [(population "BXD") (sys-tmpdir (getenv "TMPDIR")) (tmpdir (mkdtemp (string-append sys-tmpdir "/run-gemma-XXXXXX"))) (k-json-fn (string-append tmpdir "/K.json")) - (gwa-json-fn (string-append tmpdir "/GWA.json"))] + (gwa-json-fn (string-append tmpdir "/GWA.json")) + (trait-json-fn (string-append tmpdir "/" trait-fn))] + (copy-file trait-fn trait-json-fn) ;; --- First we compute K - control output goes to K.json - (let [(err (system (string-append "/gemma-wrapper/bin/gemma-wrapper --verbose --population \"" population "\" --name \"" name "\" --trait \"" trait-name "\" --verbose --loco --json --parallel -- -gk -g BXD.8_geno.txt.gz -p " pheno-fn " -a BXD.8_snps.txt > " k-json-fn )))] + (let [(err (system (string-append "/gemma-wrapper/bin/gemma-wrapper --verbose --population \"" population "\" --name \"" name "\" --trait \"" trait-name "\" --verbose --loco --json --parallel -- -gk -g " geno-fn " -p " pheno-fn " -a BXD.8_snps.txt > " k-json-fn )))] (if (not (= err 0)) (exit err))) - (let [(err (system (string-append "/gemma-wrapper/bin/gemma-wrapper --population \"" population "\" --name \"" name "\" --id \"" trait-name "\" --trait \"" trait-name "\" --verbose --loco --json --input " k-json-fn " -- -g BXD.8_geno.txt.gz -p " pheno-fn " -a BXD.8_snps.txt -lmm 9 -maf 0.1 > " gwa-json-fn)))] + (let [(err (system (string-append "/gemma-wrapper/bin/gemma-wrapper --meta \"" trait-json-fn "\" --population \"" population "\" --name \"" name "\" --id \"" trait-name "\" --trait \"" trait-name "\" --verbose --loco --json --lmdb --input " k-json-fn " -- -g " geno-fn " -p " pheno-fn " -a BXD.8_snps.txt -lmm 9 -maf 0.1 > " gwa-json-fn)))] (if (not (= err 0)) (exit err))) - ;; (delete-file pheno-fn) - ;; (delete-file gwa-json-fn) - ;; (delete-file k-json-fn) - ;; (rmdir tmpdir) + (delete-file pheno-fn) + (delete-file gwa-json-fn) + (delete-file k-json-fn) + (delete-file trait-json-fn) + (rmdir tmpdir) ) ) |