sparql-examples

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

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

18

Select the number of UniProtKB entries for each of the EC (Enzyme Commission) top level categories

Use at

PREFIX ec: <http://purl.uniprot.org/enzyme/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>

SELECT ?ecClass (COUNT(?protein) as ?size)
WHERE
{
    VALUES (?ecClass) {(ec:1.-.-.-) (ec:2.-.-.-) (ec:3.-.-.-) (ec:4.-.-.-) (ec:5.-.-.-) (ec:6.-.-.-) (ec:7.-.-.-)} .
    ?protein ( up:enzyme | up:domain/up:enzyme | up:component/up:enzyme ) ?enzyme .
    # Enzyme subclasses are materialized, do not use rdfs:subClassOf+
    ?enzyme rdfs:subClassOf ?ecClass .
}
GROUP BY ?ecClass ORDER BY ?ecClass
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?ecClass"):::projected 
  v3("?enzyme")
  v2("?protein"):::projected 
  v4("?size")
  a1((" "))
  a2((" "))
  bind0[/VALUES ?ecClass/]
  bind0-->v2
  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
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph union1[" Union "]
    subgraph union1l[" "]
      style union1l fill:#abf,stroke-dasharray: 3 3;
      v2 --"up:component"-->  a2
      a2 --"up:enzyme"-->  v3
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      v2 --"up:domain"-->  a1
      a1 --"up:enzyme"-->  v3
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v2 --"up:enzyme"-->  v3
  end
  union0r <== or ==> union0l
  end
  v3 --"rdfs:subClassOf"-->  v2
  bind2[/"count(?protein)"/]
  v2 --o bind2
  bind2 --as--o v4