query-d5639ab7aff9eccfdac76cae06b4f7ab

rq turtle/ttl

External ID vs. reference URL (P854)

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?id ?taxonName ?urlAsSource ?importedFromWikimediaProject ?statedIn WHERE {
      ?item wdt:P225 ?taxonName .
      ?item p:P685/ps:P685 ?id .
      ?item p:P685 ?idStatement .      
      ?idStatement prov:wasDerivedFrom ?ref . 
      OPTIONAL {?ref pr:P854 ?urlAsSource} .
      OPTIONAL {?ref pr:P143 ?importedFromWikimediaProject} .
      OPTIONAL {?ref pr:P248 ?statedIn} . 
      BIND(str(?urlAsSource) as ?urlAsSourceString)
      FILTER(!bound(?statedIn))
      FILTER(strStarts(?urlAsSourceString, "https://www.ncbi.nlm.nih.gov/"))
      #FILTER(bound(?statedIn) && !sameTerm(?statedIn, wd:Q13711410))
}
ORDER BY ASC(xsd:integer(?id)) ASC(?taxonName)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?id"):::projected v6("?idStatement") v9("?importedFromWikimediaProject"):::projected v5("?item"):::projected v7("?ref") v4("?statedIn"):::projected v2("?taxonName"):::projected v8("?urlAsSource"):::projected v10("?urlAsSourceString") a1((" ")) f0[["starts-with(?urlAsSourceString,'https://www.ncbi.nlm.nih.gov/')"]] f0 --> v10 f1[["not bound(?statedIn)"]] f1 --> v4 v5 --"p:direct/P225"--> v2 v5 --"p:P685"--> a1 a1 --"p:statement/P685"--> v1 v5 --"p:P685"--> v6 v6 --"prov:wasDerivedFrom"--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:reference/P854".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:reference/P143".-> v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:reference/P248".-> v4 end bind2[/"str(?urlAsSource)"/] v8 --o bind2 bind2 --as--o v10