@prefix ex: <https://sparql.orthodb.org/.well-known/sparql-examples/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:3 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Find LCA in the OrthoDB tree for fruit fly and honey bee taxons"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """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 .
    })
}""" ;
    schema:target <https://sparql.orthodb.org/sparql/> .

