sparql-examples

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

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

038

rq turtle/ttl

Lists all metabolites in a given pathway, returning the pathway identifier and metabolite labels. This example uses the default value (Pathway ID "WP1560"); the WikiPathways SNORQL UI lets you change it.

Use at

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 ?pathway (str(?label) as ?Metabolite) where {
    {
        SELECT ?pathway WHERE {
            ?pathway dcterms:identifier "WP1560" .
            ?pathway a wp:Pathway .
        }
    }
    ?metabolite a wp:Metabolite ;
       rdfs:label ?label ;
       dcterms:isPartOf ?pathway .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?Metabolite")
  v3("?label"):::projected 
  v2("?metabolite")
  v1("?pathway"):::projected 
  c2(["WP1560"]):::literal 
  c4(["wp:Pathway"]):::iri 
  c5(["wp:Metabolite"]):::iri 
  v1 --"dcterms:identifier"-->  c2
  v1 --"a"-->  c4
  v2 --"a"-->  c5
  v2 --"rdfs:label"-->  v3
  v2 --"dcterms:isPartOf"-->  v1
  bind0[/"str(?label)"/]
  v3 --o bind0
  bind0 --as--o v4