Skip to content

Commit

Permalink
fix: windows path bug in lcd parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Dec 24, 2023
1 parent 99cc7e9 commit 1c18870
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Added `...` argument to `read_chroms` for supplying additional arguments to parsers.
* Added alias to `read_chroms` for reading `mzxml` files with `RaMS`.
* Added `precision` argument to `call_rainbow` to control number of digits "mz" values are rounded to. (Also changed default behavior so values are rounded to one decimal by default).
* Fixed bug in `read_shimadzu_lcd` on Windows due to issue with passing escaped paths to Python.
* Updated documentation of various functions.

## chromConverter 0.5.0
Expand Down
2 changes: 1 addition & 1 deletion R/read_shimadzu_lcd.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export_stream <- function(path_in, stream, path_out, remove_null_bytes = FALSE,
reticulate::py_run_string('data = st.read()')

if (missing(path_out)){
path_out <- tempfile()
path_out <- fs::file_temp()
}
if (remove_null_bytes){
reticulate::py_run_string("data = data.replace(b'\\x00', b'')")
Expand Down
17 changes: 10 additions & 7 deletions tests/testthat/test-extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,27 +295,30 @@ test_that("read_peaklist can read `Shimadzu` ascii (PDA) files", {
expect_equal(colnames(x[[1]]), c("sample", "rt", "start", "end", "area", "height"))
})

test_that("read_chroms can read 'Shimadzu' ascii (PDA) files", {
test_that("read_chroms can read 'Shimadzu' PDA files (ascii and LCD)", {
skip_on_cran()
skip_if_not_installed("chromConverterExtraTests")

path <- system.file("shimadzuDAD_Anthocyanin.txt",
path_ascii <- system.file("shimadzuDAD_Anthocyanin.txt",
package = "chromConverterExtraTests")
skip_if_not(file.exists(path))
skip_if_not(file.exists(path_ascii))

x <- read_chroms(path, format_in = "shimadzu_dad", progress_bar = FALSE)[[1]]
path_lcd <- system.file("Anthocyanin.lcd", package = "chromConverterExtraTests")
skip_if_not(file.exists(path_lcd))

x <- read_chroms(path_ascii, format_in = "shimadzu_dad", progress_bar = FALSE)[[1]]
expect_equal(class(x)[1], "matrix")
expect_equal(dim(x), c(4689, 328))
expect_equal(attr(x, "parser"), "chromconverter")
expect_equal(attr(x, "data_format"), "wide")

x1 <- read_chroms(path, format_in="shimadzu_dad", progress_bar = FALSE,
x1 <- read_chroms(path_ascii, format_in="shimadzu_dad", progress_bar = FALSE,
data_format = "long", format_out = "data.frame")[[1]]
expect_equal(class(x1)[1], "data.frame")
expect_equal(dim(x1), c(4689*328, 3))

path <- system.file("Anthocyanin.lcd", package = "chromConverterExtraTests")
x2 <- read_chroms(path, progress_bar = FALSE)[[1]]

x2 <- read_chroms(path_lcd, progress_bar = FALSE)[[1]]
expect_equal(dim(x2),c(4689,328))
expect_equal(x, x2, ignore_attr = TRUE)
})
Expand Down

0 comments on commit 1c18870

Please sign in to comment.