@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:4 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Select all cross-references for a given reaction"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>

# Query 4
# Select all cross-references mapped to RHEA:21016
# 
# This query mimics the Cross-references section of 
# https://www.rhea-db.org/rhea/21016
#
SELECT distinct ?rhea ?rheaDir ?xref 
WHERE {
  ?rhea rdfs:subClassOf rh:Reaction .
  VALUES (?rhea) {(rh:21016)}
  {
    ?rhea rdfs:seeAlso ?xref .
    BIND(?rhea as ?rheaDir)
  }
  UNION
  {
    ?rhea rh:directionalReaction ?directionalReaction .
    ?directionalReaction rdfs:seeAlso ?xref . 
    BIND(?directionalReaction as ?rheaDir  )
  }
  UNION
  {
    ?rhea rh:bidirectionalReaction ?bidirectionalReaction .
    ?bidirectionalReaction rdfs:seeAlso ?xref . 
    BIND(?bidirectionalReaction as ?rheaDir  )
  }
}""" ;
    schema:target <https://sparql.rhea-db.org/sparql> .

