aboutsummaryrefslogtreecommitdiff
path: root/gn/db
diff options
context:
space:
mode:
Diffstat (limited to 'gn/db')
-rw-r--r--gn/db/sparql.scm22
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 . }
{