A set of SPARQL examples that are used in different TGX resources
Extracts directed metabolite-to-metabolite interactions from human pathways in the AnalysisCollection, returning source and target identifiers, interaction types, and Rhea IDs as part of the DSMN workflow. This example uses the default value (Species "Homo sapiens"); the WikiPathways SNORQL UI lets you change it.
PREFIX cur: <http://vocabularies.wikipathways.org/wp#Curation:>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
### Part 1: ###
SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?mimtype
?pathway (str(?titleLit) as ?title)
?sourceCHEBI ?targetDbCHEBI ?sourceHMDB ?targetDbHMDB ?InteractionID
WHERE {
### Part 2: ###
?pathway a wp:Pathway ;
wp:organismName "Homo sapiens" ;
dc:title ?titleLit .
### Part 3A: ###
FILTER (EXISTS {?pathway wp:ontologyTag cur:AnalysisCollection}) .
### Part 3B: ###
#FILTER (EXISTS {?pathway wp:ontologyTag cur:Reactome_Approved}) .
### Part 3C: ###
#FILTER (EXISTS {?pathway wp:ontologyTag cur:Lipids}) .
### Part 4: ###
?interaction dcterms:isPartOf ?pathway ;
a wp:DirectedInteraction ;
wp:source ?source ;
wp:target ?target .
OPTIONAL{?interaction a ?mimtype}.
VALUES ?mimtype {wp:ComplexBinding wp:Conversion wp:Inhibition wp:Catalysis
wp:Stimulation wp:TranscriptionTranslation wp:DirectedInteraction} .
### Part 5: ###
?source a wp:Metabolite .
?source wp:bdbWikidata ?sourceDb .
OPTIONAL{?source wp:bdbChEBI ?sourceCHEBI}.
OPTIONAL{?source wp:bdbHmdb ?sourceHMDB}.
?target a wp:Metabolite .
?target wp:bdbWikidata ?targetDb .
OPTIONAL{?target wp:bdbChEBI ?targetDbCHEBI}.
OPTIONAL{?target wp:bdbHmdb ?targetDbHMDB}.
### Part 6: ###
OPTIONAL{?interaction wp:bdbRhea ?InteractionID} .
} ORDER BY DESC(?InteractionID)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?InteractionID"):::projected
v4("?interaction"):::projected
v8("?mimtype"):::projected
v2("?pathway"):::projected
v5("?source")
v9("?sourceCHEBI"):::projected
v8("?sourceDb"):::projected
v10("?sourceHMDB"):::projected
v6("?target")
v11("?targetDb"):::projected
v12("?targetDbCHEBI"):::projected
v13("?targetDbHMDB"):::projected
v14("?title")
v3("?titleLit"):::projected
c9(["wp:DirectedInteraction"]):::iri
c6(["Homo sapiens"]):::literal
c4(["wp:Pathway"]):::iri
c12(["wp:Metabolite"]):::iri
c2(["wp:Curation:AnalysisCollection"]):::iri
f0[[" "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wp:ontologyTag"--> e0c2
e0v1("?pathway"):::projected
e0c2(["wp:Curation:AnalysisCollection"]):::iri
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> c1
f0 --> c2
v2 --"wp:ontologyTag"--> c2
v2 --"a"--> c4
v2 --"wp:organismName"--> c6
v2 --"dc:title"--> v3
v4 --"dcterms:isPartOf"--> v2
v4 --"a"--> c9
v4 --"wp:source"--> v5
v4 --"wp:target"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."a".-> v8
end
bind1[/VALUES ?mimtype/]
bind1-->v8
bind10(["wp:ComplexBinding"])
bind10 --> bind1
bind11(["wp:Conversion"])
bind11 --> bind1
bind12(["wp:Inhibition"])
bind12 --> bind1
bind13(["wp:Catalysis"])
bind13 --> bind1
bind14(["wp:Stimulation"])
bind14 --> bind1
bind15(["wp:TranscriptionTranslation"])
bind15 --> bind1
bind16(["wp:DirectedInteraction"])
bind16 --> bind1
v5 --"a"--> c12
v5 --"wp:bdbWikidata"--> v8
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wp:bdbChEBI".-> v9
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wp:bdbHmdb".-> v10
end
v6 --"a"--> c12
v6 --"wp:bdbWikidata"--> v11
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wp:bdbChEBI".-> v12
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wp:bdbHmdb".-> v13
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wp:bdbRhea".-> v1
end
bind2[/"str(?titleLit)"/]
v3 --o bind2
bind2 --as--o v14