A set of SPARQL examples that are used in different SIB resources
List all metabolites produced by species with near threatened (wd:Q719675) IUCN status (wdt:P141) and with values available (or greater than a specific value) for trait 'Seed dry mass'.
PREFIX emi: <https://purl.org/emi#>
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 sosa: <http://www.w3.org/ns/sosa/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?structure_inchikey ?wd_chem ?source_wdx ?sourceNameURI WHERE {
?trySpObs sosa:isSampleOf ?trySpName ; #retrieve trait/non-trait data for trySpName (scientific name of plant species as listed in trydb)
sosa:isFeatureOfInterestOf ?tryObId .
?tryObId sosa:hasResult ?tryData .
?trySpName emi:inTaxon ?source_wdx . #retrieve wikidata-ids wdx for trySpName
?tryData rdfs:label ?tryDataLab ;
rdf:type emi:Trait ; #retrieve data which is labelled as "Trait"
rdf:value ?tryDataVal . #retrieve values for Trait data
FILTER (?tryDataLab = "Seed dry mass" ) #filter on data label 'Seed dry mass'
FILTER (?tryDataVal >= 626) #filter on data value >= 626
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?source_wdx wdt:P141 wd:Q719675 . #filter wikidata-ids for trySpName, which have IUCN status (wdt:P141) as near threatened (wd:Q719675)
}
BIND(REPLACE(STR(?trySpName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for scientific names of trySpName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
{ SELECT ?source_wdx ?structure_inchikey ?wd_chem 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 ?structure_inchikey .
?structure_inchikey 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 ?structure_inchikey;
wdt:P703 ?source_wdx .
}}
} LIMIT 1000
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?extract")
v15("?feature")
v14("?feature_list")
v17("?ik2d")
v13("?lcms")
v10("?material")
v12("?organe")
v16("?sirius_annotation")
v18("?smiles")
v9("?sourceNameURI"):::projected
v8("?sourceNameX")
v7("?source_wdx"):::projected
v19("?structure_inchikey"):::projected
v6("?tryData")
v2("?tryDataLab")
v1("?tryDataVal")
v5("?tryObId")
v4("?trySpName")
v3("?trySpObs")
v20("?wd_chem"):::projected
c9(["emi:Trait"]):::iri
c17(["emi:StructuralAnnotation"]):::iri
c13(["wd:Q719675"]):::iri
f0[["?tryDataVal >= '626^^xsd:integer'"]]
f0 --> v1
f1[["?tryDataLab = 'Seed dry mass'"]]
f1 --> v2
v3 --"sosa:isSampleOf"--> v4
v3 --"sosa:isFeatureOfInterestOf"--> v5
v5 --"sosa:hasResult"--> v6
v4 --"emi:inTaxon"--> v7
v6 --"rdfs:label"--> v2
v6 --"a"--> c9
v6 --"rdf:value"--> v1
subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
style s1 stroke-width:4px;
v7 --"wdt:P141"--> c13
end
bind2[/"replace(str(?trySpName),'%20',' ')"/]
v4 --o bind2
bind2 --as--o v8
bind3[/"?sourceNameX"/]
v8 --o bind3
bind3 --as--o v9
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;
v20 --"wdt:P235"--> v19
v20 --"wdt:P703"--> v7
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v10 --"sosa:hasSample"--> v11
v10 --"sosa:isSampleOf"--> v12
v12 --"emi:inTaxon"--> v7
v11 --"sosa:isFeatureOfInterestOf"--> v13
v13 --"sosa:hasResult"--> v14
v14 --"emi:hasLCMSFeature"--> v15
v15 --"emi:hasAnnotation"--> v16
v16 --"a"--> c17
v16 --"emi:hasChemicalStructure"--> v17
v17 --"emi:hasSMILES"--> v18
v17 --"emi:isInChIKey2DOf"--> v19
v19 --"emi:isInChIKeyOf"--> v20
end
union0r <== or ==> union0l
end