A set of SPARQL examples that are used in LOTUS
Maintenance. Referenced compound-taxon pairs on Wikidata (assigned to incorrect homonym).
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#title: Maintenance. Referenced compound-taxon pairs on Wikidata (assigned to incorrect homonym).
SELECT
(REPLACE(STR(?compound), ".*Q", "Q") AS ?qid)
(REPLACE(STR(?taxon_incorrect), ".*Q", "Q") AS ?MINUSP703) # To change manually to -P703
(REPLACE(STR(?taxon_correct), ".*Q", "Q") AS ?P703)
(REPLACE(STR(?reference), ".*Q", "Q") AS ?S248) WHERE {
  VALUES ?taxon_incorrect {
    wd:Q1651414
  }
  VALUES ?taxon_correct {
    wd:Q44789
  }
  ?compound p:P703 ?statement.
  ?statement ps:P703 ?taxon_incorrect;
    (prov:wasDerivedFrom/pr:P248) ?reference.
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?MINUSP703")
  v8("?P703")
  v9("?S248")
  v3("?compound"):::projected 
  v6("?qid")
  v5("?reference"):::projected 
  v4("?statement")
  v2("?taxon_correct"):::projected 
  v1("?taxon_incorrect"):::projected 
  a1((" "))
  bind0[/VALUES ?taxon_incorrect/]
  bind0-->v1
  bind00(["wd:Q1651414"])
  bind00 --> bind0
  bind1[/VALUES ?taxon_correct/]
  bind1-->v2
  bind10(["wd:Q44789"])
  bind10 --> bind1
  v3 --"p:P703"-->  v4
  v4 --"p:statement/P703"-->  v1
  v4 --"prov:wasDerivedFrom"-->  a1
  a1 --"p:reference/P248"-->  v5
  bind2[/"replace(str(?compound),'.*Q','Q')"/]
  v3 --o bind2
  bind2 --as--o v6
  bind3[/"replace(str(?taxon_incorrect),'.*Q','Q')"/]
  v1 --o bind3
  bind3 --as--o v7
  bind4[/"replace(str(?taxon_correct),'.*Q','Q')"/]
  v2 --o bind4
  bind4 --as--o v8
  bind5[/"replace(str(?reference),'.*Q','Q')"/]
  v5 --o bind5
  bind5 --as--o v9