A set of SPARQL examples that are used in different SIB resources
Select parent reactions, give the number of child and descendant reactions
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
SELECT
?reaction
(count(?ancestorReaction) as ?ancestorReactionCount)
WHERE {
?reaction rdfs:subClassOf rh:Reaction .
?reaction rh:status rh:Approved .
?ancestorReaction rdfs:subClassOf rh:Reaction .
?ancestorReaction rh:status rh:Approved .
?reaction rdfs:subClassOf+ ?ancestorReaction .
}
GROUP BY ?reaction
ORDER BY (count(?ancestorReaction))
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?_anon_ec727cdef44145fc8400f88674993a197936")
v2("?ancestorReaction"):::projected
v4("?ancestorReactionCount")
v1("?reaction"):::projected
a1((" "))
c4(["rh:Approved"]):::iri
c2(["rh:Reaction"]):::iri
v1 --"rdfs:subClassOf"--> c2
v1 --"rh:status"--> c4
v2 --"rdfs:subClassOf"--> c2
v2 --"rh:status"--> c4
v1 --"rdfs:subClassOf"--> v2
bind2[/"count(?ancestorReaction)"/]
v2 --o bind2
bind2 --as--o v3
bind3[/"count(?ancestorReaction)"/]
v2 --o bind3
bind3 --as--o v4