query-9dc8efe8f834e73aa2805ffacd0231bd

rq turtle/ttl

Common parent taxons of 2 species SELECT ?item ?itemLabel ?depth1 ?depth2 ?taxon_rankLabel { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" . gas:program gas:in wd:Q42196 . gas:program gas:linkType wdt:P171 . gas:program gas:out ?item . gas:program gas:out1 ?depth1 . } SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" . gas:program gas:in wd:Q20980826 . gas:program gas:linkType wdt:P171 . gas:program gas:out ?item . gas:program gas:out1 ?depth2 . } OPTIONAL { ?item wdt:P105 ?taxon_rank . } SERVICE wikibase:label {bd:serviceParam wikibase:language "en" } } ORDER BY (?depth1 + ?depth2) LIMIT 1 # Remove limit to see all higher levels

Use at

PREFIX gas: <http://www.bigdata.com/rdf/gas#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Common parent taxons of 2 species
SELECT ?item ?itemLabel ?depth1 ?depth2 ?taxon_rankLabel
{
  SERVICE gas:service
  {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" .
    gas:program gas:in wd:Q42196 .
    gas:program gas:linkType wdt:P171 .
    gas:program gas:out ?item .
    gas:program gas:out1 ?depth1 .
  }
  SERVICE gas:service
  {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" .
    gas:program gas:in wd:Q20980826 .
    gas:program gas:linkType wdt:P171 .
    gas:program gas:out ?item .
    gas:program gas:out1 ?depth2 .
  }
  OPTIONAL { ?item wdt:P105 ?taxon_rank . }
  SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}
ORDER BY (?depth1 + ?depth2)
LIMIT 1 # Remove limit to see all higher levels

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?depth1"):::projected v2("?depth2"):::projected v3("?item"):::projected v4("?taxon_rank") c2(["gas:program"]):::iri c4(["com.bigdata.rdf.graph.analytics.SSSP"]):::literal c6(["wd:Q42196"]):::iri c11(["wd:Q20980826"]):::iri c16(["en"]):::literal c14(["bd:serviceParam"]):::iri c8(["wdt:P171"]):::iri subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c6 c2 --"gas:linkType"--> c8 c2 --"gas:out"--> v3 c2 --"gas:out1"--> v1 end subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c11 c2 --"gas:linkType"--> c8 c2 --"gas:out"--> v3 c2 --"gas:out1"--> v2 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P105".-> v4 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c14 --"wikibase:language"--> c16 end