#
# example SPARQL query 147
#

@prefix schema: <https://schema.org/> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 
@prefix sh: <http://www.w3.org/ns/shacl#> . 
@prefix cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/> .


cello:Query_147 a sh:SPARQLExecutable ;
    sh:prefixes _:sparql_examples_prefixes ;
    rdfs:comment """Some hybrid cell lines with the species from which they originate"""@en ; 
    schema:keywords "ox" , "species" , "hybrid" ; 
    schema:target <https://sparql.cellosaurus.org/sparql> ; 
    sh:select """
PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select
  ?cl_class ?cl ?cl_name
  (count(?species_name) as ?species_cnt)
  (group_concat(?species_name ; separator = ', ') as ?species_list)
  where {
    select ?cl_class ?cl ?cl_name ?species_name
      where {
      ?cl a ?cl_class .
      ?cl cello:recommendedName ?cl_name .
      ?cl cello:derivedFromIndividualBelongingToSpecies / rdfs:label ?species_name .
    }
}
group by ?cl_class ?cl ?cl_name having (count(?species_name) > 1)
order by desc(count(?species_name))
limit 100
    """
    .

