From 1baf1a444c000cac21775a1b4d7d348c5fb1f880 Mon Sep 17 00:00:00 2001
From: Pjotr Prins
Date: Mon, 17 Jul 2023 12:25:29 +0200
Subject: refactoring
---
gn3-guile/web/webserver.scm | 73 ++++++++++++++-------------------------------
1 file changed, 22 insertions(+), 51 deletions(-)
(limited to 'gn3-guile/web')
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm
index 0803018..2aaffed 100755
--- a/gn3-guile/web/webserver.scm
+++ b/gn3-guile/web/webserver.scm
@@ -49,8 +49,7 @@
("comment" . "This is the official REST API for the GeneNetwork service hosted at https://genenetwork.org/")
("license" . (("source code" . "AGPL")))
("note" . "work in progress (WIP)")
- ("see also". ,(meta (prefix)))
- ))
+ ("see also". ,(meta (prefix)))))
(define info-meta `(
("doc" . ,(mk-doc "info"))
@@ -65,56 +64,33 @@
(bytevector->string (receive (response-status response-body)
(http-request (string-append "https://sparql.genenetwork.org/sparql?default-graph-uri=&query=" (uri-encode query) "&format=application%2Fsparql-results%2Bjson"))
- response-body) "UTF-8"
- ))
+ response-body) "UTF-8"))
(define (sparql-names response)
- (cdr (assoc "vars" (cdr (assoc "head" response))))
- )
+ (cdr (assoc "vars" (cdr (assoc "head" response)))))
-(define (sparql-results response)
- (cdr (assoc "bindings" (cdr (assoc "results" response
+(define (sparql-results response) (cdr (assoc "bindings" (cdr (assoc "results" response
)))))
(define (sparql-scm query)
- "Return dual S-exp"
- (let response (((json-string->scm (sparql-exec query)))
- (values (sparql-names response) (sparql-results response))
- )))
-
-
-(define (sparql-exec query)
- "Return list of varnames and list of results"
- (let ([response (sparql-scm query)])
- (values (sparql-names response) (sparql-results response))
- ))
+ "Return dual S-exp of varnames and results"
+ (let ((response (json-string->scm (sparql-exec query))))
+ (values (sparql-names response) (sparql-results response))))
(define (sparql-species)
- (sparql-exec "
+ (sparql-scm "
PREFIX gn:
PREFIX rdf:
SELECT DISTINCT ?species WHERE {
?species rdf:type gn:species .
-}"
- ))
+}"))
(define (get-species-uris)
- (map (lambda (m) (cdr (assoc "value"(cdr (car m))))) (array->list (sparql-species)))
- )
+ (map (lambda (m) (cdr (assoc "value"(cdr (car m))))) (array->list (sparql-species))))
-(define (sparql-species-meta2)
- (sparql-exec "
-PREFIX gn:
-PREFIX rdf:
-
-SELECT DISTINCT ?species ?p ?o WHERE {
- ?species rdf:type gn:species .
- ?species ?p ?o .
-}"
- ))
(define (sparql-species-meta)
- (sparql-exec "
+ (sparql-scm "
PREFIX gn:
PREFIX rdf:
@@ -124,28 +100,23 @@ SELECT ?species ?p ?o WHERE {
SELECT DISTINCT ?species ?p ?o WHERE {
?species rdf:type gn:species .
?species ?p ?o .
- }}}"
- ))
-
+ }}}"))
-(define (get-species-all)
- (sparql-species-meta))
-(define (get-species)
- (receive (names results) (sparql-species-meta)
- results))
+;; (define (get-species)
+;; (receive (names results) (sparql-species-meta)
+;; results))
-(define (get-values name resultlist)
- (map (lambda (m) (cdr (assoc "value" (cdr (assoc name m))))) resultlist)
- )
+;; (define (get-values name resultlist)
+;; (map (lambda (m) (cdr (assoc "value" (cdr (assoc name m))))) resultlist))
-(define (filter-results)
- (get-values "o" (array->list (get-species)))
- )
+;; (define (filter-results)
+;; (get-values "o" (array->list (get-species))))
+;; (define (triples)
+;; (array->list (get-species-all)))
-(define (triples)
- (array->list (get-species-all)))
+(define get-matrix #f)
;; from the triples first harvest the species URIs, followed by creating records of information
--
cgit v1.2.3