context("test: get_xic")
test_that("Testing get xic function", {
# Download required test files------------------------------------------------
source(system.file("tests/testthat/file_check.R", package = "pspecterlib"))
downfolder <- file_check("downfolder")
BU_ScanMetadata <- file_check("BU")
RAW_ScanMetadata <- file_check("RAW")
# Test get_xic input checks---------------------------------------------------
# The ScanMetadata object must be of the correct class
expect_error(
get_xic(data.frame("Test" = 1)),
"ScanMetadata must be a scan_metadata object generated by get_scan_metadata."
)
# MZ should be a number
expect_error(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = "659"
),
"MZ must be a number."
)
# RT should be a range
expect_error(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = 659.8596,
RTRange = c(60, 58)
),
"RT range must be written as a vector with two numerics, a min and max."
)
# Isotope number should include values between 0 and 5
expect_error(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = 659.8596,
RTRange = c(58, 60),
IsotopeNumber = c(1:6)
),
"The range of isotope values must be a vector of integers with values between 0 and 5."
)
# Charge should include values between 1 and 3
expect_error(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = 659.8596,
RTRange = c(58, 60),
Charges = 0:1
),
"The range of charge values must be a vector of integers between 1 and 3."
)
# Messages should be TRUE or FALSE
expect_error(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = 659.8596,
RTRange = c(58, 60),
Messages = "FALSE"
),
"Messages must be TRUE or FALSE."
)
# Create an xic_pspecter object-----------------------------------------------
# Generate an XIC with an XML file
BU_XIC <- suppressWarnings({suppressMessages(
get_xic(
ScanMetadata = BU_ScanMetadata,
MZ = 659.8596,
RTRange = c(58, 60),
IsotopeNumber = 0,
Charges = 1
)
)})
expect_true(inherits(BU_XIC, "xic_pspecter"))
# Generate an XIC with a RAW file
RAW_XIC <- suppressMessages({
get_xic(
ScanMetadata = RAW_ScanMetadata,
MZ = 1500,
RTRange = c(0, 1),
IsotopeNumber = 0,
Charges = 1:3,
Messages = NA
)
})
expect_true(inherits(RAW_XIC, "xic_pspecter"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.