sparql-examples

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

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

033

rq turtle/ttl

Finds all human pathways containing a specific MolMeDB compound by resolving its PubChem identifier through the MolMeDB SPARQL endpoint. May be slower due to external endpoint dependency. This example uses the default value (Species "Homo sapiens"); the WikiPathways SNORQL UI lets you change it.

Use at

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>

SELECT DISTINCT ?pathwayRes (str(?wpid) as ?pathway) (str(?title) as ?pathwayTitle) ((substr(str(?COMPOUND),46)) as ?PubChem) WHERE
{
  SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/molmedb> {
   <http://identifiers.org/molmedb/MM00431> skos:exactMatch ?COMPOUND.
   filter (strstarts(str(?COMPOUND), 'http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID'))
  }
  
  ?gene a wp:Metabolite ;
    dcterms:identifier ?id ;
    dcterms:isPartOf ?pathwayRes ;
    wp:bdbPubChem ?COMPOUND .
  
  ?pathwayRes a wp:Pathway ;
    wp:organismName "Homo sapiens";
    dcterms:identifier ?wpid ;
    dc:title ?title . 
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?COMPOUND"):::projected 
  v9("?PubChem")
  v2("?gene")
  v3("?id")
  v7("?pathway")
  v4("?pathwayRes"):::projected 
  v8("?pathwayTitle")
  v6("?title"):::projected 
  v5("?wpid"):::projected 
  c12(["Homo sapiens"]):::literal 
  c10(["wp:Pathway"]):::iri 
  c6(["wp:Metabolite"]):::iri 
  c3([http://identifiers.org/molmedb/MM00431]):::iri 
  subgraph s1["https://idsm.elixir-czech.cz/sparql/endpoint/molmedb"]
    style s1 stroke-width:4px;
    f0[["starts-with(str(?COMPOUND),'http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID')"]]
    f0 --> v1
    c3 --"skos:exactMatch"-->  v1
  end
  v2 --"a"-->  c6
  v2 --"dcterms:identifier"-->  v3
  v2 --"dcterms:isPartOf"-->  v4
  v2 --"wp:bdbPubChem"-->  v1
  v4 --"a"-->  c10
  v4 --"wp:organismName"-->  c12
  v4 --"dcterms:identifier"-->  v5
  v4 --"dc:title"-->  v6
  bind1[/"str(?wpid)"/]
  v5 --o bind1
  bind1 --as--o v7
  bind2[/"str(?title)"/]
  v6 --o bind2
  bind2 --as--o v8
  bind3[/"substring(str(?COMPOUND),'46^^xsd:integer')"/]
  v1 --o bind3
  bind3 --as--o v9