aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2023-07-28 13:21:37 +0200
committerPjotr Prins2023-07-28 13:21:37 +0200
commit8cd227c551f772e142002171e0c928db637ecb08 (patch)
treea6bdb6ba5cf9edd51e70f70539934834e391ec5b
parentc591d394e08d7052515634a5b9c1e05ff5a2dff8 (diff)
downloadgenenetwork3-8cd227c551f772e142002171e0c928db637ecb08.tar.gz
use match
-rwxr-xr-xgn3-guile/web/webserver.scm23
1 files changed, 13 insertions, 10 deletions
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm
index 123abf5..fb0ed38 100755
--- a/gn3-guile/web/webserver.scm
+++ b/gn3-guile/web/webserver.scm
@@ -156,10 +156,11 @@ SELECT DISTINCT * where { wd:Q158695 wdt:P225 ?o . } limit 10
"
(sparql-tsv (wd-sparql-endpoint-url) (string-append "
-SELECT DISTINCT * where {
+SELECT DISTINCT ?taxon ?ncbi ?descr where {
wd:" species " " (wdt-taxon-name) " ?taxon ;
wdt:P685 ?ncbi ;
schema:description ?descr .
+ ?species wdt:P685 ?ncbi .
FILTER (lang(?descr)='en')
} limit 5
@@ -252,15 +253,17 @@ SELECT ?species ?p ?o WHERE {
(let ([wd-id (url-parse-id (assoc-ref rec "22-rdf-syntax-ns#isDefinedBy"))])
(if (string=? wd-id "unknown")
rec
- ; wikidata query:
- (receive (names row) (tsv->scm (sparql-wd-species-info wd-id))
- (display wd-id)
- (display row)
- (let ([ncbi (car (cdr (car row)) )])
- (cons `("wikidata" . ,wd-id)
- (cons `("ncbi" . ,ncbi)
- (cons `("taxonomy-name" . ,(car (car row))) rec))
- ))
+ ; wikidata query:
+ (receive (names row) (tsv->scm (sparql-wd-species-info wd-id))
+ (match (pk (car row))
+ ((taxonomy-name ncbi descr)
+ (cons `("wikidata" . ,wd-id)
+ (cons `("ncbi" . ,ncbi)
+ (cons `("taxonomy-name" . ,taxonomy-name)
+ ; (cons `("shortname" . ,shortname)
+ (cons `("description" . ,descr)
+ rec)))))
+ )
)))
) (get-species)
))