#
# example SPARQL query 106
#

@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_106 a sh:SPARQLExecutable ;
    sh:prefixes _:sparql_examples_prefixes ;
    rdfs:comment """Cell lines resistant to benzamides (a class of chemical compound)"""@en ; 
    schema:keywords "res" , "resistant" , "chemical" , "drug" , "toxin" ; 
    schema:target <https://sparql.cellosaurus.org/sparql> ; 
    sh:select """
PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
select distinct ?cl ?cl_name
('resistant to' as ?link) ?compound_ac (substr(?label2,0,30) as ?compound_name)
('which is more specific than' as ?relation)  ?generic_component
where {
  #values ?generic_component { "cyclic compound" } . # large class of chemical compound
  values ?generic_component { "benzamides"  } .     # uncomment to use another large class of chemical compound
  ?concept1 skos:prefLabel ?generic_component .      # get concept from its label (concept1)
  ?concept1 skos:notation ?code1 .                   # get notation code of the concept
  ?cl cello:hasResistance ?compound .                # cell line with resistance to some chemical compound
  ?cl cello:recommendedName ?cl_name .
  ?compound cello:isIdentifiedByXref ?concept2.      # get concept identifying the chemical compound (concept2)
  ?concept2 cello:more_specific_than+ ?concept1 .	 # concept2 must be equal or more specific than concept1
  ?concept2 skos:notation ?compound_ac .		     # get notation of concept 2
  ?concept2 skos:prefLabel ?label2.                  # get label of concept 2
}
limit 100
    """
    .

