aboutsummaryrefslogtreecommitdiff
path: root/gn/db
diff options
context:
space:
mode:
authorPjotr Prins2023-08-23 14:23:44 +0200
committerPjotr Prins2023-08-23 14:23:44 +0200
commitafbbd86f316c2bfa70b86c1c51a4147a83f285ec (patch)
treecfcb6445da1f69e3a9a553424dc557dba57a8040 /gn/db
parent9dff66430a956f7c8fe92a600bf36c4b1895f958 (diff)
downloadgn-guile-afbbd86f316c2bfa70b86c1c51a4147a83f285ec.tar.gz
Able to render group data
Diffstat (limited to 'gn/db')
-rw-r--r--gn/db/sparql.scm33
1 files changed, 32 insertions, 1 deletions
diff --git a/gn/db/sparql.scm b/gn/db/sparql.scm
index 2665235..7e512ff 100644
--- a/gn/db/sparql.scm
+++ b/gn/db/sparql.scm
@@ -15,12 +15,15 @@
memo-sparql-species-meta
sparql-species-meta
sparql-groups-meta
+ sparql-group-info
memo-sparql-wd-species-info
compile-species
compile-groups-meta
get-rows
tsv->scm
strip-lang
+ make-table
+ make-pairs
)
)
@@ -200,6 +203,14 @@ dump-species-metadata.ttl:gn:Axbxa gnt:belongsToSpecies gn:Mus_musculus .
"Format results as a list of values ordered by names"
(map (lambda (row) (get-values names row)) (array->list results)))
+(define (get-pairs names results)
+ "Format results as a list of key-values ordered by names"
+ (map (lambda (row)
+ (let ([tuple (get-values names row)])
+ (cons (car tuple) (car (cdr tuple)))
+ ))
+ (array->list results)))
+
;; from the triples first harvest the species URIs, followed by creating records of information
(define (compile-species recs rows)
@@ -224,7 +235,7 @@ dump-species-metadata.ttl:gn:Axbxa gnt:belongsToSpecies gn:Mus_musculus .
;; ------------------------------------------------------------------------------
(define (sparql-groups-meta)
- "Return values names recs"
+ "Return values names recs - (set-id, species, descr)"
(sparql-scm (gn-sparql-endpoint-url) "
SELECT DISTINCT ?set ?species ?descr WHERE {
?set rdf:type gnc:inbredSet ;
@@ -235,8 +246,28 @@ dump-species-metadata.ttl:gn:Axbxa gnt:belongsToSpecies gn:Mus_musculus .
(define memo-sparql-groups-meta
(memoize2 sparql-groups-meta))
+(define (make-table sparql-thunk)
+ "Make a tuple of column names and rows"
+ (receive (names res) (sparql-thunk)
+ (let ([rows (get-rows names res)])
+ (list names rows))))
+
+(define (make-pairs sparql-thunk)
+ "Make a tuple of column names and rows"
+ (receive (names res) (sparql-thunk)
+ (let ([rows (get-pairs names res)])
+ (list names rows))))
+
(define (compile-groups-meta)
"Return tuple of names and rows containing #(set species descr)"
(receive (names res) (memo-sparql-groups-meta)
(let ([rows (get-rows names res)])
(list names rows))))
+
+(define (sparql-group-info gnid)
+ "Return set/group info - used by meta and data output"
+ (sparql-scm (gn-sparql-endpoint-url) (string-append "
+ SELECT DISTINCT ?key ?value WHERE {
+ " gnid " ?key ?value .
+ # FILTER ( !EXISTS{ " gnid " gnt:hasTissue ?value })
+}")))