tests/testthat/test_validateMatchedSpectra.R

csp <- CompareSpectraParam(requirePrecursor = TRUE,
                           THRESHFUN = function(x) x >= 0.7)
norm_int <- function(x) {
    x[, "intensity"] <- x[, "intensity"] / max(x[, "intensity"]) * 100
    x
}
ms <- matchSpectra(addProcessing(pest_ms2, norm_int),
                   addProcessing(minimb, norm_int), csp)
ms2 <- ms[whichQuery(ms)]

test_that(".createChoices works", {
    res <- .createChoices(ms)
    expect_true(is.list(res))
    expect_equal(unname(res), as.list(seq_along(ms)))
})

test_that(".create_dt works", {
    res <- .create_dt(ms)
    expect_true(is.data.frame(res))
    expect_true(all(c("precursorMz", "target_precursorMz", "rtime", "score")
                    %in% colnames(res)))
})
rformassspectrometry/MetaboAnnotation documentation built on Oct. 20, 2024, 7:25 p.m.