Skip to content

Commit

Permalink
add code for warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Oct 6, 2023
1 parent 8c627ee commit f706bfb
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions inst/scripts/phytools2.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,44 @@ library(tidyr)
library(ggplot2)
library(ape)

# phys_name <- 'antimicrobial resistance'
# phys_name <- 'acetate producing'
# phys_name <- 'aerophilicity'

phys_names <- c(
'aerophilicity', 'acetate producing', 'antimicrobial resistance'
## multistate-intersection
'aerophilicity',

## multistate-union
'antimicrobial resistance',

## binary
'acetate producing'

)

phys <- physiologies(phys_names)

## There might be some warnings due to taxizedb. They can be ignored for now
## This is due to changes in taxonomy, so the taxonomy might require
## to be updated from time to time
phys_data_ready <- vector('list', length(phys))
myWarnings <- vector('list', length(phys))
for (i in seq_along(phys_data_ready)) {
names(phys_data_ready)[i] <- names(phys)[i]
res <- getDataReady(filterData(phys[[i]]))
if (is.null(res))
next
phys_data_ready[[i]] <- res
name <- names(phys)[i]
message('Preparing ', name, '.')
names(phys_data_ready)[i] <- name
names(myWarnings)[i] <- name
wngs <- list()
suppressWarnings({
withCallingHandlers(
dat <- getDataReady(filterData(phys[[i]])),
warning = function(w) {
wngs <<- c(wngs, list(w))
}
)
})
if (length(wngs) > 0)
myWarnings[[i]] <- wngs
}
myWarnings <- discard(myWarnings, is.null)







Expand Down

0 comments on commit f706bfb

Please sign in to comment.