From b9fb2c69136fe243fc9c6f7c3c4f8917814a401e Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 12 Aug 2023 13:52:25 +0200 Subject: Add SPARQL prefix --- gn/db/sparql.scm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'gn/db') 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: +PREFIX gnt: +PREFIX gnc: +PREFIX rdf: + +" 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: -PREFIX gnc: -PREFIX rdf: - 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: -PREFIX gnc: -PREFIX gnt: -PREFIX rdf: - SELECT ?species ?p ?o WHERE { MINUS { ?species rdf:type ?o . } { -- cgit v1.2.3