Skip to content

Commit

Permalink
start readMSP testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sneumann committed Mar 5, 2024
1 parent 4101c74 commit 595c0c3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Binary file added inst/extdata/testdata/readMSPreturnObj.Rdata
Binary file not shown.
67 changes: 67 additions & 0 deletions tests/testthat/test_fileinput.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,70 @@ test_that("MS-Dial 4.X", {
# expect_equal(ncol(data$dataFrame), 41)
})

test_that("MSP reading works", {

if(FALSE) {
fileSpectra <- system.file("extdata/showcase/Metabolite_profile_showcase.msp", package = "MetFamily")
#load(system.file("extdata/testdata/readMSPreturnObj.Rdata", package = "MetFamily"))

returnObj <- parseMSP(fileSpectra = fileSpectra,
minimumIntensityOfMaximalMS2peak = 2000,
minimumProportionOfMS2peaks = 0.05,
neutralLossesPrecursorToFragments = TRUE,
neutralLossesFragmentsToFragments = FALSE,
progress = FALSE)


expect_equal(returnObj$numberOfSpectra, 2640)
expect_equal(returnObj$numberOfSpectraOriginal, 5824)
expect_equal(returnObj$numberOfMS2PeaksOriginal, 145973)
expect_equal(returnObj$numberOfMS2PeaksWithNeutralLosses, 68738)
expect_equal(returnObj$numberOfMS2PeaksAboveThreshold, 34369)
expect_equal(returnObj$numberOfMS2PeaksBelowThreshold, 109797)
expect_equal(returnObj$numberOfTooHeavyFragments, 1807)
expect_equal(returnObj$numberOfSpectraDiscardedDueToNoPeaks, 15)
expect_equal(returnObj$numberOfSpectraDiscardedDueToMaxIntensity, 3163)
expect_equal(returnObj$numberOfSpectraDiscardedDueToTooHeavy, 5)
expect_equal(length(returnObj$precursorMz), 2640)
expect_equal(returnObj$precursorMz[1], 85)
expect_equal(length(returnObj$precursorRt), 2640)
expect_equal(returnObj$precursorRt[1], 10.98)

}

# > str(returnObj, max.level = 1)
# List of 14
# $ fileSpectra : chr "/tmp/RtmpL82I4E/ff16bb92ac5e87cb202eec2e/0.msp"
# $ spectraList :List of 2640
# $ numberOfSpectra : int 2640
# $ numberOfSpectraOriginal : int 5824
# $ numberOfMS2PeaksOriginal : num 145973
# $ numberOfMS2PeaksWithNeutralLosses : num 68738
# $ numberOfMS2PeaksAboveThreshold : num 34369
# $ numberOfMS2PeaksBelowThreshold : num 109797
# $ numberOfTooHeavyFragments : num 1807
# $ numberOfSpectraDiscardedDueToNoPeaks : num 15
# $ numberOfSpectraDiscardedDueToMaxIntensity: num 3163
# $ numberOfSpectraDiscardedDueToTooHeavy : num 5
# $ precursorMz : num [1:2640] 85 85 85 85 85 ...
# $ precursorRt : num [1:2640] 10.98 7.42 12.4 16.26 13 ...
#



##
## returnObj contains the following elements:
##

# returnObj <- list()
# returnObj$fileSpectra <- fileSpectra
# returnObj$spectraList <- list()
# returnObj$numberOfSpectra <- 0
# returnObj$numberOfMS2PeaksOriginal <- 0
# returnObj$numberOfMS2PeaksWithNeutralLosses <- 0
# returnObj$numberOfMS2PeaksAboveThreshold <- 0
# returnObj$numberOfMS2PeaksBelowThreshold <- 0
# returnObj$precursorMz <- vector(mode = "numeric")
# returnObj$precursorRt <- vector(mode = "numeric")

})

0 comments on commit 595c0c3

Please sign in to comment.