A set of SPARQL examples that are used in different SIB resources
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX emi: <https://purl.org/emi#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT ?sourceWD ?sourceName ?intxnName ?intxnLabel ?targetWD ?targetName ?ik ?wd_chem WHERE {
# interaction data
{
SELECT DISTINCT ?sourceWD ?sourceName ?intxnName ?intxnLabel ?targetWD ?targetName WHERE {
?intxn emi:hasSource ?source ; # retrieve interaction-pairs
emi:hasTarget ?target ;
emi:isClassifiedWith ?intxnName .
?target emi:inTaxon ?targetWD ; # retrieve wikidata-id for target plant
sosa:isSampleOf ?targetSample ;
rdfs:label ?targetName .
?source emi:inTaxon ?sourceWD ; # retrieve wikidata-id for source parasite
sosa:isSampleOf ?sourceSample ;
rdfs:label ?sourceName .
?intxnName rdfs:label ?intxnLabel
VALUES ?sourceWD { wd:Q7102162 } # retain results only if the source-WD matches the wikidata-id of Orgyia postica
}
}
# metabolite data
{
SELECT DISTINCT ?targetWD ?ik ?wd_chem WHERE {
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?targetWD . # filter metabolite data which is found in wikidata-ids targetWD
?extract sosa:isFeatureOfInterestOf ?lcms .
?lcms sosa:hasResult ?feature_list .
?feature_list emi:hasLCMSFeature ?feature .
?feature emi:hasAnnotation ?sirius_annotation .
?sirius_annotation a emi:StructuralAnnotation ;
emi:hasChemicalStructure ?ik2d .
?ik2d emi:hasSMILES ?smiles ;
emi:isInChIKey2DOf ?ik .
?ik emi:isInChIKeyOf ?wd_chem . # retrieve wikidata-ids for metabolites
}
} UNION #union with data from lotus (integrated in wikidata)
{
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?ik ;
wdt:P703 ?targetWD .
}
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?targetWD 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 ;
OPTIONAL { ?targetWD wdt:P225 ?targetName . }
}
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?extract")
v17("?feature")
v16("?feature_list")
v21("?ik"):::projected
v19("?ik2d")
v1("?intxn")
v11("?intxnLabel"):::projected
v4("?intxnName"):::projected
v15("?lcms")
v12("?material")
v14("?organe")
v18("?sirius_annotation")
v20("?smiles")
v2("?source")
v10("?sourceName"):::projected
v9("?sourceSample")
v12("?sourceWD"):::projected
v3("?target")
v7("?targetName"):::projected
v6("?targetSample")
v5("?targetWD"):::projected
v22("?wd_chem"):::projected
c13(["emi:StructuralAnnotation"]):::iri
c24(["wd:Q879246"]):::iri
c22(["wd:Q719675"]):::iri
v1 --"emi:hasSource"--> v2
v1 --"emi:hasTarget"--> v3
v1 --"emi:isClassifiedWith"--> v4
v3 --"emi:inTaxon"--> v5
v3 --"sosa:isSampleOf"--> v6
v3 --"rdfs:label"--> v7
v2 --"emi:inTaxon"--> v12
v2 --"sosa:isSampleOf"--> v9
v2 --"rdfs:label"--> v10
v4 --"rdfs:label"--> v11
bind0[/VALUES ?sourceWD/]
bind0-->v12
bind00(["wd:Q7102162"])
bind00 --> bind0
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
v22 --"wdt:P235"--> v21
v22 --"wdt:P703"--> v5
end
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
v5 --"wdt:P141"--> c22
v5 --"wdt:P171"--> c24
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wdt:P225".-> v7
end
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v12 --"sosa:hasSample"--> v13
v12 --"sosa:isSampleOf"--> v14
v14 --"emi:inTaxon"--> v5
v13 --"sosa:isFeatureOfInterestOf"--> v15
v15 --"sosa:hasResult"--> v16
v16 --"emi:hasLCMSFeature"--> v17
v17 --"emi:hasAnnotation"--> v18
v18 --"a"--> c13
v18 --"emi:hasChemicalStructure"--> v19
v19 --"emi:hasSMILES"--> v20
v19 --"emi:isInChIKey2DOf"--> v21
v21 --"emi:isInChIKeyOf"--> v22
end
union0r <== or ==> union0l
end