@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ex: <https://bigcat-um.github.io/sparql-examples/WikiPathways/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex: <https://purl.expasy.org/sparql-examples/ontology#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:031 a sh:SPARQLExecutable,
       sh:SPARQLSelectExecutable ;
    rdfs:label "Metabolites in AOP-Wiki"@en ;
    rdfs:comment "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."@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """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""" ;
    schema:target <https://sparql.wikipathways.org/sparql> ;
    schema:keywords "collaborations", "AOP-Wiki", "metabolite" ;
    spex:federatesWith <https://aopwiki.rdf.bigcat-bioinformatics.org/sparql/> ;
    dcterms:source <https://github.com/wikipathways/SPARQLQueries/blob/7a6a9c7bb1c188b1422d851f705492d6c78c49f4/C.%20Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.rq> ;
    dcterms:modified "2026-10-07"^^xsd:date ;
    dcterms:license <https://www.gnu.org/licenses/gpl-3.0.html> .
