@prefix dcterms: <http://purl.org/dc/terms/> .
@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#> .

ex:113_UniProtKB_Swiss-Prot_entries_annotated_with_CC-CA_Rhea_involving_lipids.ttl a sh:SPARQLExecutable,
    sh:SPARQLSelectExecutable;
  rdfs:comment "UniProtKB/Swiss-Prot entries annotated with CC-CA/Rhea involving lipids"@en;
  sh:select """PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# select all pairs (sprot,rhea) where rhea involves a lipid
PREFIX rh:<http://rdf.rhea-db.org/>
PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_>
PREFIX up:<http://purl.uniprot.org/core/>
PREFIX uniprotkb:<http://purl.uniprot.org/uniprot/>

SELECT 
  (COUNT(*) as ?cnt) 
WHERE 
{
  {
    SELECT ?protein ?rhea 
    WHERE {
      SERVICE <https://sparql.rhea-db.org/sparql> {
        SELECT 
          distinct 
           ?rhea 
        WHERE {
          ?rhea rdfs:subClassOf rh:Reaction .
          ?rhea rh:status rh:Approved .
          ?rhea rh:side ?reactionSide .
          ?reactionSide rh:contains ?participant .
          ?participant rh:compound ?compound .
          ?compound rh:chebi ?chebi .
          ?chebi rdfs:subClassOf+ CHEBI:18059 .
        }
      }
    }
  }
  ?protein a up:Protein .
  ?protein up:reviewed true .
  ?protein up:annotation ?a .
  ?a a up:Catalytic_Activity_Annotation .
  ?a up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?rhea .
}""";
  <https://purl.expasy.org/sparql-examples/ontology#federatesWith> <https://sparql.rhea-db.org/sparql>;
  schema:target <https://sparql.uniprot.org/sparql> .
