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 ?intxnId ?targetWD ?targetName WHERE {
# interaction data
{
?intxn emi:hasSource ?xOrg ; # retrieve interaction-pairs
emi:hasTarget ?yOrg ;
emi:isClassifiedWith ?intxnId .
?intxnId rdfs:label ?intxnName .
?xOrg emi:inTaxon ?sourceWD ;
rdfs:label ?sourceName .
?yOrg emi:inTaxon ?targetWD ;
rdfs:label ?targetName .
}
# metabolite data
FILTER (?xWD = ?sourceWD || ?xWD = ?targetWD) # ensure that xWD can be both source/target from the interaction-pairs retrieved before
{
SELECT DISTINCT ?xWD ?wd_chem WHERE {
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?xWD .
?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 .
VALUES ?wd_chem { wd:Q27107545 }
}
} UNION # union with data from wikidata (lotus)
{
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?ik ;
wdt:P703 ?xWD .
VALUES ?wd_chem { wd:Q27107545 }
}
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v12("?extract")
v16("?feature")
v15("?feature_list")
v20("?ik")
v18("?ik2d")
v4("?intxn")
v7("?intxnId"):::projected
v8("?intxnName"):::projected
v14("?lcms")
v11("?material")
v13("?organe")
v17("?sirius_annotation")
v19("?smiles")
v9("?sourceName"):::projected
v2("?sourceWD"):::projected
v10("?targetName"):::projected
v3("?targetWD"):::projected
v22("?wd_chem")
v5("?xOrg")
v1("?xWD")
v6("?yOrg")
c13(["emi:StructuralAnnotation"]):::iri
f0[["(?xWD = ?sourceWD || ?xWD = ?targetWD)"]]
f0 --> v1
f0 --> v2
f0 --> v3
v4 --"emi:hasSource"--> v5
v4 --"emi:hasTarget"--> v6
v4 --"emi:isClassifiedWith"--> v7
v7 --"rdfs:label"--> v8
v5 --"emi:inTaxon"--> v2
v5 --"rdfs:label"--> v9
v6 --"emi:inTaxon"--> v3
v6 --"rdfs:label"--> v10
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"--> v20
v22 --"wdt:P703"--> v1
bind1[/VALUES ?wd_chem/]
bind1-->v22
bind10(["wd:Q27107545"])
bind10 --> bind1
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v11 --"sosa:hasSample"--> v12
v11 --"sosa:isSampleOf"--> v13
v13 --"emi:inTaxon"--> v1
v12 --"sosa:isFeatureOfInterestOf"--> v14
v14 --"sosa:hasResult"--> v15
v15 --"emi:hasLCMSFeature"--> v16
v16 --"emi:hasAnnotation"--> v17
v17 --"a"--> c13
v17 --"emi:hasChemicalStructure"--> v18
v18 --"emi:hasSMILES"--> v19
v18 --"emi:isInChIKey2DOf"--> v20
v20 --"emi:isInChIKeyOf"--> v22
bind2[/VALUES ?wd_chem/]
bind2-->v22
bind20(["wd:Q27107545"])
bind20 --> bind2
end
union0r <== or ==> union0l
end