Koetai SPARQL examples

Community-curated SPARQL example queries for multiple life-science endpoints.

View the Project on GitHub Koetai/sparql-examples

gbif_backbone_taxa_not_covered_on_wikidata

rq turtle/ttl

This query checks which GBIF species id's are not covered on wikidata by alliging on the wikidata property for GBIF

Use at

PREFIX species: <https://www.gbif.org/species/>
PREFIX dwc:     <http://rs.tdwg.org/dwc/terms/>
PREFIX gbif:    <https://rs.gbif.org/terms/>
PREFIX rank:    <https://rs.gbif.org/terms/rank/>
PREFIX status:  <https://rs.gbif.org/terms/status/>
PREFIX wdt:     <http://www.wikidata.org/prop/direct/>

SELECT ?sp ?key ?name WHERE {
  ?sp gbif:rank rank:species ;
      gbif:taxonomicStatus status:accepted ;
      dwc:scientificName ?name .
  BIND(REPLACE(STR(?sp), "^.*/species/", "") AS ?key)
  MINUS {
    SERVICE <https://qlever.dev/api/wikidata> {
      ?wd wdt:P846 ?key .
    }
  }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v3("?key"):::projected 
  v2("?name"):::projected 
  v1("?sp"):::projected 
  v4("?wd")
  c4([https://rs.gbif.org/terms/status/accepted]):::iri 
  c2([https://rs.gbif.org/terms/rank/species]):::iri 
  v1 --https://rs.gbif.org/terms/rank-->  c2
  v1 --https://rs.gbif.org/terms/taxonomicStatus-->  c4
  v1 --http://rs.tdwg.org/dwc/terms/scientificName-->  v2
  bind0[/"replace(str(?sp),'^.*/species/','')"/]
  v1 --o bind0
  bind0 --as--o v3
  subgraph minus1["MINUS"]
    style minus1 stroke-width:6px,fill:pink,stroke:red;
    subgraph s1["https://qlever.dev/api/wikidata"]
      style s1 stroke-width:4px;
      v4 --"wdt:P846"-->  v3
    end
  end