Otoliths / rFishTaxa

R Interface to 'Eschmeyer's Catalog of Fishes'
Apache License 2.0
5 stars 4 forks source link

Error in CAS search #5

Open TBurla opened 1 year ago

TBurla commented 1 year ago

Hi, I have been using the program for several orders of fish and, in some of them, the search has some error, at first I thought that it could be caused by some special character (and I'm still checking for them), but now I saw the same message to the following search. Specificity with "Colomesus asellus" or "Colomesus".

s_sp <- c("Colomesus asellus","Colomesus tocantinensis")

Eschmeyer's Catalog of Fishes search

CAS <- search_cas(query = s_sp, type = "species") %>%

  • left_join(species_family()[, 1:4], by = "family") Error in dplyr::mutate(): ℹ In argument: species = stringr::str_split(content, "\\. ", simplify = T)[, 1]. Caused by error in stringr::str_split(content, "\\. ", simplify = T)[, 1]: ! subscript out of bounds Run rlang::last_trace() to see where the error occurred.

    TETRAODONTIFORMES -> For each group, change the name of the group and the s_sp

    Species list

    s_sp <- c("Colomesus asellus", "Colomesus tocantinensis")

    Eschmeyer's Catalog of Fishes search

    CAS <- search_cas(query = s_sp, type = "species") %>%

  • left_join(species_family()[, 1:4], by = "family") Error in dplyr::mutate(): ℹ In argument: species = stringr::str_split(content, "\\. ", simplify = T)[, 1]. Caused by error in stringr::str_split(content, "\\. ", simplify = T)[, 1]: ! subscript out of bounds Run rlang::last_trace() to see where the error occurred. rlang::last_trace() <error/dplyr:::mutate_error> Error in dplyr::mutate(): ℹ In argument: species = stringr::str_split(content, "\\. ", simplify = T)[, 1]. Caused by error in stringr::str_split(content, "\\. ", simplify = T)[, 1]: ! subscript out of bounds

    Backtrace: ▆

    1. ├─search_cas(query = s_sp, type = "species") %>% ...
    2. ├─dplyr::left_join(., species_family()[, 1:4], by = "family")
    3. ├─rFishTaxa::search_cas(query = s_sp, type = "species")
    4. │ └─base::lapply(...)
    5. │ └─rFishTaxa (local) FUN(X[[i]], ...)
    6. │ └─rFishTaxa:::get_cas(x, type = type)
    7. │ └─... %>% dplyr::select(query, species_author, family, status)
    8. ├─dplyr::select(., query, species_author, family, status)
    9. ├─stats::na.omit(.)
    10. ├─dplyr::mutate(...)
    11. └─dplyr:::mutate.data.frame(...)
    12. └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
    13. ├─base::withCallingHandlers(...)
    14. └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
    15. └─mask$eval_all_mutate(quo)
    16. └─dplyr (local) eval() Run rlang::last_trace(drop = FALSE) to see 2 hidden frames. rlang::last_trace(drop = FALSE) <error/dplyr:::mutate_error> Error in dplyr::mutate(): ℹ In argument: species = stringr::str_split(content, "\\. ", simplify = T)[, 1]. Caused by error in stringr::str_split(content, "\\. ", simplify = T)[, 1]: ! subscript out of bounds

      Backtrace: ▆

    17. ├─search_cas(query = s_sp, type = "species") %>% ...
    18. ├─dplyr::left_join(., species_family()[, 1:4], by = "family")
    19. ├─rFishTaxa::search_cas(query = s_sp, type = "species")
    20. │ └─base::lapply(...)
    21. │ └─rFishTaxa (local) FUN(X[[i]], ...)
    22. │ └─rFishTaxa:::get_cas(x, type = type)
    23. │ └─... %>% dplyr::select(query, species_author, family, status)
    24. ├─dplyr::select(., query, species_author, family, status)
    25. ├─stats::na.omit(.)
    26. ├─dplyr::mutate(...)
    27. ├─dplyr:::mutate.data.frame(...)
    28. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
    29. │ ├─base::withCallingHandlers(...)
    30. │ └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
    31. │ └─mask$eval_all_mutate(quo)
    32. │ └─dplyr (local) eval()
    33. └─dplyr (local) <fn>(<sbscOOBE>)
    34. └─rlang::abort(message, class = error_class, parent = parent, call = error_call)
akarolinamoreno commented 11 months ago

Did you manage to find a solution? I am also encountering the same error for some species..

TBurla commented 9 months ago

I used the code below to know which species was the last that passed through the search, them searched the species or genus in CAS to see what happened. Some where writing mistakes, but the majority were old names that were not used, but you can trace the history in CAS site. I took the last valid name to replace the species names with problem and it worked well.

#Create empty data frame to store results
CAS_search <- data.frame(query = character(),
                         species_author = character(),
                         species = character(),
                         author = character(),
                         family = character(),
                         status = character(),
                         class = character(),
                         order = character(),
                         subfamily = character(),
                         stringsAsFactors = FALSE)

#loop through each species
for (species in data$species){
  #Construct cas query
  CAS_query <- paste0(species)
  #Perform CAS search
  CAS_r <- search_cas(query = CAS_query, type = "species") %>% left_join(species_family()[, 1:4], by = "family")
  CAS_search <- bind_rows(CAS_search, CAS_r)
}