sparql-examples

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

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

3

Find LCA in the OrthoDB tree for fruit fly and honey bee taxons

Use at

PREFIX up: <http://purl.uniprot.org/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX : <http://purl.orthodb.org/>

SELECT DISTINCT *
WHERE {
    ?lca a :Clade ; up:scientificName ?lcaname .
    taxon:7227  rdfs:subClassOf* ?lca .
    taxon:7460 rdfs:subClassOf* ?lca .
    FILTER(not exists {
        ?xca a :Clade ; rdfs:subClassOf ?lca .
        taxon:7227    rdfs:subClassOf* ?xca .
        taxon:7460   rdfs:subClassOf* ?xca .
    })
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?lca"):::projected 
  v3("?lcaname"):::projected 
  v1("?xca")
  c4(["taxon:7227"]):::iri 
  c2([":Clade"]):::iri 
  c5(["taxon:7460"]):::iri 
  f0[["not  "]]
  subgraph f0e0["Exists Clause"]
    e0v1 --"a"-->  e0c2
    e0v1 --"rdfs:subClassOf"-->  e0v2
    e0c4 --"rdfs:subClassOf"-->  e0v1
    e0c5 --"rdfs:subClassOf"-->  e0v1
    e0v2("?lca"):::projected 
    e0v1("?xca"):::projected 
    e0c4(["taxon:7227"]):::iri 
    e0c2([":Clade"]):::iri 
    e0c5(["taxon:7460"]):::iri 
  end
  f0--EXISTS--> f0e0
  f0 --> v1
  f0 --> c1
  f0 --> c2
  f0 --> c3
  f0 --> v2
  f0 --> c4
  f0 --> c5
  v1 --"a"-->  c2
  v1 --"rdfs:subClassOf"-->  v2
  c4 --"rdfs:subClassOf"-->  v1
  c5 --"rdfs:subClassOf"-->  v1
  v2 --"a"-->  c2
  v2 --"up:scientificName"-->  v3
  c4 --"rdfs:subClassOf"-->  v2
  c5 --"rdfs:subClassOf"-->  v2