sparql-examples

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

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

024

rq turtle/ttl

Retrieves lipid names, formulas, and associated pathways for a specific LIPID MAPS category by querying the LIPID MAPS SPARQL endpoint. May be slower due to external endpoint dependency.

Use at

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX chebi: <http://purl.obolibrary.org/obo/chebi/>

SELECT ?lipid ?name ?formula ?lmid (GROUP_CONCAT(?wpid_;separator=", ") AS ?pathway)
WHERE {
  SERVICE <https://lipidmaps.org/sparql> {
    VALUES ?category { <https://www.lipidmaps.org/rdf/category/112> <https://www.lipidmaps.org/rdf/category/11200> } 
    ?lipidmaps rdfs:label ?name ;
      rdfs:subClassOf* ?category ;
      chebi:formula ?formula .
  }
  BIND (IRI(CONCAT("https://identifiers.org/lipidmaps/",
               SUBSTR(STR(?lipidmaps), 31))) AS ?lmid)
  ?lipid wp:bdbLipidMaps ?lmid ;
         dcterms:isPartOf ?pw .
  ?pw a wp:Pathway ; dcterms:identifier ?wpid_ .
}
GROUP BY ?lipid ?name ?formula ?lmid
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?category")
  v4("?formula"):::projected 
  v6("?lipid"):::projected 
  v2("?lipidmaps")
  v5("?lmid"):::projected 
  v3("?name"):::projected 
  v9("?pathway")
  v7("?pw")
  v8("?wpid_"):::projected 
  c8(["wp:Pathway"]):::iri 
  subgraph s1["https://lipidmaps.org/sparql"]
    style s1 stroke-width:4px;
    bind0[/VALUES ?category/]
    bind0-->v1
    bind00([https://www.lipidmaps.org/rdf/category/112])
    bind00 --> bind0
    bind01([https://www.lipidmaps.org/rdf/category/11200])
    bind01 --> bind0
    v2 --"rdfs:label"-->  v3
    v2 --"rdfs:subClassOf"-->  v1
    v2 --http://purl.obolibrary.org/obo/chebi/formula-->  v4
  end
  bind1[/"concat('https://identifiers.org/lipidmaps/',substring(str(?lipidmaps),'31^^xsd:integer'))"/]
  v2 --o bind1
  bind1 --as--o v5
  v6 --"wp:bdbLipidMaps"-->  v5
  v6 --"dcterms:isPartOf"-->  v7
  v7 --"a"-->  c8
  v7 --"dcterms:identifier"-->  v8
  bind3[/"?wpid_"/]
  v8 --o bind3
  bind3 --as--o v9