sparql-examples

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

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

Query_163

rq turtle/ttl

Some topic comments (optionally with their source) about cell lines

Use at


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 ?annot_class ?source ?shortened_comment where {
  values ?annot_class {
    cello:AnecdotalComment
    cello:BiotechnologyComment
    cello:CautionComment
    cello:CharacteristicsComment
    cello:DonorInfoComment
    cello:DoublingTime
    cello:OmicsInfo
    cello:ProblematicCellLineComment
    cello:MiscellaneousInfoComment
  }
  ?prop rdfs:subPropertyOf cello:hasAnnotation .
  ?cl ?prop ?annot .
  ?cl cello:recommendedName ?cl_name .
  ?annot a ?annot_class .
  ?annot rdfs:comment ?comment .
  optional {
    ?annot cello:hasSource ?s .
  	optional { ?s cello:originatesFrom / a ?st }.
   	optional { ?s cello:originatesFrom / cello:internalId ?id }   	# src origin is a xref or a publi
    optional { ?s cello:originatesFrom / skos:prefLabel ?org }      # src origin is an organization
    optional { ?s rdfs:label ?lb }                                  # src origin not specified
  }
  bind (coalesce(?id, ?org, ?lb, '-') as ?source)
  bind (coalesce(?st, '-') as ?source_type)
  bind (substr(?comment, 0, 80) as ?shortened_comment)
  #filter (?source != '-') # uncomment to get only sourced comments
}
order by ?cl
limit 100
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?annot")
  v2("?annot_class"):::projected 
  v1("?cl"):::projected 
  v5("?cl_name"):::projected 
  v6("?comment")
  v9("?id")
  v11("?lb")
  v10("?org")
  v3("?prop")
  v7("?s")
  v14("?shortened_comment"):::projected 
  v12("?source"):::projected 
  v13("?source_type")
  v8("?st")
  a1((" "))
  a2((" "))
  a3((" "))
  c2(["cello:hasAnnotation"]):::iri 
  bind0[/VALUES ?annot_class/]
  bind0-->v2
  bind00(["cello:AnecdotalComment"])
  bind00 --> bind0
  bind01(["cello:BiotechnologyComment"])
  bind01 --> bind0
  bind02(["cello:CautionComment"])
  bind02 --> bind0
  bind03(["cello:CharacteristicsComment"])
  bind03 --> bind0
  bind04(["cello:DonorInfoComment"])
  bind04 --> bind0
  bind05(["cello:DoublingTime"])
  bind05 --> bind0
  bind06(["cello:OmicsInfo"])
  bind06 --> bind0
  bind07(["cello:ProblematicCellLineComment"])
  bind07 --> bind0
  bind08(["cello:MiscellaneousInfoComment"])
  bind08 --> bind0
  v3 --"rdfs:subPropertyOf"-->  c2
  v1 -->v3--> v4
  v1 --"cello:recommendedName"-->  v5
  v4 --"a"-->  v2
  v4 --"rdfs:comment"-->  v6
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."cello:hasSource".->  v7
    subgraph optional1["(optional)"]
    style optional1 fill:#bbf,stroke-dasharray: 5 5;
      v7 -."cello:originatesFrom".->  a1
      a1 --"a"-->  v8
    end
    subgraph optional2["(optional)"]
    style optional2 fill:#bbf,stroke-dasharray: 5 5;
      v7 -."cello:originatesFrom".->  a2
      a2 --"cello:internalId"-->  v9
    end
    subgraph optional3["(optional)"]
    style optional3 fill:#bbf,stroke-dasharray: 5 5;
      v7 -."cello:originatesFrom".->  a3
      a3 --"skos:prefLabel"-->  v10
    end
    subgraph optional4["(optional)"]
    style optional4 fill:#bbf,stroke-dasharray: 5 5;
      v7 -."rdfs:label".->  v11
    end
  end
  bind1[/"?id?org?lb'-'"/]
  v9 --o bind1
  v10 --o bind1
  v11 --o bind1
  bind1 --as--o v12
  bind2[/"?st'-'"/]
  v8 --o bind2
  bind2 --as--o v13
  bind3[/"substring(?comment,'0^^xsd:integer','80^^xsd:integer')"/]
  v6 --o bind3
  bind3 --as--o v14