@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:37_Select_the_number_of_reactions_with_cross-references_to_MetaCyc a sh:SPARQLExecutable,
    sh:SPARQLSelectExecutable;
  rdfs:comment "Select the number of reactions with cross-references to MetaCyc"@en;
  sh:select """PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_>
PREFIX up:<http://purl.uniprot.org/core/>
PREFIX keywords:<http://purl.uniprot.org/keywords/>
PREFIX taxon:<http://purl.uniprot.org/taxonomy/>

SELECT
  (count(distinct ?rhea) as ?rheaMetacycCount)
  (count(distinct ?xref) as ?metacycRheaCount)
  (count(?rhea) as ?rheaMetacycXrefCount)
WHERE {
  ?rhea rdfs:subClassOf rh:Reaction .
  ?rhea rh:status rh:Approved .
  ?rhea rh:directionalReaction ?directionalReaction .
  ?rhea rh:bidirectionalReaction ?bidirectionalReaction .
  {
    ?directionalReaction rdfs:seeAlso ?xref .
    FILTER regex(str(?xref), \"METACYC\") .
  }
  UNION
  {
    ?bidirectionalReaction rdfs:seeAlso ?xref .
    FILTER regex(str(?xref), \"METACYC\") .
  }
  UNION
  {
    ?rhea rdfs:seeAlso ?xref .
    FILTER regex(str(?xref), \"METACYC\") .
  }
}""";
  schema:target <https://sparql.rhea-db.org/sparql> .
