lotus-sparql-examples

A set of SPARQL examples that are used in LOTUS

View the Project on GitHub lotusnprod/lotus-sparql-examples

wd_nps_kingdoms

rq turtle/ttl

Compounds found in selected kingdoms.

Use at


PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
#title: Compounds found in selected kingdoms.
SELECT DISTINCT ?compound ?compound_inchikey ?taxon ?taxon_name ?reference ?reference_doi ?supertaxon WHERE {
  VALUES ?supertaxon {
    wd:Q729   # Animalia
    wd:Q756   # Plantae
    wd:Q764   # Fungi
    wd:Q10876 # Bacteria (domain, not kingdom)
  }
  ?compound wdt:P235 ?compound_inchikey;
    p:P703 ?statement.
  ?statement ps:P703 ?taxon;
    (prov:wasDerivedFrom/pr:P248) ?reference;
    wikibase:rank wikibase:NormalRank.
    ?reference wdt:P356 ?reference_doi.
  ?taxon (wdt:P171+) ?supertaxon;
    wdt:P225 ?taxon_name.
}

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?compound"):::projected 
  v3("?compound_inchikey"):::projected 
  v6("?reference"):::projected 
  v7("?reference_doi"):::projected 
  v4("?statement")
  v1("?supertaxon"):::projected 
  v5("?taxon"):::projected 
  v8("?taxon_name"):::projected 
  a1((" "))
  c7(["wikibase:NormalRank"]):::iri 
  bind0[/VALUES ?supertaxon/]
  bind0-->v1
  bind00(["wd:Q729"])
  bind00 --> bind0
  bind01(["wd:Q756"])
  bind01 --> bind0
  bind02(["wd:Q764"])
  bind02 --> bind0
  bind03(["wd:Q10876"])
  bind03 --> bind0
  v2 --"p:direct/P235"-->  v3
  v2 --"p:P703"-->  v4
  v4 --"p:statement/P703"-->  v5
  v4 --"prov:wasDerivedFrom"-->  a1
  a1 --"p:reference/P248"-->  v6
  v4 --"wikibase:rank"-->  c7
  v6 --"p:direct/P356"-->  v7
  v5 --"p:direct/P171"-->  v1
  v5 --"p:direct/P225"-->  v8