sparql-examples

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

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

6

Select all Rhea reactions mapped to MetaCyc reactions

Use at

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

# Query 6 
# Select all Rhea reactions mapped to MetaCyc reactions
# MetaCyc reactions are mapped to either undirected, left-to-right, right-to-left or bidirectional reactions
# Rhea web query: https://www.rhea-db.org/rhea?query=metacyc:*
#
SELECT distinct ?rhea ?rheaDir ?metacyc
WHERE {
  ?rhea rdfs:subClassOf rh:Reaction .
  {
    ?rhea rdfs:seeAlso ?metacyc .
    FILTER CONTAINS(str(?metacyc), "METACYC") 
    BIND(?rhea as ?rheaDir)
  }
  UNION
  {
    ?rhea rh:directionalReaction ?directionalReaction .
    ?directionalReaction rdfs:seeAlso ?metacyc . 
    FILTER CONTAINS(str(?metacyc), "METACYC") 
    BIND(?directionalReaction as ?rheaDir  )
  }
  UNION
  {
    ?rhea rh:bidirectionalReaction ?bidirectionalReaction .
    ?bidirectionalReaction rdfs:seeAlso ?metacyc . 
    FILTER CONTAINS(str(?metacyc), "METACYC") 
    BIND(?bidirectionalReaction as ?rheaDir  )
  }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?bidirectionalReaction")
  v4("?directionalReaction")
  v2("?metacyc"):::projected 
  v1("?rhea"):::projected 
  v6("?rheaDir"):::projected 
  c2(["rh:Reaction"]):::iri 
  v1 --"rdfs:subClassOf"-->  c2
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph union1[" Union "]
    subgraph union1l[" "]
      style union1l fill:#abf,stroke-dasharray: 3 3;
      f0[["contains(str(?metacyc),'METACYC')"]]
      f0 --> v2
      v1 --"rh:bidirectionalReaction"-->  v5
      v5 --"rdfs:seeAlso"-->  v2
      bind1[/"?bidirectionalReaction"/]
      v5 --o bind1
      bind1 --as--o v6
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      f2[["contains(str(?metacyc),'METACYC')"]]
      f2 --> v2
      v1 --"rh:directionalReaction"-->  v4
      v4 --"rdfs:seeAlso"-->  v2
      bind3[/"?directionalReaction"/]
      v4 --o bind3
      bind3 --as--o v6
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    f4[["contains(str(?metacyc),'METACYC')"]]
    f4 --> v2
    v1 --"rdfs:seeAlso"-->  v2
    bind5[/"?rhea"/]
    v1 --o bind5
    bind5 --as--o v6
  end
  union0r <== or ==> union0l
  end