sparql-examples

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

View the Project on GitHub BiGCAT-UM/sparql-examples

083

rq turtle/ttl

Lists catalysed reactions between two metabolites, with the pathway, the label of the catalyst, the source and target metabolites, and their Wikidata identifiers.

Use at

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>

SELECT DISTINCT ?wpid ?catalyst ?source ?sourceDb ?target ?targetDb WHERE {
  ?pathway a wp:Pathway ;
      dc:identifier / dcterms:identifier ?wpid .
  ?catalysis dcterms:isPartOf ?pathway ;
    wp:source / rdfs:label ?catalyst ;
    wp:participants ?reaction .
  ?reaction a wp:Interaction .
  ?reaction wp:source ?source .
  ?source a wp:Metabolite .
  OPTIONAL{?source wp:bdbWikidata ?sourceDb .}

  ?reaction wp:target ?target .
  ?target a wp:Metabolite .
  OPTIONAL{?target wp:bdbWikidata ?targetDb .}
} ORDER BY ASC(?source)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?catalysis")
  v5("?catalyst"):::projected 
  v2("?pathway")
  v6("?reaction")
  v1("?source"):::projected 
  v7("?sourceDb"):::projected 
  v8("?target"):::projected 
  v9("?targetDb"):::projected 
  v3("?wpid"):::projected 
  a1((" "))
  a2((" "))
  c9(["wp:Interaction"]):::iri 
  c2(["wp:Pathway"]):::iri 
  c10(["wp:Metabolite"]):::iri 
  v2 --"a"-->  c2
  v2 --"dc:identifier"-->  a1
  a1 --"dcterms:identifier"-->  v3
  v4 --"dcterms:isPartOf"-->  v2
  v4 --"wp:source"-->  a2
  a2 --"rdfs:label"-->  v5
  v4 --"wp:participants"-->  v6
  v6 --"a"-->  c9
  v6 --"wp:source"-->  v1
  v1 --"a"-->  c10
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v1 -."wp:bdbWikidata".->  v7
  end
  v6 --"wp:target"-->  v8
  v8 --"a"-->  c10
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v8 -."wp:bdbWikidata".->  v9
  end