A set of SPARQL examples that are used in different SIB resources
Number of reactions that have parent and child reactions
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
SELECT ?reaction
(count(distinct ?reactionChild) as ?reactionChildCount)
(count(distinct ?reactionDescendant) as ?reactionDescendantCount)
?equation
WHERE {
?reaction rdfs:subClassOf rh:Reaction .
?reaction rh:status rh:Approved .
?reaction rh:equation ?equation .
?reactionChild rdfs:subClassOf rh:Reaction .
?reactionChild rh:status rh:Approved .
?reactionDescendant rdfs:subClassOf rh:Reaction .
?reactionDescendant rh:status rh:Approved .
?reaction ^rdfs:subClassOf ?reactionChild .
?reaction ^rdfs:subClassOf+ ?reactionDescendant .
}
GROUP BY ?reaction ?equation
ORDER BY DESC (count(?reactionChild))
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?_anon_3b93fb9548914f3581febfeabf3844491476")
v2("?equation"):::projected
v1("?reaction"):::projected
v3("?reactionChild"):::projected
v6("?reactionChildCount")
v4("?reactionDescendant"):::projected
v7("?reactionDescendantCount")
a1((" "))
c4(["rh:Approved"]):::iri
c2(["rh:Reaction"]):::iri
v1 --"rdfs:subClassOf"--> c2
v1 --"rh:status"--> c4
v1 --"rh:equation"--> v2
v3 --"rdfs:subClassOf"--> c2
v3 --"rh:status"--> c4
v4 --"rdfs:subClassOf"--> c2
v4 --"rh:status"--> c4
v3 --"rdfs:subClassOf"--> v1
v4 --"rdfs:subClassOf"--> v1
bind3[/"count(?reactionChild)"/]
v3 --o bind3
bind3 --as--o v5
bind4[/"count(?reactionChild)"/]
v3 --o bind4
bind4 --as--o v6
bind5[/"count(?reactionDescendant)"/]
v4 --o bind5
bind5 --as--o v7