Skip to content

Commit

Permalink
- remove not used allowNoMatch argument in getMzShift()
Browse files Browse the repository at this point in the history
- more tests for getMzShift()
  • Loading branch information
thomas-enzlein committed Sep 4, 2024
1 parent 40dcdce commit 81a6a11
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 0 additions & 3 deletions R/getMzShift.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ getMzShift <- function(peaks,
mzShift <- na.omit(mzShift)

if (!all(allIdx %in% specIdx)) {
if (!allowNoMatch) {
stop("Could not find ", targetMz, " for all spectra! Consider adjusting tol.\n")
}
warning("Could not find ", targetMz, " in spectrum ", paste(which(!(allIdx %in% specIdx)), collapse = ", "), ".\n")
specIdx <- sort(which(allIdx %in% specIdx))
} else {
Expand Down
4 changes: 2 additions & 2 deletions man/isMALDIassay.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion tests/testthat/test-getMzShift.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ test_that("getMzShift stops if a single condition gets filtered completly", {
MALDIquant::mass(dummyPeaks[[1]]) <- c(1:4, 6, 7:11)
names(dummyPeaks) <- 1:3

expect_error(suppressWarnings(getMzShift(dummyPeaks, targetMz = 5.1, tol = 0.15, verbose = TRUE)))
expect_error(suppressWarnings(getMzShift(dummyPeaks,
targetMz = 5.1,
tol = 0.15,
verbose = TRUE)))
})

test_that("getMzShift stops if targetMz can't be found in any spectrum", {
dummyPeaks <- peakListConstructor()
names(dummyPeaks) <- 1:3

expect_error(suppressWarnings(getMzShift(dummyPeaks,
targetMz = 12,
tol = 0.15,
verbose = TRUE)))
})

test_that("getMzShift finds mass shift correctly", {
Expand Down

0 comments on commit 81a6a11

Please sign in to comment.