178_subcellular_location_go_indirect_match

rq turtle/ttl

Find Gene Ontology terms that are a looser match to a UniProt subcellular-location term than the direct skos:exactMatch: GO terms reached from the directly-matched term via rdfs:subClassOf+ (is-a), or via a BFO_0000050 (part_of) owl:Restriction on top of it. GO's own part_of axioms are loaded in the UniProt endpoint as an owl:Restriction blank node (a rdfs:subClassOf [ a owl:Restriction ; owl:onProperty obo:BFO_0000050 ; owl:someValuesFrom b ] means a is part_of b), so combining a property path with that restriction pattern is what it takes to follow "is-a-or-part-of" one more step

Use at

PREFIX up: <http://purl.uniprot.org/core/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT
  ?location
  ?locationName
  ?directGo
  ?relatedGo
WHERE {
  ?location a up:Cellular_Component ;
    skos:prefLabel ?locationName ;
    skos:exactMatch ?directGo .
  {
    ?relatedGo rdfs:subClassOf+ ?directGo .
  } UNION {
    ?relatedGo rdfs:subClassOf [ a owl:Restriction ;
                                   owl:onProperty
                                  obo:BFO_0000050 ;
                                  owl:someValuesFrom ?directGo
    ] .
  }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v3("?directGo"):::projected 
  v1("?location"):::projected 
  v2("?locationName"):::projected 
  v4("?relatedGo"):::projected 
  a1((" "))
  c8(["obo:BFO_0000050"]):::iri 
  c6(["owl:Restriction"]):::iri 
  c2(["up:Cellular_Component"]):::iri 
  v1 --"a"-->  c2
  v1 --"skos:prefLabel"-->  v2
  v1 --"skos:exactMatch"-->  v3
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    a1 --"a"-->  c6
    a1 --"owl:onProperty"-->  c8
    a1 --"owl:someValuesFrom"-->  v3
    v4 --"rdfs:subClassOf"-->  a1
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v4 --"rdfs:subClassOf"-->  v3
  end
  union0r <== or ==> union0l
  end