sparql-examples

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

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

012

rq turtle/ttl

Calculates the average, minimum, and maximum number of a selected entity type per pathway in WikiPathways. This example uses the default value (Entity Type "DataNode"); the WikiPathways SNORQL UI lets you change it.

Use at

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

SELECT (AVG(?no) AS ?avg)
       (MIN(?no) AS ?min)
       (MAX(?no) AS ?max)
WHERE {
    SELECT ?Pathway (COUNT(?entity) AS ?no)
    WHERE {
    ?entity a wp:DataNode ;
       dcterms:isPartOf ?Pathway .
    ?Pathway a wp:Pathway .}
    GROUP BY ?Pathway
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?Pathway")
  v4("?avg")
  v1("?entity")
  v6("?max")
  v5("?min")
  v3("?no"):::projected 
  c2(["wp:DataNode"]):::iri 
  c4(["wp:Pathway"]):::iri 
  v1 --"a"-->  c2
  v1 --"dcterms:isPartOf"-->  v2
  v2 --"a"-->  c4
  bind1[/"count(?entity)"/]
  v1 --o bind1
  bind1 --as--o v3
  bind5[/"average(?no)"/]
  v3 --o bind5
  bind5 --as--o v4
  bind6[/"min(?no)"/]
  v3 --o bind6
  bind6 --as--o v5
  bind7[/"max(?no)"/]
  v3 --o bind7
  bind7 --as--o v6