sparql-examples

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

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

026

rq turtle/ttl

Counts the total number of lipids with LIPID MAPS identifiers per human pathway, ordered by count. 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 wp: <http://vocabularies.wikipathways.org/wp#>
prefix lipidmaps:      <https://identifiers.org/lipidmaps/> #IRI can be used to create URLs from identifiers in line 7
select distinct ?pathwayRes (str(?wpid) as ?pathway) (str(?title) as ?pathwayTitle) (count(distinct ?lipidID) AS ?LipidsInPWs)
where {
  ?metabolite a wp:Metabolite ;    #Define what are metabolites
    dcterms:identifier ?id ;       #Find the identifier of a certain metabolite
    dcterms:isPartOf ?pathwayRes ; #Define metabolites are part of a pathway
    wp:bdbLipidMaps ?lipidID .     #Find the LIPID MAPS identifier for a certain metabolite
  ?pathwayRes a wp:Pathway ;       #Define what is a pathway
              wp:organismName "Homo sapiens" ; #Filter pathways on species Human
    dcterms:identifier ?wpid ;     #Obtain identifier of pathway
    dc:title ?title .              #Obtain title of pathway
}
GROUP BY ?pathwayRes ?wpid ?title
ORDER BY DESC(?LipidsInPWs)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v10("?LipidsInPWs")
  v3("?id")
  v5("?lipidID"):::projected 
  v2("?metabolite")
  v8("?pathway")
  v4("?pathwayRes"):::projected 
  v9("?pathwayTitle")
  v7("?title"):::projected 
  v6("?wpid"):::projected 
  c8(["Homo sapiens"]):::literal 
  c6(["wp:Pathway"]):::iri 
  c2(["wp:Metabolite"]):::iri 
  v2 --"a"-->  c2
  v2 --"dcterms:identifier"-->  v3
  v2 --"dcterms:isPartOf"-->  v4
  v2 --"wp:bdbLipidMaps"-->  v5
  v4 --"a"-->  c6
  v4 --"wp:organismName"-->  c8
  v4 --"dcterms:identifier"-->  v6
  v4 --"dc:title"-->  v7
  bind1[/"str(?wpid)"/]
  v6 --o bind1
  bind1 --as--o v8
  bind2[/"str(?title)"/]
  v7 --o bind2
  bind2 --as--o v9
  bind3[/"count(?lipidID)"/]
  v5 --o bind3
  bind3 --as--o v10