Skip to content

Commit

Permalink
lastfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed May 24, 2024
1 parent fb9fadd commit 350aa22
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ importMethodsFrom("Spectra", "precursorMz")
importMethodsFrom("Spectra", "$")
importMethodsFrom("Spectra", "uniqueMsLevels")
importMethodsFrom("Spectra", "backendBpparam")
importFrom("Spectra", "MsBackendMemory", "dataStorageBasePath")
importFrom("Spectra", "MsBackendMemory", "dataStorageBasePath",
"dataStorageBasePath<-")

## MsExperiment things
importClassesFrom("MsExperiment", "MsExperiment")
Expand Down
6 changes: 2 additions & 4 deletions R/PlainTextParam.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ setMethod("storeResults",
setMethod("loadResults",
signature(object = "MsExperiment",
param = "PlainTextParam"),
function(object, param, spectraFilePath){
function(object, param, spectraFilePath = character()){
res <- .load_msexperiment(path = param@path,
spectraFilePath = spectraFilePath)
validObject(res)
Expand All @@ -183,8 +183,7 @@ setMethod("loadResults",
param = "PlainTextParam"),
function(object, param, spectraFilePath){
res <- callNextMethod()
res <- .load_xcmsexperiment(res, path = param@path,
spectraFilePath = spectraFilePath) # not sure if the spectraFilePath is necessary here
res <- .load_xcmsexperiment(res, path = param@path)
validObject(res)
res
}
Expand All @@ -207,7 +206,6 @@ setMethod("loadResults",
else stop("No \"sample_data.txt\" file found in ", path)
fl <- file.path(path, "spectra_files.txt")
if (file.exists(fl)){
spec <- spectra(fl)
sf <- .import_spectra_files(fl, spectraFilePath = spectraFilePath)
res <- readMsExperiment(spectraFiles = sf, sampleData = sd)
fl <- file.path(path, "spectra_processing_queue.json")
Expand Down
10 changes: 7 additions & 3 deletions R/RDataParam.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ setMethod("storeResults",
setMethod("loadResults",
signature(object = "XcmsExperiment",
param = "RDataParam"),
function(object, param, spectraFilePath){
res <- load(file = param@fileName)
function(object, param, spectraFilePath = character()){
env <- new.env()
load(file = param@fileName, envir = env)
res <- get(ls(env)[1], envir = env)
if (!length(spectraFilePath) == 0 &&
inherits(s@backend, "MsBackendMzR"))
inherits(spectra(res)@backend, "MsBackendMzR")) {
dataStorageBasePath(spectra(res)) <- spectraFilePath
}

res
}
)
Expand Down
2 changes: 1 addition & 1 deletion man/PlainTextParam.Rd

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

2 changes: 1 addition & 1 deletion man/RDataParam.Rd

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

3 changes: 1 addition & 2 deletions tests/testthat/test_PlainTextParam.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ test_that("storeResults,PlainTextParam,XcmsExperiment works", {
expect_true(file.exists(file.path(param@path, "feature_definitions.txt")))
expect_true(file.exists(file.path(param@path, "feature_peak_index.txt")))
pth = file.path(tempdir(), "test2")
param <- PlainTextParam(path = pth, spectraExport = FALSE)
param <- PlainTextParam(path = pth)
storeResults(xmse_full, param = param)
expect_false(file.exists(file.path(param@path, "spectra_files.txt")))
})

test_that("loadResults, PlainTextParam works", {
Expand Down

0 comments on commit 350aa22

Please sign in to comment.