sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

109_Distribution_of_reactions_according_to_the_first_level_of_enzyme_classification

rq turtle/ttl

Distribution of reactions according to the first level of enzyme classification

Use at


PREFIX rh:<http://rdf.rhea-db.org/>
PREFIX ec:<http://purl.uniprot.org/enzyme/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>

SELECT
  ?ecClass
  (str(?ecName) as ?ecClassName)
  (count(?reaction) as ?reactionCount)
WHERE
{
  SERVICE <http://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 .
  }
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction 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("?reaction"):::projected 
  v6("?reactionCount")
  c4(["rh:Reaction"]):::iri 
  subgraph s1["http://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(?reaction)"/]
  v4 --o bind3
  bind3 --as--o v6