sparql-examples

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

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

Query_167

rq turtle/ttl

Count of cell lines established by organization

Use at


PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX cvcl: <https://purl.expasy.org/cellosaurus/rdf/cvcl/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <https://schema.org/>
select
        ?org_name 		              # organization name
        ?person_name                # name of contact person (optional)
        (count(?cl) as ?cl_count)		# count of cell linesknown as etablished by organization
where {
  #values ?cl { cvcl:CVCL_C2T2 }
  ?cl a / rdfs:subClassOf cello:CellLine .
  ?cl cello:establishedBy ?org.
  ?org a schema:Organization.
  ?org cello:recommendedName ?org_name . # there is 1 and only 1 rec name by org
  optional {
    ?person cello:isMemberOf ?org.
    ?person a schema:Person .
    ?person cello:name ?person_name .
  }
}
group by ?org_name ?person_name
order by desc(count(?cl))
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v6("?_anon_39b94405334d4c98a94d4349b2e25270250")
  v1("?cl"):::projected 
  v7("?cl_count")
  v2("?org")
  v3("?org_name"):::projected 
  v4("?person")
  v5("?person_name"):::projected 
  a2((" "))
  a1((" "))
  c5([https://schema.org/Organization]):::iri 
  c3(["cello:CellLine"]):::iri 
  c8([https://schema.org/Person]):::iri 
  v1 --"a"-->  a2
  a2 --"rdfs:subClassOf"-->  c3
  v1 --"cello:establishedBy"-->  v2
  v2 --"a"-->  c5
  v2 --"cello:recommendedName"-->  v3
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."cello:isMemberOf".->  v2
    v4 --"a"-->  c8
    v4 --"cello:name"-->  v5
  end
  bind2[/"count(?cl)"/]
  v1 --o bind2
  bind2 --as--o v6
  bind3[/"count(?cl)"/]
  v1 --o bind3
  bind3 --as--o v7