A set of SPARQL examples that are used in different TGX resources
Summarizes IEM community pathways with counts of proteins, metabolites, Rhea reaction annotations, missing Rhea IDs, and linked OMIM disease identifiers per pathway.
PREFIX cur: <http://vocabularies.wikipathways.org/wp#Curation:>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX gpml: <http://vocabularies.wikipathways.org/gpml#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
#Variable selection
SELECT DISTINCT (str(?title) as ?pathwayName) ?PWID
(count(distinct ?geneProduct) AS ?ProteinsInPWs) (count(distinct ?metaboliteNode) AS ?MetabolitesInPWs)
(count(distinct ?interactionID) AS ?RheaInPWs) (count(distinct ?interactionMissing) AS ?NoRheaInPWs)
(count(distinct ?omim) as ?diseaseIDs)
WHERE {
?pathway wp:ontologyTag cur:IEM .
?pathway dcterms:identifier ?PWID. #Obtain the ID
?pathway wp:isAbout ?gpmlRDF_ID . #find the corresponding GPML link
?pathway dc:title ?title . #Obtain the title
{
?geneProduct dcterms:isPartOf ?pathway . #Only those part of PW
?geneProduct a wp:Protein . #Filter for Protein DataNodes
}
UNION
{
?metaboliteNode a wp:Metabolite . #Filter for Metabolite DataNodes
?metaboliteNode dcterms:isPartOf ?pathway . #Only those part of PW
}
UNION
{
OPTIONAL{?interaction wp:bdbRhea ?interactionID . #Find interactions with a Rhea ID
?interaction dcterms:isPartOf ?pathway .} #Only those part of PW
}
UNION
{
OPTIONAL{?interactionMissing dcterms:isPartOf ?pathway . #Find additional interactions
?interactionMissing rdf:type wp:Conversion . #That are of type 'metabolic conversion'
FILTER NOT EXISTS {?interactionMissing wp:bdbRhea ?interactionID . } #Without a Rhea ID
}
}
UNION {
?diseaseNode dcterms:isPartOf ?gpmlRDF_ID . #Only check for matching pathways
?diseaseNode rdf:type gpml:Label . #Only include textLabels
?diseaseNode gpml:href ?omim . #That have an href attribute
FILTER regex(?omim, "omim.org", "i") #Only keep hrefs if they contain 'omim.org'
}
} GROUP BY ?pathway ?title ?PWID
ORDER BY ASC(?pathway)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v14("?MetabolitesInPWs")
v16("?NoRheaInPWs")
v2("?PWID"):::projected
v13("?ProteinsInPWs")
v15("?RheaInPWs")
v17("?diseaseIDs")
v11("?diseaseNode")
v5("?geneProduct"):::projected
v3("?gpmlRDF_ID")
v7("?interaction")
v8("?interactionID"):::projected
v9("?interactionMissing"):::projected
v6("?metaboliteNode"):::projected
v10("?omim"):::projected
v1("?pathway")
v12("?pathwayName")
v4("?title"):::projected
c2(["wp:Curation:IEM"]):::iri
c8(["wp:Protein"]):::iri
c14(["gpml:Label"]):::iri
c9(["wp:Metabolite"]):::iri
c11(["wp:Conversion"]):::iri
v1 --"wp:ontologyTag"--> c2
v1 --"dcterms:identifier"--> v2
v1 --"wp:isAbout"--> v3
v1 --"dc:title"--> v4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
f0[["regex(?omim,'omim.org','i')"]]
f0 --> v10
v11 --"dcterms:isPartOf"--> v3
v11 --"a"--> c14
v11 --"gpml:href"--> v10
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v9 -."dcterms:isPartOf".-> v1
v9 --"a"--> c11
end
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wp:bdbRhea".-> v8
v7 --"dcterms:isPartOf"--> v1
end
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v6 --"a"--> c9
v6 --"dcterms:isPartOf"--> v1
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v5 --"dcterms:isPartOf"--> v1
v5 --"a"--> c8
end
union0r <== or ==> union0l
end
bind6[/"str(?title)"/]
v4 --o bind6
bind6 --as--o v12
bind7[/"count(?geneProduct)"/]
v5 --o bind7
bind7 --as--o v13
bind8[/"count(?metaboliteNode)"/]
v6 --o bind8
bind8 --as--o v14
bind9[/"count(?interactionID)"/]
v8 --o bind9
bind9 --as--o v15
bind10[/"count(?interactionMissing)"/]
v9 --o bind10
bind10 --as--o v16
bind11[/"count(?omim)"/]
v10 --o bind11
bind11 --as--o v17