sparql-examples

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

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

Query_140

rq turtle/ttl

Some cell lines known to be resistant to some chemical compound or toxin

Use at


PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?cl ?cl_name ?compound_class (substr(?compound_str,0,36) as ?compound_name) ?compound_iri ?compound_url where
  {
   ?cl a / rdfs:subClassOf cello:CellLine .
   ?cl cello:recommendedName ?cl_name .
   ?cl cello:hasResistance ?compound.
   ?compound a ?compound_class .
   ?compound cello:name ?compound_str .
   optional {
    ?compound cello:isIdentifiedByXref ?xref .
    ?xref cello:accession ?ac.
    ?xref rdfs:seeAlso ?compound_url .
  }
  optional {
    ?compound cello:isIdentifiedByIRI ?compound_iri .
  }
  #filter(!bound(?compound_iri))  # uncomment to see only chemical for which we have no IRI (owl concept)
  #filter(!bound(?compound_url))  # uncomment to see only chemical for which we have no identifying xref
}
order by ?cl
limit 100
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?ac")
  v1("?cl"):::projected 
  v2("?cl_name"):::projected 
  v3("?compound")
  v4("?compound_class"):::projected 
  v9("?compound_iri"):::projected 
  v10("?compound_name")
  v5("?compound_str"):::projected 
  v8("?compound_url"):::projected 
  v6("?xref")
  a1((" "))
  c3(["cello:CellLine"]):::iri 
  v1 --"a"-->  a1
  a1 --"rdfs:subClassOf"-->  c3
  v1 --"cello:recommendedName"-->  v2
  v1 --"cello:hasResistance"-->  v3
  v3 --"a"-->  v4
  v3 --"cello:name"-->  v5
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v3 -."cello:isIdentifiedByXref".->  v6
    v6 --"cello:accession"-->  v7
    v6 --"rdfs:seeAlso"-->  v8
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v3 -."cello:isIdentifiedByIRI".->  v9
  end
  bind0[/"substring(?compound_str,'0^^xsd:integer','36^^xsd:integer')"/]
  v5 --o bind0
  bind0 --as--o v10