A set of SPARQL examples that are used in different SIB resources
Distribution of reactions according to the first class of the enzyme classification (federated query)
PREFIX ec: <http://purl.uniprot.org/enzyme/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
# Query 11
# Retrieve the count of reactions mapped to each level (main class) of the enzyme classification
#
# This query mimics the Filter section of the Rhea website (Browse all reactions)
# https://www.rhea-db.org/rhea?query=
SELECT ?ecClass (STR(?ecName) AS ?ecClassName) (COUNT(?rhea) AS ?rheaCount)
WHERE {
SERVICE <https://sparql.uniprot.org/sparql> {
VALUES (?ecClass) { (ec:1.-.-.-)(ec:2.-.-.-)(ec:3.-.-.-)(ec:4.-.-.-)(ec:5.-.-.-) (ec:6.-.-.-) (ec:7.-.-.-)}
?ecNumber rdfs:subClassOf ?ecClass .
?ecClass skos:prefLabel ?ecName .
}
?rhea rdfs:subClassOf rh:Reaction .
?rhea rh:ec ?ecNumber .
} GROUP BY ?ecClass ?ecName
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?ecClass"):::projected
v5("?ecClassName")
v3("?ecName"):::projected
v2("?ecNumber")
v4("?rhea"):::projected
v6("?rheaCount")
c4(["rh:Reaction"]):::iri
subgraph s1["https://sparql.uniprot.org/sparql"]
style s1 stroke-width:4px;
bind0[/VALUES ?ecClass/]
bind0-->v1
bind00(["ec:1.-.-.-"])
bind00 --> bind0
bind01(["ec:2.-.-.-"])
bind01 --> bind0
bind02(["ec:3.-.-.-"])
bind02 --> bind0
bind03(["ec:4.-.-.-"])
bind03 --> bind0
bind04(["ec:5.-.-.-"])
bind04 --> bind0
bind05(["ec:6.-.-.-"])
bind05 --> bind0
bind06(["ec:7.-.-.-"])
bind06 --> bind0
v2 --"rdfs:subClassOf"--> v1
v1 --"skos:prefLabel"--> v3
end
v4 --"rdfs:subClassOf"--> c4
v4 --"rh:ec"--> v2
bind2[/"str(?ecName)"/]
v3 --o bind2
bind2 --as--o v5
bind3[/"count(?rhea)"/]
v4 --o bind3
bind3 --as--o v6