Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

The taxon function has no method to pass a taxon ID directly #17

Closed
tpoisot opened this issue Feb 28, 2019 · 6 comments · Fixed by #20
Closed

The taxon function has no method to pass a taxon ID directly #17

tpoisot opened this issue Feb 28, 2019 · 6 comments · Fixed by #20
Assignees
Labels
enhancement first-pr Good first pull request!

Comments

@tpoisot
Copy link
Member

tpoisot commented Feb 28, 2019

Currently, taxon performs only text search, but sometimes the ID of the taxon is known (for example, when we want the genus of a given species). This would require a second method.

The taxon function is defined here: https://github.com/EcoJulia/GBIF.jl/blob/master/src/taxon.jl

The GBIF API endpoint for taxa by ID is here: http://api.gbif.org/v1/species/216

@tpoisot tpoisot self-assigned this Feb 28, 2019
@tpoisot tpoisot added the first-pr Good first pull request! label Feb 28, 2019
@MichielStock
Copy link
Contributor

@tpoisot Let's see if I can do this in half an hour!

@tpoisot
Copy link
Member Author

tpoisot commented Mar 3, 2019

🎉 make your PR on master, and @ me if you have questions!

@MichielStock
Copy link
Contributor

I don't have much experience with querying a database:

  • Should I write a function with method taxon(taxonID::Int) to indicate that we have a key?
  • So the args would be args = Dict{String, Any}("name" => 216, "strict" => strict, "verbose" => verbose)
  • line 68
   sp_s_url = gbifurl * "species/match"

should then be

   sp_s_url = gbifurl * "species"

This is how I understand it from the API, though the body which is collected always matches WELP....

Can you point me in the right direction?

@tpoisot
Copy link
Member Author

tpoisot commented Mar 4, 2019

@MichielStock the taxa informations are stored as a Pair: name => id, so maybe the function can have a method that accepts this. I would see two of them, in fact:

taxon(t::Pair) = taxon(t.second)
function taxon(id::Int)
 # general case with only the ID
end

And I think that in your example query, name should be idinstead.

@MichielStock
Copy link
Contributor

MichielStock commented Mar 4, 2019

OK, seems to work, though the result of such a query does not have the keys status, confidence and matchType, which are required by GBIFTaxon(o::Dict{String, Any}).

I can either

  • add default values for this
  • make this optional for GBIFTaxon

@tpoisot
Copy link
Member Author

tpoisot commented Mar 5, 2019

@MichielStock can you open a pull request? I'll have a look at what the changes were, and can give better advice on status, etc.

By the way, please also add your name to the .zenodo.json file at the root of the project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement first-pr Good first pull request!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants