sparql-examples

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

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

031

rq turtle/ttl

Finds metabolites in pathways of the chosen species that are linked to stressors in AOP-Wiki, by querying the AOP-Wiki SPARQL endpoint and matching on ChEBI identifiers. This example uses the default value (Species "Homo sapiens"); the WikiPathways SNORQL UI lets you change it.

Use at

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX cheminf:	<http://semanticscience.org/resource/CHEMINF_>

SELECT DISTINCT (str(?title) as ?pathwayName) ?chemical ?ChEBI ?ChemicalName ?mappedid ?LinkedStressor

WHERE {
   # Query AOP-Wiki first: it returns its few hundred ChEBI-mapped chemicals in one request,
   # which are then joined to the local metabolites. With the SERVICE block last, the endpoint
   # sends one remote request per metabolite and times out.
   SERVICE <https://aopwiki.rdf.bigcat-bioinformatics.org/sparql/> {
    ?mappedid a cheminf:000407 ; cheminf:000407 ?ChEBI .
    ?cheLook a cheminf:000000 ; dc:title ?ChemicalName ; dcterms:isPartOf ?LinkedStressor ; skos:exactMatch ?mappedid .
   }
   ?chemical a wp:Metabolite ; dcterms:isPartOf ?pathway ; wp:bdbChEBI ?mappedid .
   ?pathway a wp:Pathway ; wp:organismName "Homo sapiens" ; dc:title ?title .
}
ORDER BY ?ChemicalName ?pathwayName
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?ChEBI"):::projected 
  v1("?ChemicalName"):::projected 
  v6("?LinkedStressor"):::projected 
  v5("?cheLook")
  v7("?chemical"):::projected 
  v3("?mappedid"):::projected 
  v8("?pathway")
  v10("?pathwayName")
  v9("?title"):::projected 
  c3(["cheminf:000407"]):::iri 
  c12(["Homo sapiens"]):::literal 
  c10(["wp:Pathway"]):::iri 
  c4(["cheminf:000000"]):::iri 
  c8(["wp:Metabolite"]):::iri 
  subgraph s1["https://aopwiki.rdf.bigcat-bioinformatics.org/sparql/"]
    style s1 stroke-width:4px;
    v3 --"a"-->  c3
    v3 -->c3--> v4
    v5 --"a"-->  c4
    v5 --"dc:title"-->  v1
    v5 --"dcterms:isPartOf"-->  v6
    v5 --"skos:exactMatch"-->  v3
  end
  v7 --"a"-->  c8
  v7 --"dcterms:isPartOf"-->  v8
  v7 --"wp:bdbChEBI"-->  v3
  v8 --"a"-->  c10
  v8 --"wp:organismName"-->  c12
  v8 --"dc:title"-->  v9
  bind0[/"str(?title)"/]
  v9 --o bind0
  bind0 --as--o v10