sparql-examples

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

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

82_Select_the_number_of_approved_reactions_involving_a_carbohydrate

rq turtle/ttl

Select the number of approved reactions involving a carbohydrate (subclass of CHEBI:16646) based on the ChEBI ontology (use of subClassOf+)

Use at

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
SELECT
  (count(distinct ?reaction) as ?reactionCount)
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:status rh:Approved .
  ?reaction rh:side ?reactionSide .
  ?reactionSide rh:contains ?participant .
  ?participant rh:compound ?compound .
  ?compound rh:chebi ?chebi .
  ?chebi rdfs:subClassOf+ CHEBI:16646 .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?chebi")
  v4("?compound")
  v3("?participant")
  v1("?reaction"):::projected 
  v6("?reactionCount")
  v2("?reactionSide")
  c9(["CHEBI:16646"]):::iri 
  c4(["rh:Approved"]):::iri 
  c2(["rh:Reaction"]):::iri 
  v1 --"rdfs:subClassOf"-->  c2
  v1 --"rh:status"-->  c4
  v1 --"rh:side"-->  v2
  v2 --"rh:contains"-->  v3
  v3 --"rh:compound"-->  v4
  v4 --"rh:chebi"-->  v5
  v5 --"rdfs:subClassOf"-->  c9
  bind1[/"count(?reaction)"/]
  v1 --o bind1
  bind1 --as--o v6