diff options
author | Pjotr Prins | 2023-08-12 13:52:25 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-08-12 13:52:25 +0200 |
commit | b9fb2c69136fe243fc9c6f7c3c4f8917814a401e (patch) | |
tree | cb2233b1feeb62d1302410c1438a5314a21684e9 /gn/db | |
parent | 3778f3df14cc3da068fc205586e3b6471885ebe9 (diff) | |
download | gn-guile-b9fb2c69136fe243fc9c6f7c3c4f8917814a401e.tar.gz |
Add SPARQL prefix
Diffstat (limited to 'gn/db')
-rw-r--r-- | gn/db/sparql.scm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gn/db/sparql.scm b/gn/db/sparql.scm index 6c3b5b2..95b4e1d 100644 --- a/gn/db/sparql.scm +++ b/gn/db/sparql.scm @@ -24,6 +24,16 @@ (define (wd-sparql-endpoint-url) "https://query.wikidata.org/sparql") +(define (gn-sparql-prefix query) + (string-append + " +PREFIX gn: <http://genenetwork.org/id/> +PREFIX gnt: <http://genenetwork.org/term/> +PREFIX gnc: <http://genenetwork.org/category/> +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + +" query)) + (define (wdt-taxon-name) "wdt:P225") (define (sparql-exec endpoint-url query) @@ -56,7 +66,8 @@ (define (sparql-scm endpoint-url query) "Return dual S-exp 'resultset' of varnames and results" - (let ((response (json-string->scm (sparql-exec endpoint-url query)))) + (let ((response (json-string->scm + (sparql-exec endpoint-url (gn-sparql-prefix query))))) (values (sparql-names response) (sparql-results response)))) (define (tsv->scm text) @@ -136,10 +147,6 @@ gn:Mus_musculus gnt:organism taxon:10090 . (define (sparql-species) (sparql-scm (gn-sparql-endpoint-url) " -PREFIX gn: <http://genenetwork.org/id/> -PREFIX gnc: <http://genenetwork.org/category/> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - SELECT DISTINCT ?species WHERE { ?species rdf:type gnc:species . }")) @@ -150,11 +157,6 @@ SELECT DISTINCT ?species WHERE { (define (sparql-species-meta) "Return values names recs" (sparql-scm (gn-sparql-endpoint-url) " -PREFIX gn: <http://genenetwork.org/id/> -PREFIX gnc: <http://genenetwork.org/category/> -PREFIX gnt: <http://genenetwork.org/term/> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - SELECT ?species ?p ?o WHERE { MINUS { ?species rdf:type ?o . } { |