Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikidata query to get other species identifiers #15

Open
juba opened this issue Jul 15, 2024 · 2 comments
Open

Wikidata query to get other species identifiers #15

juba opened this issue Jul 15, 2024 · 2 comments
Assignees

Comments

@juba
Copy link
Member

juba commented Jul 15, 2024

Should be a double query:

  • one on the taxid
  • one on the sciname if the species has no taxid in wikidata

See what identifiers to get back.

See also #6

@juba juba self-assigned this Jul 15, 2024
@juba
Copy link
Member Author

juba commented Jul 15, 2024

Query template for querying taxid + sciname. Problem: it can yield wrong results if duplicated scinames.

SELECT DISTINCT * WHERE {
{SELECT ?gbifID ?otolID ?wormsID WHERE {
  ?species wdt:P685 "40".
  OPTIONAL { ?species wdt:P846 ?gbifID. }
  OPTIONAL { ?species wdt:P9157 ?otolID. }
  OPTIONAL { ?species wdt:P850 ?wormsID. }
}}
UNION {
SELECT DISTINCT ?gbifID ?otolID ?wormsID  WHERE {
  ?species ?label "Stigmatella"@en.  
  OPTIONAL { ?species wdt:P846 ?gbifID. }
  OPTIONAL { ?species wdt:P9157 ?otolID. }
  OPTIONAL { ?species wdt:P850 ?wormsID. } 
}}}

Example for Stigmatella

Simpler template only querying taxid:

SELECT ?gbifID ?otolID ?wormsID WHERE {
  ?species wdt:P685 "40".
  OPTIONAL { ?species wdt:P846 ?gbifID. }
  OPTIONAL { ?species wdt:P9157 ?otolID. }
  OPTIONAL { ?species wdt:P850 ?wormsID. }
}

Example for Stigmatella

@juba
Copy link
Member Author

juba commented Jul 16, 2024

It seems better not to query on sciname to avoid wrong results.

More complete query (here for 9615, canis lupus familiaris):

SELECT ?item ?ncbi ?gbifID ?opentolID ?wormsID ?inaturalistID ?catalogueOfLifeID ?iucn ?iucnStatus WHERE {
  ?item wdt:P685 "9615".
  OPTIONAL { ?item wdt:P685 ?ncbi. }  
  OPTIONAL { ?item wdt:P846 ?gbifID. }
  OPTIONAL { ?item wdt:P9157 ?opentolID. }
  OPTIONAL { ?item wdt:P850 ?wormsID. }
  OPTIONAL { ?item wdt:P3151 ?inaturalistID. } 
  OPTIONAL { ?item wdt:P10585 ?catalogueOfLifeID. } 
  OPTIONAL { ?item wdt:P627 ?iucn. }   
  OPTIONAL { ?item wdt:P141 ?iucnStatus. } 
}

Example for canis lupus

Note: this query can return several rows, as this example illustrates. There are two wikidata entries associated to taxid 9609: Canis familiaris and Canis lupus familiaris.

@juba juba changed the title Create wikidata quey to get other species identifiers Wikidata query to get other species identifiers Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant