diff options
author | Pjotr Prins | 2023-08-27 11:24:08 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-08-27 11:24:08 +0200 |
commit | 2a8ae48a36cc88105c9a4c056132c9a47e2f120a (patch) | |
tree | e89080e0c5b9f614e2035686d0898cadba2a8dc2 | |
parent | afbbd86f316c2bfa70b86c1c51a4147a83f285ec (diff) | |
download | gn-guile-2a8ae48a36cc88105c9a4c056132c9a47e2f120a.tar.gz |
Shortnames
-rw-r--r-- | gn/data/species.scm | 5 | ||||
-rw-r--r-- | gn/db/sparql.scm | 2 | ||||
-rw-r--r-- | test/runner.scm | 6 | ||||
-rw-r--r-- | web/gn-uri.scm | 7 |
4 files changed, 16 insertions, 4 deletions
diff --git a/gn/data/species.scm b/gn/data/species.scm index a712bae..100cccf 100644 --- a/gn/data/species.scm +++ b/gn/data/species.scm @@ -11,9 +11,11 @@ #:export ( gnid-species + get-species get-species-meta get-species-data get-species-shortnames + get-species-binominal-names get-expanded-species get-expanded-taxon-meta get-expanded-taxon-data @@ -95,6 +97,9 @@ (define (get-species-shortnames recs) (map (lambda r (assoc-ref (car r) "shortName")) recs)) +(define (get-species-binominal-names recs) + (map (lambda r (url-parse-id (car (car r)))) recs)) + (define (get-species-meta2 recs) "Return a list of short names and expand them to URIs" (map (lambda r diff --git a/gn/db/sparql.scm b/gn/db/sparql.scm index 7e512ff..c413b9a 100644 --- a/gn/db/sparql.scm +++ b/gn/db/sparql.scm @@ -100,7 +100,7 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> (define recs '()) (define h (compile-species recs table)) (assoc "http://genenetwork.org/species_drosophila_melanogaster" h) -(assoc-ref h "http://genenetwork.org/species_drosophila_melanogaster") ;; note switch! +(assoc-ref h "http://genenetwork.org/id/Drosophila_melanogaster") (define d (car h)) (assoc-ref (list d) "http://genenetwork.org/species_drosophila_melanogaster") diff --git a/test/runner.scm b/test/runner.scm index 5555dc2..da42235 100644 --- a/test/runner.scm +++ b/test/runner.scm @@ -10,6 +10,12 @@ (test-begin "runner") +(test-equal "species short names" + (get-species-shortnames (get-species)) #f) + +(test-equal "species binominal identifiers" + (get-species-binominal-names (get-species)) '("Solanum_lycopersicum" "Rattus_norvegicus" "Populus_trichocarpa" "Mus_musculus" "Hordeum_vulgare" "Homo_sapiens" "Glycine_max" "Arabidopsis_thaliana" "Oryzias_latipes" "Macaca_nemestrina" "Glossophaga_soricina" "Drosophila_melanogaster")) + (test-assert "species-meta is expected contain a link to tomato" (assoc "tomato" (cdr (assoc "links" (get-species-meta))))) diff --git a/web/gn-uri.scm b/web/gn-uri.scm index f275bcd..5d95cd8 100644 --- a/web/gn-uri.scm +++ b/web/gn-uri.scm @@ -22,11 +22,12 @@ )) - (define (normalize-id str) ;; (string-replace-substring (string-downcase str) " " "_") - (string-replace-substring str " " "_") - ) + (match str + (#f "unknown") + (_ (string-replace-substring str " " "_")) + )) (define (url-parse-id uri) (if uri |