sparql-examples

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

View the Project on GitHub German-BioImaging/sparql-examples

001

rq turtle/ttl

What are the ROIs which have the word lymph in its annotation

Use at

PREFIX ns2: <http://www.openmicroscopy.org/rdf/2016-06/ome_core/>
PREFIX ome:    	<http://www.openmicroscopy.org/rdf/2016-06/ome_core/>                
PREFIX redcap: 	<https://population.ahri.org/api/>
PREFIX rdf:    	<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:     	<http://purl.org/dc/elements/1.1/>
PREFIX dct:		<http://purl.org/dc/terms/>
SELECT DISTINCT ?redCapId ?redcapRecord ?omeID ?omeRecord ?specimen_source ?imagename ?ROI ?text
WHERE {    
  # --- REDCap records ---
  ?redcapRecord
    rdf:type redcap:record ;
    redcap:specimen_source ?specimen_source ;
    redcap:lab_id ?redCapId .
  BIND(
    URI(CONCAT("https://population.ahri.org/api/", REPLACE(STR(?redCapId), " ", "")))
    AS ?redcapConstructedURI
  )
#  VALUES ?specimen_source {"5"}  # restrict to IALCH Forensic Pathology
  # --- OME records ---
  ?omeRecord ome:Map ?map ;
  dct:isPartOf ?image  
  .
  ?map
    ome:Key "lab_id_main" ;
    ome:Value ?omeID . 
  BIND(
    URI(CONCAT("https://population.ahri.org/api/", STR(?omeID)))
    AS ?omeConstructedURI
  )
  .	?image dct:hasPart ?pixels ; ome:Name ?imagename
  .	?pixels rdf:type <http://www.openmicroscopy.org/Schemas/OME/2016-06#Pixels>
	; dct:hasPart ?ROI . 
    ?ROI rdf:type <http://www.openmicroscopy.org/Schemas/OME/2016-06#ROI> ;
    ome:shapes ?shapes .
	?shapes ome:Text ?text
#    VALUES ?text{'lymph node'} .
    FILTER REGEX(?text, 'lymph', 'i')
#  . ?roi dct:isPartOf ?pixels; rdf:type <http://www.openmicroscopy.org/Schemas/OME/2016-06#ROI>

  # --- Match records by constructed URI ---
  FILTER(?redcapConstructedURI = ?omeConstructedURI)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v13("?ROI"):::projected 
  v9("?image")
  v12("?imagename"):::projected 
  v8("?map")
  v11("?omeConstructedURI")
  v10("?omeID"):::projected 
  v7("?omeRecord"):::projected 
  v11("?pixels")
  v6("?redCapId"):::projected 
  v7("?redcapConstructedURI")
  v4("?redcapRecord"):::projected 
  v14("?shapes")
  v5("?specimen_source"):::projected 
  v3("?text"):::projected 
  c15([http://www.openmicroscopy.org/Schemas/OME/2016-06#ROI]):::iri 
  c14([http://www.openmicroscopy.org/Schemas/OME/2016-06#Pixels]):::iri 
  c10(["lab_id_main"]):::literal 
  c4([https://population.ahri.org/api/record]):::iri 
  f0[["?redcapConstructedURI = ?omeConstructedURI"]]
  f0 --> v7
  f0 --> v11
  f1[["regex(?text,'lymph','i')"]]
  f1 --> v3
  v4 --"a"-->  c4
  v4 --https://population.ahri.org/api/specimen_source-->  v5
  v4 --https://population.ahri.org/api/lab_id-->  v6
  bind2[/"concat('https://population.ahri.org/api/',replace(str(?redCapId),' ',''))"/]
  v6 --o bind2
  bind2 --as--o v7
  v7 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/Map-->  v8
  v7 --"dc:isPartOf"-->  v9
  v8 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/Key-->  c10
  v8 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/Value-->  v10
  bind3[/"concat('https://population.ahri.org/api/',str(?omeID))"/]
  v10 --o bind3
  bind3 --as--o v11
  v9 --"dc:hasPart"-->  v11
  v9 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/Name-->  v12
  v11 --"a"-->  c14
  v11 --"dc:hasPart"-->  v13
  v13 --"a"-->  c15
  v13 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/shapes-->  v14
  v14 --http://www.openmicroscopy.org/rdf/2016-06/ome_core/Text-->  v3