query-fd21267c75511cb2c73c51860dc9ae7b
Propertiesparent taxon (P171)taxon rank (P105)Plants of the World Online ID (P5037)IPNI plant ID (P961)
Use at
- https://query.wikidata.org/sparql
 
PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT DISTINCT ?qid ?ipni ?comment
WHERE
{
  SERVICE gas:service {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
                gas:in wd:Q21908; # parent taxon Malvales
                gas:traversalDirection "Reverse" ;
                gas:out ?item ;
                gas:out1 ?depth ;
                gas:maxIterations 10 ;
                gas:linkType wdt:P171 .
  }
  ?item wdt:P105 wd:Q7432; # taxon rank species
        wdt:P5037 ?powo.
  FILTER ( NOT EXISTS { ?item wdt:P961 ?id. } )
  OPTIONAL { ?item wdt:P171 ?linkTo }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
    ?item rdfs:label ?itemLabel .
  }
  FILTER ( !STRENDS(?powo, "-4") ) # POWO IDs ending in -4 are temporary, see: https://powo.science.kew.org/about 
  BIND (CONCAT('"', STRAFTER(?powo, "urn:lsid:ipni.org:names:"), '"') AS ?ipni ) # surround with """ for Quickstatements v2
  BIND ("parsed from existing POWO identifier" AS ?comment)
  BIND (ENCODE_FOR_URI(REPLACE(STR(?item), ".*Q", "Q")) AS ?qid)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v8("?comment"):::projected 
  v4("?depth")
  v3("?id")
  v7("?ipni"):::projected 
  v2("?item")
  v6("?itemLabel")
  v5("?linkTo")
  v1("?powo")
  v9("?qid"):::projected 
  c4(["gas:program"]):::iri 
  c6(["com.bigdata.rdf.graph.analytics.SSSP"]):::literal 
  c10(["Reverse"]):::literal 
  c23(["en"]):::literal 
  c8(["wd:Q21908"]):::iri 
  c18(["wd:Q7432"]):::iri 
  c21(["bd:serviceParam"]):::iri 
  c16(["wdt:P171"]):::iri 
  c14(["10^^xsd:integer"]):::literal 
  f0[["not ends-with(?powo,'-4')"]]
  f0 --> v1
  f1[["not  "]]
  subgraph f1e0["Exists Clause"]
    e0v1 --"wdt:P961"-->  e0v2
    e0v2("?id"):::projected 
    e0v1("?item"):::projected 
  end
  f1--EXISTS--> f1e0
  f1 --> v2
  f1 --> c2
  f1 --> v3
  v2 --"wdt:P961"-->  v3
  subgraph s1["http://www.bigdata.com/rdf/gas#service"]
    style s1 stroke-width:4px;
    c4 --"gas:gasClass"-->  c6
    c4 --"gas:in"-->  c8
    c4 --"gas:traversalDirection"-->  c10
    c4 --"gas:out"-->  v2
    c4 --"gas:out1"-->  v4
    c4 --"gas:maxIterations"-->  c14
    c4 --"gas:linkType"-->  c16
  end
  v2 --"wdt:P105"-->  c18
  v2 --"wdt:P5037"-->  v1
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -->c16--> v5
  end
  subgraph s2["http://wikiba.se/ontology#label"]
    style s2 stroke-width:4px;
    c21 -."wikibase:language".->  c23
    v2 --"rdfs:label"-->  v6
  end
  bind2[/"concat('"',substring-after(?powo,'urn:lsid:ipni.org:names:'),'"')"/]
  v1 --o bind2
  bind2 --as--o v7
  bind3[/"'parsed from existing POWO identifier'"/]
  bind3 --as--o v8
  bind4[/"encode-for-uri(replace(str(?item),'.*Q','Q'))"/]
  v2 --o bind4
  bind4 --as--o v9