A set of SPARQL examples that are used in different SIB resources
Distribution: number of reaction participants per reaction Side
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
SELECT
?reaction
?reactionSide1
(count(distinct ?participant1) as ?side1ParticipantCount)
?reactionSide2
(count(distinct ?participant2) as ?side2ParticipantCount)
WHERE {
?reaction rdfs:subClassOf rh:Reaction .
?reaction rh:status rh:Approved .
?reaction rh:side ?reactionSide1 .
?reactionSide1 rh:contains ?participant1 .
?reaction rh:side ?reactionSide2 .
?reactionSide2 rh:contains ?participant2 .
?reactionSide1 rh:transformableTo ?reactionSide2
}
GROUP BY ?reaction ?reactionSide1 ?reactionSide2
ORDER BY ?reaction
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?participant1"):::projected
v5("?participant2"):::projected
v1("?reaction"):::projected
v2("?reactionSide1"):::projected
v4("?reactionSide2"):::projected
v6("?side1ParticipantCount")
v7("?side2ParticipantCount")
c4(["rh:Approved"]):::iri
c2(["rh:Reaction"]):::iri
v1 --"rdfs:subClassOf"--> c2
v1 --"rh:status"--> c4
v1 --"rh:side"--> v2
v2 --"rh:contains"--> v3
v1 --"rh:side"--> v4
v4 --"rh:contains"--> v5
v2 --"rh:transformableTo"--> v4
bind2[/"count(?participant1)"/]
v3 --o bind2
bind2 --as--o v6
bind3[/"count(?participant2)"/]
v5 --o bind3
bind3 --as--o v7