Skip to content

Instantly share code, notes, and snippets.

@egonw
Created December 22, 2017 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/1cadd8132eeac56b19eb7899481e63c1 to your computer and use it in GitHub Desktop.
Save egonw/1cadd8132eeac56b19eb7899481e63c1 to your computer and use it in GitHub Desktop.
Federated query between WikiPathways and Wikidata, listing SMILES for substrate and product for metabolic conversions.
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
SELECT DISTINCT ?sourceWD ?sourceWDLabel ?sourceSMILEScan ?sourceSMILESiso ?targetWD ?targetWDLabel ?targetSMILEScan ?targetSMILESiso WITH {
SELECT ?sourceWD ?targetWD WHERE {
SERVICE <http://sparql.wikipathways.org/> {
?pathway a wp:Pathway .
?interaction dcterms:isPartOf ?pathway .
?interaction a wp:Interaction, wp:Conversion .
?interaction wp:source ?source . ?source a wp:Metabolite; wp:bdbWikidata ?sourceWD .
?interaction wp:target ?target . ?target a wp:Metabolite; wp:bdbWikidata ?targetWD .
}
}
} AS %results WHERE {
INCLUDE %results
OPTIONAL { ?sourceWD wdt:P233 ?sourceSMILEScan }
OPTIONAL { ?targetWD wdt:P233 ?targetSMILEScan }
OPTIONAL { ?sourceWD wdt:P2017 ?sourceSMILESiso }
OPTIONAL { ?targetWD wdt:P2017 ?targetSMILESiso }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment