sparql-examples

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

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

Query_120

rq turtle/ttl

Top 100 anatomical part from which cell lines are derived from

Use at


PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?site_name ?site_type ?site_ac (count(?cl) as ?cl_count)
where {
    ?cl cello:derivedFromSite ?site .
    ?site cello:name ?site_name .
    ?site cello:siteType ?site_type .
    optional { ?site rdfs:comment ?note } # unused here but shows that a comment may exist
    optional {?site cello:isIdentifiedByXref / cello:accession ?site_ac } # a few anatomical parts are not identified by a xref
  }
group by ?site_name ?site_type ?site_ac
order by desc(count(?cl))
limit 100
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?_anon_39b94405334d4c98a94d4349b2e25270277")
  v1("?cl"):::projected 
  v8("?cl_count")
  v5("?note")
  v2("?site")
  v6("?site_ac"):::projected 
  v3("?site_name"):::projected 
  v4("?site_type"):::projected 
  a2((" "))
  a1((" "))
  v1 --"cello:derivedFromSite"-->  v2
  v2 --"cello:name"-->  v3
  v2 --"cello:siteType"-->  v4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."rdfs:comment".->  v5
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."cello:isIdentifiedByXref".->  a2
    a2 --"cello:accession"-->  v6
  end
  bind2[/"count(?cl)"/]
  v1 --o bind2
  bind2 --as--o v7
  bind3[/"count(?cl)"/]
  v1 --o bind3
  bind3 --as--o v8