@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:058 a sh:SPARQLExecutable,
       sh:SPARQLSelectExecutable ;
    rdfs:label "Extracting Directed Metabolic Reactions"@en ;
    rdfs:comment "Extracts directed metabolite-to-metabolite interactions from human pathways in the AnalysisCollection, returning source and target identifiers, interaction types, and Rhea IDs as part of the DSMN workflow. 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 cur: <http://vocabularies.wikipathways.org/wp#Curation:>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>

### Part 1: ###
SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?mimtype
?pathway (str(?titleLit) as ?title)
?sourceCHEBI ?targetDbCHEBI ?sourceHMDB ?targetDbHMDB ?InteractionID  
WHERE {  

### Part 2: ###
?pathway a wp:Pathway ;
         wp:organismName "Homo sapiens" ;
         dc:title ?titleLit . 	
         
### Part 3A: ###
FILTER (EXISTS {?pathway wp:ontologyTag cur:AnalysisCollection})  .
### Part 3B: ###
#FILTER (EXISTS {?pathway wp:ontologyTag cur:Reactome_Approved}) .    
### Part 3C: ###
#FILTER (EXISTS {?pathway wp:ontologyTag cur:Lipids}) .

### Part 4: ###
?interaction dcterms:isPartOf ?pathway ;			
             a wp:DirectedInteraction ;
	           wp:source ?source ;
	           wp:target ?target .  
OPTIONAL{?interaction a ?mimtype}. 
VALUES ?mimtype {wp:ComplexBinding wp:Conversion wp:Inhibition wp:Catalysis
wp:Stimulation wp:TranscriptionTranslation wp:DirectedInteraction} .  

### Part 5: ###
?source a wp:Metabolite . 
?source wp:bdbWikidata ?sourceDb . 
OPTIONAL{?source wp:bdbChEBI ?sourceCHEBI}.
OPTIONAL{?source wp:bdbHmdb ?sourceHMDB}.
?target a wp:Metabolite . 
?target wp:bdbWikidata ?targetDb . 
OPTIONAL{?target wp:bdbChEBI ?targetDbCHEBI}. 
OPTIONAL{?target wp:bdbHmdb ?targetDbHMDB}. 

### Part 6: ###
OPTIONAL{?interaction wp:bdbRhea ?InteractionID} .
} ORDER BY DESC(?InteractionID)""" ;
    schema:target <https://sparql.wikipathways.org/sparql> ;
    schema:keywords "DSMN", "directed small molecules network" ;
    dcterms:source <https://github.com/wikipathways/SPARQLQueries/blob/c42d381565e5c49c7c754d037d6f253b3214601f/I.%20DirectedSmallMoleculesNetwork%20%28DSMN%29/extracting%20directed%20metabolic%20reactions.rq> ;
    dcterms:modified "2026-03-09"^^xsd:date ;
    dcterms:license <https://www.gnu.org/licenses/gpl-3.0.html> .
