User:William Avery/Taxonomic SPARQL

Incomplete recombination data edit

SELECT ?item ?taxonname
WHERE
{
     ?item p:P225 ?name.
     ?name  ps:P225 ?taxonname.
     ?name  pq:P3831 wd:Q14594740.
  FILTER NOT EXISTS {
         ?item  ps:1403 [].
    }
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

LIMIT 100

List of tephritid taxa and who named them by exploded parent_taxon relationship edit

SELECT ?taxonname ?authLabel ?year
WHERE
{
     ?tephs wdt:P171+ wd:Q626843. 
     ?tephs p:P225 ?name.
     ?name  ps:P225 ?taxonname.
     ?name  pq:P405 ?auth.
     ?name  pq:P574 ?year.
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?authLabel
Try it!

Taxa published by Alexey Diakonoff ordered by year of publication edit

SELECT ?taxonname ?authLabel ?year
WHERE
{
     ?taxa  p:P225 ?name.
     ?name  ps:P225 ?taxonname.
     ?name  pq:P405 wd:Q4721312.
     ?name  pq:P405 ?auth.
     ?name  pq:P574 ?year.
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?year
Try it!

Iguania species names that have a year of publication but no author edit

SELECT ?taxonitem ?taxonname
WHERE
{
     ?taxonitem wdt:P171+ wd:Q661136.   # Iguania
     ?taxonitem p:P105 ?rank.
     ?rank ps:P105 wd:Q7432.            # species
     ?taxonitem p:P225 ?name.

     ?name  ps:P225 ?taxonname.
  
     FILTER EXISTS {
        ?name pq:P574 [] .   # Year of taxon publication
     }
     FILTER NOT EXISTS {
        ?name pq:P405 [] .   # taxon author
     }
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Supposed tribes of butterflies that don't have an English Wikipedia article edit

SELECT ?taxonitem ?taxonname
WHERE
{
     ?taxonitem wdt:P171+ wd:Q756153.   # Papilionoidea
     ?taxonitem p:P105 ?rank.
     ?rank ps:P105 wd:Q227936.          # tribe
     ?taxonitem p:P225 ?name.

     ?name  ps:P225 ?taxonname.
     FILTER NOT EXISTS {
      ?sitelink schema:about ?taxonitem;
      schema:isPartOf <https://en.wikipedia.org/>;
      schema:name [].  
     }
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Saturniidae that have a GBIF Id and an English Wikipedia article, but no taxon author edit

SELECT ?taxonitem ?taxonname
WHERE
{
     ?taxonitem wdt:P171+ wd:Q843104.   # Saturniidae
     ?taxonitem p:P105 ?rank.
     ?taxonitem p:P225 ?name.
     ?taxonitem p:P846 ?gbif_id.
     ?name  ps:P225 ?taxonname.
     FILTER NOT EXISTS {
        ?name pq:P405 [] .   # taxon author
     }  
     FILTER EXISTS {
      ?sitelink schema:about ?taxonitem;
      schema:isPartOf <https://en.wikipedia.org/>;
      schema:name [].  
     }
     SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Taxon names that are "instance of" recombination instead of "object has role" edit

SELECT (COUNT(?name) AS ?count)
WHERE
{
     ?taxa  p:P225 ?name.
     ?name  pq:P31 wd:Q14594740.
}
Try it!

Pairs of gastropod names that are a recombination and its protonym, and both have site links on English Wikipedia edit

SELECT ?recombination ?taxonname ?ocitem ?octaxonname
WHERE
{
     ?recombination wdt:P171+ wd:Q4867740. #Gastropoda
     ?recombination p:P225 ?name.
     ?name  ps:P225 ?taxonname.
  
     ?ocitem wdt:P2868 wd:Q14192851.       #Role of protonym
     ?ocitem p:P225 ?ocname.
     ?ocname  ps:P225 ?octaxonname.
     ?ocitem p:P2868 ?protonym.
     ?protonym pq:P642 ?recombination.


      ?sitelink schema:about ?recombination;
      schema:isPartOf <https://en.wikipedia.org/>;
      schema:name []. 
  
      ?sitelink2 schema:about ?ocitem;
      schema:isPartOf <https://en.wikipedia.org/>;
      schema:name [].  
 

} LIMIT 100
Try it!

ButMoth WiP edit

SELECT DISTINCT ?item ?islep WHERE {
  ?item wdt:P171* wd:Q7674891.
  ?item  p:P3060 [].
  bind(if( exists { ?item wdt:P171+  wd:Q28319}, true, false) AS ?islep)
  filter not exists { ?item wdt:P171+  wd:Q28319}
}
limit 10
Try it!
SELECT DISTINCT ?item WHERE {
  ?item  p:P3060 [].
MINUS {
  ?item wdt:P171+  wd:Q28319
  }
}
Try it!
SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item wdt:P171+ wd:Q22671. 
  ?item  p:P3060 [].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Protonyms with duplicate names edit

SELECT ?taxonname (count(?item) as ?count)
WHERE
{
     ?item wdt:P171+ wd:Q980146. 
     ?item p:P225 ?name.
     ?name  ps:P225 ?taxonname.
     ?item p:P2868 ?statement0.
     ?statement0 ps:P2868 wd:Q14192851.
} group by ?taxonname having( count(?item) > 1)
order by DESC(?count)
Try it!

A bit fishy edit

SELECT ?itemLabel (COUNT(?item) AS ?ct)
WHERE
{
     ?item wdt:P171+ wd:Q127282. 
     ?item p:P31 ?inst.
     ?inst ps:P31 wd:Q16521.  # extant, not extinct or fossil
     ?item p:P225 ?name. 
     ?name  ps:P225 ?taxonname.
     ?item p:P105 ?rank.
     ?rank ps:P105 wd:Q7432.            # species
     ?item schema:description ?itemLabel.
     FILTER (LANG(?itemLabel) = "en" && STR(?itemLabel) != 'species of fish')
} GROUP BY ?itemLabel
ORDER BY DESC(?ct)
Try it!