sparql-examples

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

View the Project on GitHub sib-swiss/sparql-examples

Query_119

rq turtle/ttl

Top 10 most represented dog breeds in Cellosaurus

Use at


PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
select ?species_ac ?species_name ?breed_ac ?breed_name (count(distinct(?cl)) as ?cl_count) where {
  values ?species_ac { "9615" } # Canis lupus familiaris (Dog)
  ?cl cello:derivedFromIndividualBelongingToSpecies ?species .
  ?species cello:isIdentifiedByXref / cello:accession ?species_ac .
  ?species cello:name ?species_name .
  optional {
    ?cl cello:derivedFromIndividualBelongingToBreed ?breed .
    ?breed cello:isIdentifiedByXref / cello:accession ?breed_ac .
    ?breed cello:name ?breed_name .
  }
}
group by ?species_ac ?species_name ?breed_ac ?breed_name
order by desc(count(distinct(?cl)))
limit 10
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v8("?_anon_39b94405334d4c98a94d4349b2e25270224")
  v5("?breed")
  v6("?breed_ac"):::projected 
  v7("?breed_name"):::projected 
  v2("?cl"):::projected 
  v9("?cl_count")
  v3("?species")
  v1("?species_ac"):::projected 
  v4("?species_name"):::projected 
  a2((" "))
  a3((" "))
  a1((" "))
  bind0[/VALUES ?species_ac/]
  bind0-->v1
  bind00(["9615"])
  bind00 --> bind0
  v2 --"cello:derivedFromIndividualBelongingToSpecies"-->  v3
  v3 --"cello:isIdentifiedByXref"-->  a2
  a2 --"cello:accession"-->  v1
  v3 --"cello:name"-->  v4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."cello:derivedFromIndividualBelongingToBreed".->  v5
    v5 --"cello:isIdentifiedByXref"-->  a3
    a3 --"cello:accession"-->  v6
    v5 --"cello:name"-->  v7
  end
  bind3[/"count(?cl)"/]
  v2 --o bind3
  bind3 --as--o v8
  bind4[/"count(?cl)"/]
  v2 --o bind4
  bind4 --as--o v9