sparql-examples

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

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

28_Select_all_reactions_with_Xrefs

rq turtle/ttl

Select all reactions with cross-references

Use at

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

SELECT 
  DISTINCT ?reaction 
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:directionalReaction ?directionalReaction .
  ?reaction rh:bidirectionalReaction ?bidirectionalReaction .
  OPTIONAL { ?directionalReaction rdfs:seeAlso ?xref . }
  OPTIONAL { ?bidirectionalReaction rdfs:seeAlso ?xref . }
  FILTER (BOUND(?xref))
}
ORDER BY ?reaction

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?bidirectionalReaction")
  v3("?directionalReaction")
  v1("?reaction"):::projected 
  v2("?xref")
  c2(["rh:Reaction"]):::iri 
  f0[["bound(?xref)"]]
  f0 --> v2
  v1 --"rdfs:subClassOf"-->  c2
  v1 --"rh:directionalReaction"-->  v3
  v1 --"rh:bidirectionalReaction"-->  v4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v3 -."rdfs:seeAlso".->  v2
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."rdfs:seeAlso".->  v2
  end