aboutsummaryrefslogtreecommitdiff
path: root/gn
diff options
context:
space:
mode:
authorPjotr Prins2024-10-23 20:46:23 -0500
committerPjotr Prins2024-10-23 20:46:23 -0500
commitad3f1176642a499229554d490037b533ef7da418 (patch)
tree84a66e75957544f369c7771cef90a72275923014 /gn
parent071893cf9af080121fe60866dab59e7a691feb18 (diff)
downloadgn-guile-ad3f1176642a499229554d490037b533ef7da418.tar.gz
wikidata: build first query
Diffstat (limited to 'gn')
-rw-r--r--gn/db/sources/wikidata.scm29
-rw-r--r--gn/db/sparql.scm3
2 files changed, 31 insertions, 1 deletions
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