-
Notifications
You must be signed in to change notification settings - Fork 9
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
Resolve taxonomic names from external APIs to PhyloPic #97
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty cool!
ee663c2
to
d9abc06
Compare
(rebasing because of the updated snapshots on main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @willgearty, this works really well, great job! I've made some comments and suggestions - nothing major, but a few things to think about. Let me know if you want to chat about anything.
name <- gsub("_", " ", name) | ||
name <- URLencode(name) | ||
# Query specified API for the name ------------------------------------- | ||
if (api == "eol.org") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works really well but there is quite a bit of repeated code (e.g. L89–97). Could you perhaps start by making a list, subset the list to whatever API is requested and then run the code? I think this will help with managing any updates in future, including adding additional APIs? I get that there is some API specific code which is unavoidable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried my best to reduce some of the repeated code, but the responses from these APIs are just sooooo different.
Co-authored-by: Lewis A. Jones <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me! Thanks for entertaining my pickiness 😄. Great job on turning that around so quickly 🚀
#' @return A `list` where each value is `n` (or fewer) PhyloPic image uuids (or | ||
#' urls if `url = TRUE`) and each name is the taxonomic name as matched and | ||
#' reported by the specified `api`. If `hierarchy` is `FALSE`, the list has | ||
#' length 1. If `hierarchy` is `TRUE`, the list has maximum length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you mean if you have a vector of more than length 1... well I guess if this is the case, does it even need to be named? I guess as long as get_phylopic
and other functions can handle lists, it doesn't matter so much.
#' | ||
#' The following APIs are available for matching (`api`): | ||
#' \itemize{ | ||
#' \item{"eol.org": the \href{https://eol.org/}{Encyclopedia of Life}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
This adds the
resolve_phylopic()
function, which allows users to supply a taxonomic name that they expect to be matched in an external API (EOL, GBIF, PBDB, WoRMs, and OTOL atm) and then use that API to resolve the taxonomic name to PhyloPic. The function can return images (uuids/urls) for just the specified name or for a part of the taxonomic hierarchy (as reported by the API, except for EOL which doesn't supply taxonomic information).This basically accomplishes the asynchronous API searching that the PhyloPic website does, but with much lower overhead than calling all of those APIs within get_uuid (because it is user-driven).
Fixes #66.