@prefix ex: <https://sparql.swisslipids.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:5 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:label "Lipid reactions"@en ;
    rdfs:comment """For a given lipid (SWISSLIPID:000399814, Ceramide), return a list of all corresponding reactions (Rhea IDs and equation).
This query does consider the hierarchy: it looks for reactions involving the specified lipid and/or its more specific forms."""@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>

# Example 5
SELECT ?startId ?startName ?id ?name ?chebi ?rhea ?rheaEquation 
WHERE
{
  # SwissLipids query (list of) identifier(s)
  VALUES ?startId { SWISSLIPID:000399814 }
  # name
  ?startId rdfs:label ?startName .
  # Retrieve children lipids 
  ?id rdfs:subClassOf* ?startId .
  ?id rdfs:label ?name .
  # ChEBI x-ref
  ?id owl:equivalentClass ?chebi .
  # federated query to Rhea
  SERVICE <https://sparql.rhea-db.org/sparql> {
  	?rhea rh:equation ?rheaEquation .
  	?rhea rh:side/rh:contains/rh:compound/rh:chebi ?chebi .
  }    
} 
ORDER BY  ?startId ?id""" ;
    schema:target <https://sparql.swisslipids.org/sparql/> ;
    spex:federatesWith <https://sparql.rhea-db.org/sparql> .

