sparql-examples

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

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

50_Number_of_reactions_that_have_parent_and_child_reactions

rq turtle/ttl

Number of reactions that have parent and child reactions

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>
SELECT ?reaction
  (count(distinct ?reactionChild) as ?reactionChildCount)
  (count(distinct ?reactionDescendant) as ?reactionDescendantCount)
  ?equation
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:status rh:Approved .
  ?reaction rh:equation ?equation .

  ?reactionChild rdfs:subClassOf rh:Reaction .
  ?reactionChild rh:status rh:Approved .

  ?reactionDescendant rdfs:subClassOf rh:Reaction .
  ?reactionDescendant rh:status rh:Approved .

  ?reaction ^rdfs:subClassOf ?reactionChild .
  ?reaction ^rdfs:subClassOf+ ?reactionDescendant .
}
GROUP BY ?reaction ?equation
ORDER BY DESC (count(?reactionChild))

rdfs:subClassOf
rh:status
rh:equation
rdfs:subClassOf
rh:status
rdfs:subClassOf
rh:status
rdfs:subClassOf
rdfs:subClassOf
as
as
as
?_anon_9ebffce585eb4e248ad7e8193253e1e12180
?equation
?reaction
?reactionChild
?reactionChildCount
?reactionDescendant
?reactionDescendantCount
rh:Approved
rh:Reaction
count(?reactionChild)
count(?reactionChild)
count(?reactionDescendant)