Skip to content

Commit

Permalink
Update test_Spectra.R
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Mar 6, 2024
1 parent b413b37 commit ed6cf70
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/testthat/test_Spectra.R
Original file line number Diff line number Diff line change
Expand Up @@ -1105,29 +1105,32 @@ test_that("filterRanges, Spectra works", {
logical_test <- spectraVariables(sps_dia) %in% c("rtime", "precursorMz",
"peaksCount")
expect_error(filterRanges(sps_dia, spectraVariables = logical_test,
ranges = c(30, 350, 200,500, 350, 600)))
ranges = c(30, 350, 200,500, 350, 600)),
"character")
# do not accept values other than numerical
fls <- unique(dataOrigin(sps_dia))
expect_error(filterValues(sps_dia, spectraVariables = "dataOrigin",
values = c(fls[1], fls[1])))
expect_error(filterRanges(sps_dia, spectraVariables = "dataOrigin",
values = c(fls[1], fls[1])), "numerical")
# test too many variables
expect_error(filterRanges(sps_dia, spectraVariables = c("rtime",
"precursorMz",
"peaksCount",
"lowMz"),
ranges = c(30, 350, 200,500, 350, 600)))
ranges = c(30, 350, 200,500, 350, 600)), "Length")
# test too many ranges
expect_error(filterRanges(sps_dia, spectraVariables = c("rtime",
"precursorMz",
"peaksCount"),
ranges = c(30, 350, 200,500, 350, 600, 20, 800)))
ranges = c(30, 350, 200,500, 350, 600, 20, 800)),
"Length")
expect_true(length(sps_dia) > length(filt_spectra))
# test does not accept variables not in spectraData
expect_error(filterRanges(sps_dia, spectraVariables = c("rtime",
"precursorMz",
"peaksCount",
"fakeVar"),
ranges = c(30, 350, 200,500, 350, 600, 20, 800)))
ranges = c(30, 350, 200,500, 350, 600, 20, 800)),
"not available")
# test same results as specific filtering functions
spe_fct <- filterPrecursorMzRange(sps_dia, c(200,500))
range_fct <- filterRanges(sps_dia, spectraVariables = "precursorMz",
Expand All @@ -1146,7 +1149,7 @@ test_that("filterValues, Spectra works", {
## expect error
fls <- unique(dataOrigin(sps_dia))
expect_error(filterValues(sps_dia, spectraVariables = "dataOrigin",
values = fls[1]))
values = fls[1]), "numerical")
## test recycling
filt_spectra <- filterValues(sps_dia, spectraVariables = c("rtime",
"precursorMz",
Expand All @@ -1167,7 +1170,7 @@ test_that("filterValues, Spectra works", {
"precursorMz",
"peaksCount"),
values = c(200, 400, 350),
tolerance = 100))
tolerance = 100), "recycled")
#' test same results as filterPrecursorMzValues
spe_fct <- filterPrecursorMzValues(sps_dia, mz = 300, ppm = 20, tolerance = 10)
values_fct <- filterValues(sps_dia, spectraVariables = "precursorMz",
Expand Down

0 comments on commit ed6cf70

Please sign in to comment.