#
# example SPARQL query 141
#

@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_141 a sh:SPARQLExecutable ;
    sh:prefixes _:sparql_examples_prefixes ;
    rdfs:comment """Cell lines with a misspelling record"""@en ; 
    schema:keywords "miss" , "misspelling" , "source" ; 
    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#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
select ?cl ?cl_name ?misspelling_name ?appears_in ?note
where {
  ?cl cello:hasMisspellingRecord ?rec.
  ?cl cello:recommendedName ?cl_name .
  ?rec cello:misspellingName ?misspelling_name .
  optional {?rec rdfs:comment ?note. }
  optional {
    ?rec cello:appearsIn ?s .
  	optional { ?s  a ?st }.
   	optional { ?s cello:internalId ?id }   	# src origin is a xref or a publi
    optional { ?s skos:prefLabel ?org }     # src origin is an organization
    optional { ?s rdfs:label ?lb }          # src origin not specified
  }
  bind (coalesce(?id, ?org, ?lb, '-') as ?appears_in)
  bind (coalesce(?st, '-') as ?source_type)
  # filter (bound(?s)) # uncomment to get misspelling not linked to a particular source
  # filter (bound(?note)) # uncomment to get misspelling with an additional note
}
    """
    .

