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 enpkg: <https://enpkg.commons-lab.org/kg/>
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/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX emiBox: <https://purl.org/emi/abox#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?wd_chem ?structure_inchikey ?parasitoidX_WD ?parasitoidNameURI ?parasiteX_WD ?parasiteNameURI ?intxn3Label ?hostPlant_WD ?hostPlantNameURI
WHERE {
{SELECT DISTINCT ?parasitoidX_WD ?parasitoidNameURI ?parasiteX_WD ?parasiteNameURI ?intxn3Label ?hostPlant_WD ?hostPlantNameURI
WHERE {
{SELECT DISTINCT ?parasitoidName ?parasiteName ?parasiteX_WD ?parasitoidX_WD WHERE {
?intxn2 emi:hasSource ?parasitoidX ; #retrieve interaction pairs part-1
emi:hasTarget ?parasiteX ;
emi:isClassifiedWith ?intxnName2 .
FILTER (REGEX(STR(?intxnName2), "RO_0002208")) #keep interactions only if the interaction-id is RO_0002208 (parasitoidOf), e.g: 'parasitoidX' is 'parasitoidOf' 'parasiteX'
?parasitoidX emi:inTaxon ?parasitoidX_WD ; #retreieve wikidata-ids for parasitoidX
sosa:isSampleOf ?parasitoidName . #retrieve scientific name of parasitoidX as listed in GloBI
?parasiteX emi:inTaxon ?parasiteX_WD ; #retreieve wikidata-ids for parasiteX
sosa:isSampleOf ?parasiteName . #retreieve scientific name for parasiteX as listed in GloBI
}}
?parasiteX1 emi:inTaxon ?parasiteX_WD . #check pasarsiteX1 is in wikidata-id parasiteX_WD (the ones obtained from interaction-pairs part-1)
?intxn3 emi:hasSource ?parasiteX1 ; #retrieve interaction pairs part-2
emi:hasTarget ?hostPlant ;
emi:isClassifiedWith ?intxnName3 .
?intxnName3 rdfs:label ?intxn3Label .
?hostPlant emi:inTaxon ?hostPlant_WD ; #retreieve wikidata-ids for hostPlant
sosa:isSampleOf ?hostPlantName . #retreieve scientific name for hostPlant as listed in GloBI
FILTER (!(?intxn3Label IN ("visits", "visitsFlowersOf", "pollinates"))) #keep interactions only if the interaction-names are not 'visits', 'visitsFlowersOf' or 'pollinates'. e.g.: 'parasiteX1' is 'pathogenOf/parasiteOf/..' 'hostPlant'
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?hostPlant_WD wdt:P171* wd:Q879246 . #keep the interaction pairs part-2 only if hostPlant_WD has Kingdom Archaeplastida (wd:Q879246) in its lineage, this is to ensure the hostPlant is really a plant
}
BIND(REPLACE(STR(?parasiteName), "%20", " ") AS ?parasiteNameX) #remove percent encodings from parasite scientific name
BIND(IRI(?parasiteNameX) AS ?parasiteNameURI)
BIND(REPLACE(STR(?parasitoidName), "%20", " ") AS ?parasitoidNameX) #remove percent encodings from parasitoid scientific name
BIND(IRI(?parasitoidNameX) AS ?parasitoidNameURI)
BIND(REPLACE(STR(?hostPlantName), "%20", " ") AS ?hostPlantNameX) #remove percent encodings from hostPlant scientific name
BIND(IRI(?hostPlantNameX) AS ?hostPlantNameURI)
VALUES ?hostPlant_WD { wd:Q25408 } #filter on the host plant Achillea millefolium wikidata-id
} LIMIT 1000}
{ SELECT DISTINCT ?hostPlant_WD ?wd_chem ?structure_inchikey ?npcClass WHERE { #retrieve metabolite data
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?hostPlant_WD . #filter metabolite data which is found in wikidata-ids oh the host plant
?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 ?structure_inchikey ;
emi:hasClass ?npcClass .
?structure_inchikey emi:isInChIKeyOf ?wd_chem . #retrieve wikidata-ids for metabolites
FILTER (REGEX(STR(?npcClass), "TERPEN")) #keep if the class of metabolite is terpenes matches "TERPEN"
}} UNION #union with data from lotus (integrated in wikidata)
{ SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?structure_inchikey ;
wdt:P703 ?hostPlant_WD ;
((wdt:P31|wdt:P279)/(wdt:P279*)) ?class . #retrieve the class of the metabolite
VALUES ?class { wd:Q212364 wd:Q426694 } #keep if the class of metabolite is terpenes (wd:Q212364) or terpenoids(wd:Q426694)
}}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v35("?class")
v24("?extract")
v28("?feature")
v27("?feature_list")
v12("?hostPlant")
v15("?hostPlantName")
v21("?hostPlantNameURI"):::projected
v20("?hostPlantNameX")
v22("?hostPlant_WD"):::projected
v30("?ik2d")
v3("?intxn2")
v11("?intxn3")
v1("?intxn3Label"):::projected
v2("?intxnName2")
v13("?intxnName3")
v26("?lcms")
v23("?material")
v22("?npcClass")
v25("?organe")
v9("?parasiteName")
v17("?parasiteNameURI"):::projected
v16("?parasiteNameX")
v5("?parasiteX")
v10("?parasiteX1")
v8("?parasiteX_WD"):::projected
v7("?parasitoidName")
v19("?parasitoidNameURI"):::projected
v18("?parasitoidNameX")
v4("?parasitoidX")
v6("?parasitoidX_WD"):::projected
v29("?sirius_annotation")
v31("?smiles")
v32("?structure_inchikey"):::projected
v33("?wd_chem"):::projected
a1((" "))
c21(["emi:StructuralAnnotation"]):::iri
c13(["wd:Q879246"]):::iri
list0c1(["visits"]):::literal
list0c3(["pollinates"]):::literal
list0c2(["visitsFlowersOf"]):::literal
list0c1 --o f0
list0c2 --o f0
list0c3 --o f0
f0[["not in "]]
f0 --> v1
f1[["regex(str(?intxnName2),'RO_0002208')"]]
f1 --> v2
v3 --"emi:hasSource"--> v4
v3 --"emi:hasTarget"--> v5
v3 --"emi:isClassifiedWith"--> v2
v4 --"emi:inTaxon"--> v6
v4 --"sosa:isSampleOf"--> v7
v5 --"emi:inTaxon"--> v8
v5 --"sosa:isSampleOf"--> v9
v10 --"emi:inTaxon"--> v8
v11 --"emi:hasSource"--> v10
v11 --"emi:hasTarget"--> v12
v11 --"emi:isClassifiedWith"--> v13
v13 --"rdfs:label"--> v1
v12 --"emi:inTaxon"--> v22
v12 --"sosa:isSampleOf"--> v15
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
v22 --"wdt:P171"--> c13
end
bind2[/"replace(str(?parasiteName),'%20',' ')"/]
v9 --o bind2
bind2 --as--o v16
bind3[/"?parasiteNameX"/]
v16 --o bind3
bind3 --as--o v17
bind4[/"replace(str(?parasitoidName),'%20',' ')"/]
v7 --o bind4
bind4 --as--o v18
bind5[/"?parasitoidNameX"/]
v18 --o bind5
bind5 --as--o v19
bind6[/"replace(str(?hostPlantName),'%20',' ')"/]
v15 --o bind6
bind6 --as--o v20
bind7[/"?hostPlantNameX"/]
v20 --o bind7
bind7 --as--o v21
bind8[/VALUES ?hostPlant_WD/]
bind8-->v22
bind80(["wd:Q25408"])
bind80 --> bind8
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;
v33 --"wdt:P235"--> v32
v33 --"wdt:P703"--> v22
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v33 --"wdt:P279"--> a1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v33 --"wdt:P31"--> a1
end
union1r <== or ==> union1l
end
a1 --"wdt:P279"--> v35
bind9[/VALUES ?class/]
bind9-->v35
bind90(["wd:Q212364"])
bind90 --> bind9
bind91(["wd:Q426694"])
bind91 --> bind9
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f10[["regex(str(?npcClass),'TERPEN')"]]
f10 --> v22
v23 --"sosa:hasSample"--> v24
v23 --"sosa:isSampleOf"--> v25
v25 --"emi:inTaxon"--> v22
v24 --"sosa:isFeatureOfInterestOf"--> v26
v26 --"sosa:hasResult"--> v27
v27 --"emi:hasLCMSFeature"--> v28
v28 --"emi:hasAnnotation"--> v29
v29 --"a"--> c21
v29 --"emi:hasChemicalStructure"--> v30
v30 --"emi:hasSMILES"--> v31
v30 --"emi:isInChIKey2DOf"--> v32
v30 --"emi:hasClass"--> v22
v32 --"emi:isInChIKeyOf"--> v33
end
union0r <== or ==> union0l
end