sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

075

rq turtle/ttl

Lists metabolites in WikiPathways with their Wikidata identifier and fetches their InChIKey from Wikidata. Limited to 50 metabolites. Uses a federated SERVICE call; may be slow depending on endpoint availability.

Use at

PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT ?metabolite ?wikidata ?inchikey WHERE {
  {
    SELECT ?metabolite ?wikidata WHERE {
      ?metabolite a wp:Metabolite ;
        wp:bdbWikidata ?wikidata .
    } LIMIT 50
  }
  SERVICE <https://query.wikidata.org/sparql> {
    ?wikidata wdt:P235 ?inchikey .
  }
} LIMIT 50
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v3("?inchikey"):::projected 
  v1("?metabolite"):::projected 
  v2("?wikidata"):::projected 
  c2(["wp:Metabolite"]):::iri 
  v1 --"a"-->  c2
  v1 --"wp:bdbWikidata"-->  v2
  subgraph s1["https://query.wikidata.org/sparql"]
    style s1 stroke-width:4px;
    v2 --"wdt:P235"-->  v3
  end