A set of SPARQL examples that are used in different SIB resources
List interactions of all species which have an IUCN status (wdt:P141) of near threatened (wd:Q719675).
PREFIX emi: <https://purl.org/emi#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?wdx_Source ?sourceName ?intxnLabel ?intxnType ?wdx_Target ?targetName WHERE {
{
SELECT DISTINCT ?wdx_Target ?targetName ?sourceName ?wdx_Source ?intxnType ?intxnLabel WHERE { #first select the source-target interaction-pairs
#unidirectional interaction, e.g.: source-X hosts target target-Y
?intxn emi:hasSource ?source ;
emi:hasTarget ?target ;
emi:isClassifiedWith ?intxnType .
?intxnType rdfs:label ?intxnLabel .
?source emi:inTaxon ?wdx_Source ; # retrieve wikidata-id for source
rdfs:label ?sourceName . # scientific name of source as given in GloBI
?target emi:inTaxon ?wdx_Target ; # retrieve wikidata-id for target
rdfs:label ?targetName . # scientific name of target as given in GloBI
}
}
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
{
?wdx_Source wdt:P141 wd:Q719675 ; # filter source wikidata ids, which have IUCN status (wdt:P141) as near threatened (wd:Q719675) and which is a plant
wdt:P171* wd:Q879246 ;
} UNION
{
?wdx_Target wdt:P141 wd:Q719675 ; # filter target wikidata ids, which have IUCN status (wdt:P141) as near threatened (wd:Q719675) and which is a plant
wdt:P171* wd:Q879246 ;
}
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?intxn")
v5("?intxnLabel"):::projected
v4("?intxnType"):::projected
v2("?source")
v7("?sourceName"):::projected
v3("?target")
v9("?targetName"):::projected
v6("?wdx_Source"):::projected
v8("?wdx_Target"):::projected
c10(["wd:Q879246"]):::iri
c8(["wd:Q719675"]):::iri
v1 --"emi:hasSource"--> v2
v1 --"emi:hasTarget"--> v3
v1 --"emi:isClassifiedWith"--> v4
v4 --"rdfs:label"--> v5
v2 --"emi:inTaxon"--> v6
v2 --"rdfs:label"--> v7
v3 --"emi:inTaxon"--> v8
v3 --"rdfs:label"--> v9
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v8 --"wdt:P141"--> c8
v8 --"wdt:P171"--> c10
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P141"--> c8
v6 --"wdt:P171"--> c10
end
union0r <== or ==> union0l
end
end