A set of SPARQL examples that are used in different TGX resources
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.
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
] .
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v15("?SourceOrigin")
v16("?SourceSimilar")
v17("?TargetOrigin")
v18("?TargetSimilar")
v5("?chebiSrc")
v6("?chebiTgt")
v7("?chebioSrc"):::projected
v8("?chebioTgt"):::projected
v1("?interaction")
v9("?molfileSrc")
v10("?molfileTgt")
v2("?pathway")
v12("?scoreSrc")
v14("?scoreTgt")
v11("?similarSrc"):::projected
v13("?similarTgt"):::projected
v3("?source")
v4("?target")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
a5((" "))
a6((" "))
c8(["WP4225"]):::literal
c16(["98e-2^^xsd:double"]):::literal
c3(["wp:Conversion"]):::iri
v1 --"dcterms:isPartOf"--> v2
v1 --"a"--> c3
v1 --"wp:source"--> v3
v1 --"wp:target"--> v4
v3 --"wp:bdbChEBI"--> v5
v4 --"wp:bdbChEBI"--> v6
v2 --"dcterms:identifier"--> c8
bind0[/"concat('http://purl.obolibrary.org/obo/CHEBI_',substring(str(?chebiSrc),'37^^xsd:integer'))"/]
v5 --o bind0
bind0 --as--o v7
bind1[/"concat('http://purl.obolibrary.org/obo/CHEBI_',substring(str(?chebiTgt),'37^^xsd:integer'))"/]
v6 --o bind1
bind1 --as--o v8
subgraph s1["https://idsm.elixir-czech.cz/sparql/endpoint/chebi"]
style s1 stroke-width:4px;
a1 --http://semanticscience.org/resource/is-attribute-of--> v7
a1 --http://semanticscience.org/resource/has-value--> v9
a2 --http://semanticscience.org/resource/is-attribute-of--> v8
a2 --http://semanticscience.org/resource/has-value--> v10
a3 --"sachem:compound"--> v11
a3 --"sachem:score"--> v12
a4 --"sachem:query"--> v9
a4 --"sachem:cutoff"--> c16
a3 --"sachem:similaritySearch"--> a4
a5 --"sachem:compound"--> v13
a5 --"sachem:score"--> v14
a6 --"sachem:query"--> v10
a6 --"sachem:cutoff"--> c16
a5 --"sachem:similaritySearch"--> a6
end
bind2[/"substring(str(?chebioSrc),'32^^xsd:integer')"/]
v7 --o bind2
bind2 --as--o v15
bind3[/"substring(str(?similarSrc),'32^^xsd:integer')"/]
v11 --o bind3
bind3 --as--o v16
bind4[/"substring(str(?chebioTgt),'32^^xsd:integer')"/]
v8 --o bind4
bind4 --as--o v17
bind5[/"substring(str(?similarTgt),'32^^xsd:integer')"/]
v13 --o bind5
bind5 --as--o v18