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 ?parasitoidX_WD ?parasitoidNameURI ?intxn2Label ?parasiteX_WD ?parasiteNameURI ?intxn3Label ?hostPlant_WD ?hostPlantNameURI ?study1_DOI ?study2_DOI
WHERE {
{ SELECT DISTINCT ?parasitoidName ?parasiteName ?parasiteX_WD ?intxn2Label ?parasitoidX_WD ?study1_DOI 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'
?intxnName2 rdfs:label ?intxn2Label .
?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
OPTIONAL {
?intxn2 dcterms:bibliographicCitation ?study1_DOI . #optionally retrieve the doi of the study for parasitoid-parasite pairs
}
}}
?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
OPTIONAL {
?intxn3 dcterms:bibliographicCitation ?study2_DOI .
}
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)
} LIMIT 1000
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v14("?hostPlant")
v17("?hostPlantName")
v24("?hostPlantNameURI"):::projected
v23("?hostPlantNameX")
v16("?hostPlant_WD"):::projected
v3("?intxn2")
v6("?intxn2Label"):::projected
v13("?intxn3")
v1("?intxn3Label"):::projected
v2("?intxnName2")
v15("?intxnName3")
v10("?parasiteName")
v20("?parasiteNameURI"):::projected
v19("?parasiteNameX")
v5("?parasiteX")
v12("?parasiteX1")
v9("?parasiteX_WD"):::projected
v8("?parasitoidName")
v22("?parasitoidNameURI"):::projected
v21("?parasitoidNameX")
v4("?parasitoidX")
v7("?parasitoidX_WD"):::projected
v11("?study1_DOI"):::projected
v18("?study2_DOI"):::projected
c14(["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
v2 --"rdfs:label"--> v6
v4 --"emi:inTaxon"--> v7
v4 --"sosa:isSampleOf"--> v8
v5 --"emi:inTaxon"--> v9
v5 --"sosa:isSampleOf"--> v10
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."dcterms:bibliographicCitation".-> v11
end
v12 --"emi:inTaxon"--> v9
v13 --"emi:hasSource"--> v12
v13 --"emi:hasTarget"--> v14
v13 --"emi:isClassifiedWith"--> v15
v15 --"rdfs:label"--> v1
v14 --"emi:inTaxon"--> v16
v14 --"sosa:isSampleOf"--> v17
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v13 -."dcterms:bibliographicCitation".-> v18
end
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
v16 --"wdt:P171"--> c14
end
bind2[/"replace(str(?parasiteName),'%20',' ')"/]
v10 --o bind2
bind2 --as--o v19
bind3[/"?parasiteNameX"/]
v19 --o bind3
bind3 --as--o v20
bind4[/"replace(str(?parasitoidName),'%20',' ')"/]
v8 --o bind4
bind4 --as--o v21
bind5[/"?parasitoidNameX"/]
v21 --o bind5
bind5 --as--o v22
bind6[/"replace(str(?hostPlantName),'%20',' ')"/]
v17 --o bind6
bind6 --as--o v23
bind7[/"?hostPlantNameX"/]
v23 --o bind7
bind7 --as--o v24