query-5f51b50928067d77a5fae68e7057bc09

rq turtle/ttl

Return gene counts for each bacterial genome in Wikidata SELECT ?species ?label (count (DISTINCT ?gene) as ?gene_counts) WHERE { ?gene wdt:P31 wd:Q7187 . ?gene wdt:P703 ?species . ?species wdt:P171* wd:Q10876 . ?species rdfs:label ?label FILTER (lang(?label) = "en") . } GROUP BY ?species ?label ORDER BY DESC(?gene_counts)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#Return gene counts for each bacterial genome in Wikidata
SELECT ?species ?label (count (DISTINCT ?gene) as ?gene_counts) WHERE {
  ?gene wdt:P31 wd:Q7187 .
  ?gene wdt:P703 ?species .
  ?species wdt:P171* wd:Q10876 .
  ?species rdfs:label ?label FILTER (lang(?label) = "en") .
} GROUP BY ?species ?label ORDER BY DESC(?gene_counts)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?gene"):::projected v5("?gene_counts") v2("?label"):::projected v4("?species"):::projected c3(["wd:Q7187"]):::iri c6(["wd:Q10876"]):::iri f0[["?label = 'en'"]] f0 --> v2 v3 --"wdt:P31"--> c3 v3 --"wdt:P703"--> v4 v4 --"wdt:P171"--> c6 v4 --"rdfs:label"--> v2 bind2[/"count(?gene)"/] v3 --o bind2 bind2 --as--o v5