context("test: get_peak_data")
test_that("Testing get peak data 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_peak_data input checks---------------------------------------------
# Scan Metadata must be of the scan_metadata class
expect_error(
get_peak_data(data.frame(test = 1)),
"ScanMetadata must be a scan_metadata object generated by get_scan_metadata."
)
# Scan Number must be an integer
expect_error(
get_peak_data(BU_ScanMetadata, "2"),
"Scan Number must be an integer."
)
# Scan Number must be in the range of options
expect_error(
get_peak_data(BU_ScanMetadata, 2),
"Scan Number must be within the range of 29126 & 34291"
)
# Min Abundance must be a numeric
expect_error(
get_peak_data(BU_ScanMetadata, 30000, "2"),
"MinAbundance needs to be a numeric value."
)
# Min Abundance should be in the range of 1-100
expect_error(
get_peak_data(BU_ScanMetadata, 30000, -2),
"MinAbundance needs to range between 0 and 100."
)
expect_error(
get_peak_data(BU_ScanMetadata, 30000, 101),
"MinAbundance needs to range between 0 and 100."
)
# Create a peak_data object---------------------------------------------------
# Get peak data for an XML file
BU_Peak <- get_peak_data(BU_ScanMetadata, 30000, 10)
expect_true(inherits(BU_Peak, "peak_data"))
# Get peak data for a raw file
RAW_Peak <- get_peak_data(RAW_ScanMetadata, 3, 0)
expect_true(inherits(RAW_Peak, "peak_data"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.