sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

044

rq turtle/ttl

Chemical aspect: found in taxon

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q2270>

SELECT DISTINCT ?taxon ?taxonLabel (CONCAT("/taxon/", SUBSTR(STR(?taxon), 32)) AS ?taxonUrl)
?source ?sourceLabel (CONCAT("/work/", SUBSTR(STR(?source), 32)) AS ?sourceUrl)
?doi WHERE {
  VALUES ?chemical { target: }
  ?chemical p:P703 ?taxonStatement .
  ?taxonStatement ps:P703 ?taxon .
  OPTIONAL {
      ?taxonStatement prov:wasDerivedFrom/pr:P248 ?source .
      OPTIONAL { ?source wdt:P356 ?doi . }
    }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
} ORDER BY ASC(?taxonLabel)
  LIMIT 250

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?chemical")
  v6("?doi"):::projected 
  v5("?source"):::projected 
  v8("?sourceUrl")
  v4("?taxon"):::projected 
  v1("?taxonLabel"):::projected 
  v3("?taxonStatement")
  v7("?taxonUrl")
  a1((" "))
  c7([http://www.bigdata.com/rdf#serviceParam]):::iri 
  c9(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal 
  bind0[/VALUES ?chemical/]
  bind0-->v2
  bind00([http://www.wikidata.org/entity/Q2270])
  bind00 --> bind0
  v2 --"p:P703"-->  v3
  v3 --"p:statement/P703"-->  v4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v3 -."prov:wasDerivedFrom".->  a1
    a1 --"p:reference/P248"-->  v5
    subgraph optional1["(optional)"]
    style optional1 fill:#bbf,stroke-dasharray: 5 5;
      v5 -."p:direct/P356".->  v6
    end
  end
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c7 --"wikibase:language"-->  c9
  end
  bind1[/"concat('/taxon/',substring(str(?taxon),'32^^xsd:integer'))"/]
  v4 --o bind1
  bind1 --as--o v7
  bind2[/"concat('/work/',substring(str(?source),'32^^xsd:integer'))"/]
  v5 --o bind2
  bind2 --as--o v8