A set of SPARQL examples that are used in different SIB resources
List of possible natural locations of organisms, which produce Bahamaolide A, (wd:Q75068439) which is an antifungal (https://doi.org/10.1021/np3001915).
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://w3id.org/emi#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT ?organismName ?organismWD ?loc ?lats ?longs WHERE {
# metabolite data
{
SELECT DISTINCT ?organismWD ?organismName WHERE {
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?organismWD ; # filter metabolite data which is found in wikidata-ids wdx
rdfs:label ?organismName .
?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 . # retrieve wikidata-ids for metabolites
VALUES ?wd_chem { wd:Q75068439 } # filter wikidata_id of metabolites matches wd:Q75068439
}
} UNION #union with data from lotus (integrated in wikidata)
{
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?ik ;
wdt:P703 ?organismWD .
VALUES ?wd_chem { wd:Q75068439 }
OPTIONAL { ?organismWD wdt:P225 ?organismName . }
}
}
# interaction data
FILTER(?organismWD = ?source_wdx || ?organismWD = ?target_wdx) # ensure that organism-wd is either from source or target
?intxn emi:hasSource ?source ; #retrieve interaction-pairs
emi:hasTarget ?target .
?source emi:inTaxon ?source_wdx . # retrieve wikidata-id of source
?target emi:inTaxon ?target_wdx . # retrieve wikidata-id of target
?intxn prov:atLocation ?loc ; # retrieve the location of the interaction, and the latitude/longitude
wgs:lat ?lats ;
wgs:long ?longs .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?extract")
v10("?feature")
v9("?feature_list")
v14("?ik")
v12("?ik2d")
v16("?intxn")
v20("?lats"):::projected
v8("?lcms")
v19("?loc"):::projected
v21("?longs"):::projected
v4("?material")
v6("?organe")
v7("?organismName"):::projected
v1("?organismWD"):::projected
v11("?sirius_annotation")
v13("?smiles")
v17("?source")
v2("?source_wdx")
v18("?target")
v3("?target_wdx")
v16("?wd_chem")
c10(["emi:StructuralAnnotation"]):::iri
f0[["(?organismWD = ?source_wdx || ?organismWD = ?target_wdx)"]]
f0 --> v1
f0 --> v2
f0 --> v3
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;
v16 --"wdt:P235"--> v14
v16 --"wdt:P703"--> v1
bind1[/VALUES ?wd_chem/]
bind1-->v16
bind10(["wd:Q75068439"])
bind10 --> bind1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P225".-> v7
end
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"sosa:hasSample"--> v5
v4 --"sosa:isSampleOf"--> v6
v6 --"emi:inTaxon"--> v1
v6 --"rdfs:label"--> v7
v5 --"sosa:isFeatureOfInterestOf"--> v8
v8 --"sosa:hasResult"--> v9
v9 --"emi:hasLCMSFeature"--> v10
v10 --"emi:hasAnnotation"--> v11
v11 --"a"--> c10
v11 --"emi:hasChemicalStructure"--> v12
v12 --"emi:hasSMILES"--> v13
v12 --"emi:isInChIKey2DOf"--> v14
v14 --"emi:isInChIKeyOf"--> v16
bind2[/VALUES ?wd_chem/]
bind2-->v16
bind20(["wd:Q75068439"])
bind20 --> bind2
end
union0r <== or ==> union0l
end
v16 --"emi:hasSource"--> v17
v16 --"emi:hasTarget"--> v18
v17 --"emi:inTaxon"--> v2
v18 --"emi:inTaxon"--> v3
v16 --"prov:atLocation"--> v19
v16 --"wgs:lat"--> v20
v16 --"wgs:long"--> v21