diff --git a/R/annotate.R b/R/annotate.R index 25328d6..01f8dde 100644 --- a/R/annotate.R +++ b/R/annotate.R @@ -381,10 +381,10 @@ clioannotationdf2list <- function(x, write_empty_fields=FALSE) { } # turns it into a list of lists - i64class=class(x$bodyid) + i64cols=sapply(x, inherits, 'integer64') x=purrr::transpose(x) - fix_bodyid <- function(x) {class(x[['bodyid']]) <-i64class; x} - x=purrr::map(x, fix_bodyid) + fix_bodyid <- function(x, cols='bodyid') {for(col in cols) class(x[[col]]) <-'integer64'; x} + x=purrr::map(x, fix_bodyid, cols=which(i64cols)) purge_empty <- function(x) purrr::keep(x, .p=function(x) length(x)>0 && !any(is.na(x)) && any(nzchar(x))) if(!write_empty_fields) x=purrr::map(x, purge_empty) diff --git a/tests/testthat/test-clio.R b/tests/testthat/test-clio.R index 76c3e5d..a515e3a 100644 --- a/tests/testthat/test-clio.R +++ b/tests/testthat/test-clio.R @@ -99,7 +99,7 @@ test_that("manc_point_annotations/clioannotationdf2list works", { entry_nerve = c("None", "None", "None", "None"), exit_nerve = c("CvC", "CvC", "CvC", "CvC"), - group = c(NA, 10223, 10223, 10245), + group = manc_ids(c(NA, 10223, 10223, 10245), integer64 = T, unique = F), user = c( "jefferis@gmail.com", "jefferis@gmail.com", @@ -124,7 +124,7 @@ test_that("manc_point_annotations/clioannotationdf2list works", { ) expect_known_hash(cliolist <- clioannotationdf2list(ansforuploadsample), - "b57d0a3fdf") + "9783889b09") # a row with only bodyid should be dropped ansforuploadsample[5,'bodyid']=1 expect_equal(clioannotationdf2list(ansforuploadsample), cliolist)