@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:10 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Select all Rhea reactions linked to an enzyme classification (sub)-class"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX ec: <http://purl.uniprot.org/enzyme/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>

# Query 10
# Select all Rhea reactions mapped to 
# 
# This query corresponds to the Rhea website query:
# https://www.rhea-db.org/rhea?query=ec:1.*
# https://www.rhea-db.org/rhea?query=ec:1.1.*
# https://www.rhea-db.org/rhea?query=ec:1.1.1.*
#
SELECT ?ec ?ecNumber ?rhea ?accession ?equation
WHERE {
  ?rhea rdfs:subClassOf rh:Reaction .
  ?rhea rh:accession ?accession .
  ?rhea rh:ec ?ec .
  BIND(strafter(str(?ec),str(ec:)) as ?ecNumber)
  # class (e.g EC 1.-.-.-)
  FILTER (regex(?ecNumber,'^1\\\\.')) 
  # sub-class  (e.g EC 1.1.-.-)
  #FILTER (regex(?ecNumber,'^1\\\\.1\\\\.')) 
  # sub-sub-class (e.g EC 1.1.1.-)
  #FILTER (regex(?ecNumber,'^1\\\\.1\\\\.1\\\\.')) 
  ?rhea rh:equation ?equation .
}""" ;
    schema:target <https://sparql.rhea-db.org/sparql> .

