sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

93_Select_all_approved_reactions_with_CHEBI_17815_or_one_of_its_descendant_optional_EC

rq turtle/ttl

Select all approved reactions with CHEBI:17815 (a 1,2-diacyl-sn-glycerol) or one of its descendant. Display the EC numbers if the rhea-ec link exists.

Use at

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_>

SELECT
  distinct
    ?reaction
    ?ec
    ?reactionEquation
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:status rh:Approved .
  ?reaction rh:equation ?reactionEquation .
  ?reaction rh:side ?reactionSide .

  OPTIONAL {?reaction rh:ec ?ec .} .

  ?reactionSide rh:contains ?participant .
  ?participant rh:compound ?compound .
  ?compound rh:chebi ?chebi .
  ?chebi rdfs:subClassOf* CHEBI:17815 .
}
ORDER BY ?reaction
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?chebi")
  v6("?compound")
  v4("?ec"):::projected 
  v5("?participant")
  v1("?reaction"):::projected 
  v2("?reactionEquation"):::projected 
  v3("?reactionSide")
  c11(["CHEBI:17815"]):::iri 
  c4(["rh:Approved"]):::iri 
  c2(["rh:Reaction"]):::iri 
  v1 --"rdfs:subClassOf"-->  c2
  v1 --"rh:status"-->  c4
  v1 --"rh:equation"-->  v2
  v1 --"rh:side"-->  v3
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v1 -."rh:ec".->  v4
  end
  v3 --"rh:contains"-->  v5
  v5 --"rh:compound"-->  v6
  v6 --"rh:chebi"-->  v7
  v7 --"rdfs:subClassOf"-->  c11