sparql-examples

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

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

064

rq turtle/ttl

Counts how many pathways have at least N authors for each author ordinal position, showing the distribution of author counts across pathways.

Use at

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dc:    <http://purl.org/dc/elements/1.1/>
PREFIX wpq:   <http://www.wikidata.org/prop/qualifier/>

SELECT ?atLeast (COUNT(DISTINCT ?pathway) AS ?count) WHERE {
  ?author_ a foaf:Person ;
    wp:hasAuthorship ?authorship .
  ?authorship ^wp:hasAuthorship ?pathway ;
    wpq:series_ordinal ?atLeast .
} GROUP BY ?atLeast
  ORDER BY ASC(xsd:integer(?atLeast))
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?atLeast"):::projected 
  v2("?author_")
  v3("?authorship")
  v5("?count")
  v4("?pathway"):::projected 
  c2(["foaf:Person"]):::iri 
  v2 --"a"-->  c2
  v2 --"wp:hasAuthorship"-->  v3
  v4 --"wp:hasAuthorship"-->  v3
  v3 --http://www.wikidata.org/prop/qualifier/series_ordinal-->  v1
  bind1[/"count(?pathway)"/]
  v4 --o bind1
  bind1 --as--o v5