sparql-examples

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

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

36_Select_the_number_of_reactions_with_cross-references_to_KEGG_resource

rq turtle/ttl

Select the number of reactions with cross-references to KEGG resource (via bidirectional rhea reactions)

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX kegg: <http://identifiers.org/kegg.reaction/>

SELECT (count(?reaction) as ?reactionCount) 
WHERE {
    ?reaction rdfs:subClassOf rh:Reaction .
    ?reaction rh:bidirectionalReaction ?bidirectionalReaction .
    ?bidirectionalReaction rdfs:seeAlso ?xref .
    FILTER (regex(?xref, str(kegg:)))
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v3("?bidirectionalReaction")
  v2("?reaction"):::projected 
  v4("?reactionCount")
  v1("?xref")
  c3(["rh:Reaction"]):::iri 
  f0[["regex(?xref,str(http://identifiers.org/kegg.reaction/))"]]
  f0 --> v1
  v2 --"rdfs:subClassOf"-->  c3
  v2 --"rh:bidirectionalReaction"-->  v3
  v3 --"rdfs:seeAlso"-->  v1
  bind2[/"count(?reaction)"/]
  v2 --o bind2
  bind2 --as--o v4