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

ex:176_taxon_names_not_unique a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Find up:scientificName values that label more than one taxon. The same string can genuinely be reused for unrelated nodes in UniProt's taxonomy: a higher-rank name is sometimes also reused at genus rank (e.g. Acanthocephala, a phylum of thorny-headed worms, is also an insect genus elsewhere in the tree); \"environmental samples\" is a special case, a placeholder reused thousands of times under many different higher taxa for unclassified/metagenomic entries"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX up: <http://purl.uniprot.org/core/>

SELECT
  ?scientificName
  (COUNT(?taxon) AS ?taxonCount)
  (GROUP_CONCAT(SUBSTR(STR(?taxon), 34); separator=",") AS ?taxonIds)
WHERE {
  ?taxon up:scientificName ?scientificName .
}
GROUP BY ?scientificName
HAVING (COUNT(?taxon) > 1)
ORDER BY ?scientificName""" ;
    schema:keywords "taxonomy" , "scientificName" , "duplicate" ;
    schema:target <https://sparql.uniprot.org/sparql/> .
