A set of SPARQL examples that are used in different SIB resources
Select all compounds and count their occurrence in Rhea reactions
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT
?reactionParticipantAc
?chebi
(count(distinct ?reaction) as ?reactionCount)
?reactionParticipantName
WHERE {
?reaction rdfs:subClassOf rh:Reaction .
?reaction rh:status rh:Approved .
?reaction rh:side ?reactionSide .
?reactionSide rh:contains ?participant .
?participant rh:compound ?compound .
OPTIONAL {
?compound rh:chebi ?chebi .
}
?compound rh:name ?reactionParticipantName .
?compound rh:accession ?reactionParticipantAc .
}
GROUP BY ?reactionParticipantAc ?chebi ?reactionParticipantName
ORDER BY DESC(?reactionCount)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?chebi"):::projected
v5("?compound")
v4("?participant")
v2("?reaction"):::projected
v9("?reactionCount")
v8("?reactionParticipantAc"):::projected
v7("?reactionParticipantName"):::projected
v3("?reactionSide")
c4(["rh:Approved"]):::iri
c2(["rh:Reaction"]):::iri
v2 --"rdfs:subClassOf"--> c2
v2 --"rh:status"--> c4
v2 --"rh:side"--> v3
v3 --"rh:contains"--> v4
v4 --"rh:compound"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."rh:chebi".-> v6
end
v5 --"rh:name"--> v7
v5 --"rh:accession"--> v8
bind1[/"count(?reaction)"/]
v2 --o bind1
bind1 --as--o v9