sparql-examples

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

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

025

rq turtle/ttl

Counts the number of lipids in a specific LIPID MAPS subclass per human pathway, ordered by count. Change the FILTER value to query different subclasses. 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 DISTINCT ?pathwayRes (str(?wpid) AS ?pathway) (str(?title) AS ?pathwayTitle) (count(DISTINCT ?lipidID) AS ?Class_LipidsInPWs)
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
}
GROUP BY ?pathwayRes ?wpid ?title
ORDER BY DESC(?Class_LipidsInPWs)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v10("?Class_LipidsInPWs")
  v4("?id")
  v2("?lipidID"):::projected 
  v3("?metabolite")
  v8("?pathway")
  v5("?pathwayRes"):::projected 
  v9("?pathwayTitle")
  v7("?title"):::projected 
  v6("?wpid"):::projected 
  c9(["Homo sapiens"]):::literal 
  c7(["wp:Pathway"]):::iri 
  c3(["wp:Metabolite"]):::iri 
  f0[["regex(str(?lipidID),'FA')"]]
  f0 --> v2
  v3 --"a"-->  c3
  v3 --"dcterms:identifier"-->  v4
  v3 --"dcterms:isPartOf"-->  v5
  v3 --"wp:bdbLipidMaps"-->  v2
  v5 --"a"-->  c7
  v5 --"wp:organismName"-->  c9
  v5 --"dcterms:identifier"-->  v6
  v5 --"dc:title"-->  v7
  bind2[/"str(?wpid)"/]
  v6 --o bind2
  bind2 --as--o v8
  bind3[/"str(?title)"/]
  v7 --o bind3
  bind3 --as--o v9
  bind4[/"count(?lipidID)"/]
  v2 --o bind4
  bind4 --as--o v10