@prefix ex: <https://sparql.rhea-db.org/.well-known/sparql-examples/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:12 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Select all Rhea reactions linked to protein sequences (enzymes and transporters) in UniProtKB"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX up: <http://purl.uniprot.org/core/>

# Query 12
# Select all Rhea reactions used to annotate enzyme sequences in UniProtKB
# return the number of UniProtKB entries
# Federated query using a service to UniProt SPARQL endpoint
#
# This query corresponds to the Rhea website query:
# https://www.rhea-db.org/rhea?query=uniprot:*
#
SELECT ?uniprotCount ?rhea ?accession ?equation 
WHERE {
  SERVICE <https://sparql.uniprot.org/sparql> { 
  	SELECT ?rhea (count(?uniprot) as ?uniprotCount) {
      ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea . 
  	}
  	GROUP BY ?rhea
  }
  ?rhea rh:accession ?accession .
  ?rhea rh:equation ?equation .
}""" ;
    schema:target <https://sparql.rhea-db.org/sparql> ;
    spex:federatesWith <https://sparql.uniprot.org/sparql> .

