Skip to content

Sample query: What database record types have links to PubMed identifiers?

bill-baumgartner edited this page Jun 23, 2019 · 1 revision
PREFIX ccp: <http://ccp.ucdenver.edu/obo/ext/>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dc_terms: <http://purl.org/dc/terms/>

select ?record_type_name (count (?record) as ?record_count) (count (?pmid) as ?pmid_token_count) (count (distinct ?pmid) as ?pmid_type_count) {

  ### find all PubMed identifiers
  ?pmid rdfs:subClassOf ccp:IAO_EXT_0000274 . # IAO_EXT_0000274 = IAO_EXT:pubmed_identifier
  ### When a field value is an identifier, the field value is typed as the identifier
  ?field_value rdf:type ?pmid .
  ### records have field values as parts; this query takes advantage of
  ### the fact that only field values are typed to identifiers
  ?record obo:BFO_0000051 ?field_value . # BFO_0000051 = BFO:has_part
  
  ### get the label for the record type
  ?record rdf:type ?record_type .
  ?record_type rdfs:label ?record_type_name .
  
}
group by ?record_type_name