query-85940a1cae1ea224af792c5221c795bc

rq turtle/ttl

title: Which pigments are found in which taxa, according to which reference?

special thanks goes to User:Lmichan for updating this information!

SELECT DISTINCT ?compound ?compoundLabel ?taxon ?taxonname ?DOI WITH { SELECT ?compound WHERE { ?compound (wdt:P31/wdt:P279) wd:Q161179. # get pigments } } AS %compounds WITH { SELECT ?compound ?P703statement WHERE { INCLUDE %compounds ?compound p:P703 ?P703statement. ?P703statement wikibase:rank wikibase:NormalRank. # check for "found in taxon" statements } } AS %P703statement WITH { SELECT ?compound ?taxon ?DOI WHERE { INCLUDE %P703statement ?P703statement ps:P703 ?taxon ; # get the respective taxa prov:wasDerivedFrom / pr:P248 [ # get the reference supporting that statement wdt:P356 ?DOI # get the DOI for the reference ] . } } AS %taxa WHERE { { INCLUDE %taxa

        ?taxon wdt:P225 ?taxonname .        # get the taxon name

} ?compound rdfs:label ?compoundLabel . # get compound labels FILTER (LANG(?compoundLabel) = "en") . # filter for English } ORDER BY ASC(?compoundLabel) LIMIT 10000

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
#title: Which pigments are found in which taxa, according to which reference?
# special thanks goes to User:Lmichan for updating this information!
SELECT DISTINCT ?compound ?compoundLabel ?taxon ?taxonname ?DOI 
WHERE {
  {
     {
  SELECT ?compound ?taxon ?DOI WHERE {
     {
  SELECT ?compound ?P703statement WHERE {
    INCLUDE %compounds
            ?compound p:P703 ?P703statement.
            ?P703statement wikibase:rank wikibase:NormalRank.    # check for "found in taxon" statements
  }
}            ?P703statement ps:P703 ?taxon ;     # get the respective taxa
            prov:wasDerivedFrom / pr:P248 [     # get the reference supporting that statement
              wdt:P356 ?DOI                     # get the DOI for the reference
            ] .
  }
}
            ?taxon wdt:P225 ?taxonname .        # get the taxon name
  }
  ?compound rdfs:label ?compoundLabel .         # get compound labels
  FILTER (LANG(?compoundLabel) = "en") .        # filter for English
}
ORDER BY ASC(?compoundLabel)
LIMIT 10000

Query found at