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 qudt: <https://qudt.org/2.1/schema/qudt#>
PREFIX npc: <https://purl.org/npc#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?source_wdx ?sourceNameURI ?tryDataLab ?tryDataVal ?unit ?unitComment WHERE {
{ SELECT DISTINCT ?source_wdx WHERE { #retrieve metabolite data
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?source_wdx . #filter metabolite data which is found in wikidata-ids wdx
?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 ;
emi:hasClass ?npcClass .
?npcClass skos:broader ?npcSuperClass .
?ik emi:isInChIKeyOf ?wd_chem . #retrieve wikidata-ids for metabolites
FILTER (REGEX(STR(?npcSuperClass), "DITERPENOIDS"))
}} 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:P31|wdt:P279)/(wdt:P279*)) wd:Q47006367 ; #check if the class/superclass of the chemical is Diterpenoids
wdt:P703 ?source_wdx .
}}
?trySpName emi:inTaxon ?wdx .
?trySpObs sosa:isSampleOf ?trySpName ; #retrieve trait/non-trait data for trySpName (scientific name of plant species as listed in trydb)
sosa:isFeatureOfInterestOf ?tryObId .
?trySpName emi:inTaxon ?source_wdx . #retrieve wikidata-ids wdx for trySpName
?tryObId sosa:hasResult ?tryData .
?tryData rdfs:label ?tryDataLab ;
rdf:type emi:Trait ; #retrieve data which is labelled as "Trait"
rdf:value ?tryDataVal ; #retrieve values for Trait data
qudt:hasUnit ?unit ; #retrieve units for trait data
rdfs:comment ?unitComment . #retrieve original units for Trait data as listed in trydb
BIND(REPLACE(STR(?trySpName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for scientific names of trySpName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?extract")
v8("?feature")
v7("?feature_list")
v12("?ik")
v10("?ik2d")
v6("?lcms")
v2("?material")
v13("?npcClass")
v1("?npcSuperClass")
v4("?organe")
v9("?sirius_annotation")
v11("?smiles")
v26("?sourceNameURI"):::projected
v25("?sourceNameX")
v5("?source_wdx"):::projected
v15("?structure_inchikey")
v20("?tryData")
v21("?tryDataLab"):::projected
v22("?tryDataVal"):::projected
v19("?tryObId")
v16("?trySpName")
v18("?trySpObs")
v23("?unit"):::projected
v24("?unitComment"):::projected
v14("?wd_chem")
v17("?wdx")
a1((" "))
c24(["emi:Trait"]):::iri
c10(["emi:StructuralAnnotation"]):::iri
c21(["wd:Q47006367"]):::iri
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;
v14 --"wdt:P235"--> v15
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v14 --"wdt:P279"--> a1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v14 --"wdt:P31"--> a1
end
union1r <== or ==> union1l
end
a1 --"wdt:P279"--> c21
v14 --"wdt:P703"--> v5
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f0[["regex(str(?npcSuperClass),'DITERPENOIDS')"]]
f0 --> v1
v2 --"sosa:hasSample"--> v3
v2 --"sosa:isSampleOf"--> v4
v4 --"emi:inTaxon"--> v5
v3 --"sosa:isFeatureOfInterestOf"--> v6
v6 --"sosa:hasResult"--> v7
v7 --"emi:hasLCMSFeature"--> v8
v8 --"emi:hasAnnotation"--> v9
v9 --"a"--> c10
v9 --"emi:hasChemicalStructure"--> v10
v10 --"emi:hasSMILES"--> v11
v10 --"emi:isInChIKey2DOf"--> v12
v10 --"emi:hasClass"--> v13
v13 --"skos:broader"--> v1
v12 --"emi:isInChIKeyOf"--> v14
end
union0r <== or ==> union0l
end
v16 --"emi:inTaxon"--> v17
v18 --"sosa:isSampleOf"--> v16
v18 --"sosa:isFeatureOfInterestOf"--> v19
v16 --"emi:inTaxon"--> v5
v19 --"sosa:hasResult"--> v20
v20 --"rdfs:label"--> v21
v20 --"a"--> c24
v20 --"rdf:value"--> v22
v20 --https://qudt.org/2.1/schema/qudt#hasUnit--> v23
v20 --"rdfs:comment"--> v24
bind1[/"replace(str(?trySpName),'%20',' ')"/]
v16 --o bind1
bind1 --as--o v25
bind2[/"?sourceNameX"/]
v25 --o bind2
bind2 --as--o v26