@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:6 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:label "Enzymes for lipids"@en ;
    rdfs:comment """For a given lipid (SWISSLIPID:000399814, Ceramide), return a list of all corresponding reactions (Rhea IDs and equation), as well as their enzymes as annotated in UniProtKB/Swiss-Prot) enzymes themselves (ID and protein name).
This query does not consider the hierarchy: it looks for reactions and enzymes only for the specified lipid."""@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/>
PREFIX up: <http://purl.uniprot.org/core/>

# Example 6
SELECT ?startId ?startName ?chebi ?rhea ?rheaEquation ?uniprot ?uniprotName
WHERE
{
  # SwissLipids query (list of) identifier(s)
  VALUES ?startId { SWISSLIPID:000399814 }
  # name
  ?startId rdfs:label ?startName .
  # ChEBI x-ref
  ?startId 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 .
  }    
  # federated query to UniProt
  SERVICE <https://sparql.uniprot.org/sparql> {
    ?uniprot up:reviewed true .
    ?uniprot up:recommendedName/up:fullName ?uniprotName .
    ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea .
  }
} 
ORDER BY ?startId""" ;
    schema:target <https://sparql.swisslipids.org/sparql/> ;
    spex:federatesWith <https://sparql.uniprot.org/sparql> , <https://sparql.rhea-db.org/sparql> .

