@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:055 a sh:SPARQLExecutable,
       sh:SPARQLSelectExecutable ;
    rdfs:label "IDSM Chemical Similarity Search"@en ;
    rdfs:comment "Finds structurally similar ChEBI compounds for source and target metabolites in a pathway's directed interactions via the IDSM/ChEBI structure search service (idsm.elixir-czech.cz). May be slower due to external endpoint dependency. This example uses the default value (Pathway ID \"WP4225\"); the WikiPathways SNORQL UI lets you change it."@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX ebi: <http://ebi.rdf.ac.uk/dataset/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX idsm: <https://idsm.elixir-czech.cz/sparql/endpoint/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX sso: <http://semanticscience.org/resource/>
PREFIX rh:<http://rdf.rhea-db.org/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
SELECT distinct ((substr(str(?chebioSrc),32)) as ?SourceOrigin) ((substr(str(?similarSrc),32)) as ?SourceSimilar) ((substr(str(?chebioTgt),32)) as ?TargetOrigin) ((substr(str(?similarTgt),32)) as ?TargetSimilar)  #?reaction
WHERE {
  ?interaction dcterms:isPartOf ?pathway ; a wp:Conversion ;
      wp:source ?source ;
      wp:target ?target .
    ?source wp:bdbChEBI ?chebiSrc .
    ?target wp:bdbChEBI ?chebiTgt .
    ?pathway dcterms:identifier "WP4225".
    BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiSrc),37))) AS ?chebioSrc)
    BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiTgt),37))) AS ?chebioTgt)
#IDSM
SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> {
   ?chebioSrc ^sso:is-attribute-of / sso:has-value ?molfileSrc .
 ?chebioTgt ^sso:is-attribute-of / sso:has-value ?molfileTgt .
  [ sachem:compound ?similarSrc; sachem:score ?scoreSrc ]
    sachem:similaritySearch [
      sachem:query ?molfileSrc ;
     sachem:cutoff 98e-2
    ].
  [ sachem:compound ?similarTgt; sachem:score ?scoreTgt ]
    sachem:similaritySearch [
      sachem:query ?molfileTgt ;
      sachem:cutoff 98e-2 
    ] .
  }
 }""" ;
    schema:target <https://sparql.wikipathways.org/sparql> ;
    schema:keywords "chemistry" ;
    spex:federatesWith <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> ;
    dcterms:source <https://github.com/wikipathways/SPARQLQueries/blob/2f7566a161f01130c02bd00c981d238c055f8bd6/H.%20Chemistry/IDSM_similaritySearch.rq> ;
    dcterms:modified "2026-03-08"^^xsd:date ;
    dcterms:license <https://www.gnu.org/licenses/gpl-3.0.html> .
