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

taxize::gnr* issues #57

Open
cmbappleby opened this issue Jan 29, 2025 · 7 comments
Open

taxize::gnr* issues #57

cmbappleby opened this issue Jan 29, 2025 · 7 comments

Comments

@cmbappleby
Copy link

I'm trying to use EMLassemblyline::template_taxonomic_coverage(), and I get "Error: Service Unavailable (HTTP 503)". After some digging, it seems that resolver.globalnames.org is no longer working and has been replaced with verifier.globalnames.org. The taxize package has a function, gna_verifier() to replace gnr_resolve(); however, there does not appear to be a function that replaces gnr_datasources(). Not sure if this is a taxomonyCleanr issue or a taxize issue.

@clnsmth
Copy link
Contributor

clnsmth commented Jan 29, 2025

Thanks for reaching out @cmbappleby.

Which version of EMLassemblyline are you running?

@cmbappleby
Copy link
Author

@clnsmth 3.3.5

@cmbappleby
Copy link
Author

@clnsmth I cloned taxonomyCleanr and tweaked the code, and I got EMLassemblyline::template_taxonomic_coverage() to work. Not sure if it's exactly how it's supposed to work, but it works.

In get_authority() I replaced gnr_resolve() with:

# Use Global Names Verifier to see if the taxon can be found in data.source
  resp <- suppressWarnings(
    taxize::gna_verifier(
      names = taxon,
      data_sources = as.character(data.source)
    )
  )

And I changed the code in this function:

load_gnr_datasources <- function() {
  # Define the API URL for taxa authorities
  url <- "https://verifier.globalnames.org/api/v1/data_sources"

  # Make the GET request to the API
  response <- httr::GET(url)

  # Parse the response JSON to a list
  taxa_authorities <- jsonlite::fromJSON(httr::content(response, "text"))

  gnr_list <- as.data.frame(taxa_authorities)

  return(gnr_list)
}

I do get a warning No encoding supplied: defaulting to UTF-8 and haven't done any troubleshooting to see what's causing it.

@clnsmth
Copy link
Contributor

clnsmth commented Jan 30, 2025

Thanks @cmbappleby, I'll take a closer look at this code.

Would you mind checking if this issue persists after installing the latest versions of taxonomyCleanr (v.1.6.6) and EMLassemblyline (v3.5.6).

@cmbappleby
Copy link
Author

cmbappleby commented Jan 30, 2025

@clnsmth I'm using the latest version of EMLassemblyline. The code I changed was from v.1.6.6 of taxonomyCleanr, which calls taxize functions that utilize Global Names Resolver, which is no longer working.

From v.1.6.6 of taxonomyCleanr

load_gnr_datasources <- function() {
  gnr_list <- as.data.frame(taxize::gnr_datasources())
  gnr_list$title[gnr_list$id == "3"] <- "ITIS"
  return(gnr_list)
}

get_authority <- function(taxon, data.source){

  # Tell user what authority is being queried
  gnr_list <- load_gnr_datasources()
  use_i <- gnr_list[ , 'id'] == data.source
  message('Searching ', gnr_list[use_i, 'title'],' for "',taxon,'"')

  # User Global Names Resolver to see if the taxon can be found in data.source
  resp <- suppressWarnings(
    taxize::gnr_resolve(sci = taxon,
                        data_source_ids = as.character(data.source),
                        resolve_once = TRUE,
                        canonical = TRUE,
                        best_match_only = TRUE))
  # Parse response and return and first item found
  if (nrow(resp) != 0) {
    res <- list(resolved_name = resp$matched_name2[1],
                authority = gnr_list$title[use_i],
                score = resp$score[1])
    return(res)
  } else {
    res <- list(resolved_name =  NA_character_,
                authority = NA_character_,
                score = NA_character_)
    return(res)
  }
}

@cmbappleby
Copy link
Author

@clnsmth gnr_resolve() will be removed with the next update to taxize. They have also created a gna_data_sources() function to replace to gnr_datasources().

@wright13
Copy link

wright13 commented Feb 7, 2025

@clnsmth gnr_resolve() will be removed with the next update to taxize. They have also created a gna_data_sources() function to replace to gnr_datasources().

Looks like taxize 0.10.0 is out now! https://github.com/ropensci/taxize/releases/tag/v0.10.0

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

3 participants