sparql-examples

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

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

023

rq turtle/ttl

Counts the number of individual lipids in a specific LIPID MAPS subclass across human pathways. Change the FILTER value to query different subclasses (FA, GL, GP, SP, ST, PR, SL, PK). This example uses the default values (Species "Homo sapiens", LIPID MAPS Class "FA"); the WikiPathways SNORQL UI lets you change them.

Use at

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>

SELECT (count(DISTINCT ?lipidID) as ?IndividualLipidsPerClass)
WHERE {     ?metabolite a wp:Metabolite ;
    dcterms:identifier ?id ;
    dcterms:isPartOf ?pathwayRes ;
    wp:bdbLipidMaps ?lipidID . #Metabolite DataNodes need to have a LIPID MAPS ID, for this query to count correctly (some lipids might be missed due to missing Xrefs)
  ?pathwayRes a wp:Pathway ;
              wp:organismName "Homo sapiens"; #Filter for a species (ommit when querying all pathways available for all species)
    dcterms:identifier ?wpid ;
    dc:title ?title .
  FILTER regex(str(?lipidID), "FA" ). #Filter for a LIPID MAPS ID subclass: 'FA' Fatty Acids ; 'GL' Glycerolipid ; 'GP' Glycerophospholipid ; 'SP' Sphingolipids ; 'ST' Sterol lipids ; 'PR' Prenol Lipids ; 'SL' Saccharolipids ; 'PK' Polyketides
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?IndividualLipidsPerClass")
  v3("?id")
  v1("?lipidID"):::projected 
  v2("?metabolite")
  v4("?pathwayRes")
  v6("?title")
  v5("?wpid")
  c9(["Homo sapiens"]):::literal 
  c7(["wp:Pathway"]):::iri 
  c3(["wp:Metabolite"]):::iri 
  f0[["regex(str(?lipidID),'FA')"]]
  f0 --> v1
  v2 --"a"-->  c3
  v2 --"dcterms:identifier"-->  v3
  v2 --"dcterms:isPartOf"-->  v4
  v2 --"wp:bdbLipidMaps"-->  v1
  v4 --"a"-->  c7
  v4 --"wp:organismName"-->  c9
  v4 --"dcterms:identifier"-->  v5
  v4 --"dc:title"-->  v6
  bind2[/"count(?lipidID)"/]
  v1 --o bind2
  bind2 --as--o v7