From 66c26676c938e6ba35440bcb2e851fb025549ed0 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 20 Aug 2023 13:09:03 +0200 Subject: Add gnid to species - still a bug --- gn/data/species.scm | 14 +++++++------- gn/db/sparql.scm | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'gn') diff --git a/gn/data/species.scm b/gn/data/species.scm index 98ea1b1..e06931e 100644 --- a/gn/data/species.scm +++ b/gn/data/species.scm @@ -16,6 +16,12 @@ get-expanded-taxon-data )) +(define (gn-species short-name) + "Find the GN identifier from shortname" + (let ([rec (get-expanded-taxon-data short-name)]) + rec + )) + (define (get-species) (receive (names res) (memo-sparql-species-meta) (let* ([table (get-rows names res)] @@ -62,13 +68,6 @@ ) -(define (get-expanded-species) - "Here we add information related to each species" - (map (lambda (rec) - (expand-species rec) - ) (get-species) -)) - (define (get-expanded-taxon-data short-name) "Here we add information related to one taxonomy species" (call/cc (lambda (return) @@ -121,4 +120,5 @@ ("meta" . ,(mk-meta id)) ("data" . ,(mk-data id)) ("up" . ,(mk-meta "species")) + ("links" . ,(get-group-links (gn-species id))) )) diff --git a/gn/db/sparql.scm b/gn/db/sparql.scm index 0e8c938..fd779c6 100644 --- a/gn/db/sparql.scm +++ b/gn/db/sparql.scm @@ -13,6 +13,7 @@ #:export (memo-sparql-species memo-sparql-species-meta + sparql-species-meta memo-sparql-wd-species-info compile-species get-rows @@ -180,6 +181,14 @@ SELECT ?species ?p ?o WHERE { (define memo-sparql-species-meta (memoize2 sparql-species-meta)) +#! +dump-species-metadata.ttl:gn:Axbxa rdf:type gnc:inbredSet . +dump-species-metadata.ttl:gn:Axbxa rdfs:label "AXB/BXA Family" . +dump-species-metadata.ttl:gn:Axbxa gnt:family "Reference Populations (replicate average, SE, N)" . +dump-species-metadata.ttl:gn:Axbxa gnt:mappingMethod "AXBXA" . +dump-species-metadata.ttl:gn:Axbxa gnt:code "AXB" . +dump-species-metadata.ttl:gn:Axbxa gnt:belongsToSpecies gn:Mus_musculus . +!# (define (get-values names row) "Get values by name from a resultset row" @@ -194,17 +203,18 @@ SELECT ?species ?p ?o WHERE { (define (compile-species recs rows) "Compile a matrix of species triples into records" (for-each (lambda (r) - (let* ([s (car r)] + (let* ([species (car r)] [v (cdr (cdr r))] [p (car (cdr r))] [nrec '()] - [kv (assoc s recs)]) ; find record to fill based on subject - (if (not kv) - (set! nrec '()) - (set! nrec (cdr kv)) + [kvs (assoc species recs)]) ; find record to fill based on subject + ;; for each gnid add value pair + (if (not kvs) + (set! nrec `(("gnid" ,species))) + (set! nrec (cdr kvs)) ) (set! nrec (assoc-set! nrec p v)) - (set! recs (assoc-set! recs s nrec)) + (set! recs (assoc-set! recs species nrec)) )) rows) recs) -- cgit v1.2.3