MzBackendMzR misleading error with empty file list and misleading behavior with `files` argument
Closed this issue · 3 comments
When constructing MzBackendMzR
with an empty file list, the returned error message is misleading:
fls <- c()
sp <- Spectra(fls, source = MsBackendMzR())
# Error in .local(object, ...) :
# Parameter 'files' is mandatory for 'MsBackendMzR'
This lets me think that I should be using Spectra(files = fls, ...)
instead, which in fact does not error:
sp <- Spectra(files = fls, source = MsBackendMzR())
# no error
sp
# MSn data (Spectra) with 0 spectra in a MsBackendMemory backend:
However files
is not the right argument, in fact sp <- Spectra(files = fls, source = MsBackendMzR())
completely ignores fls
:
fls <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)
sp <- Spectra(files = fls, source = MsBackendMzR())
sp
# MSn data (Spectra) with 0 spectra in a MsBackendMemory backend:
Passing fls
as anonymous parameter works as expected:
sp <- Spectra(fls, source = MsBackendMzR())
sp
# MSn data (Spectra) with 1862 spectra in a MsBackendMzR backend:
Expected behaviour:
fls <- c(); sp <- Spectra(fls, source = MsBackendMzR())
should
- either return a valid
Spectra
object with 0 spectra and potentially warn that the file list was empty - or error because the file list was empty.
Note that no-input MsBackendMzR
(and also MsBackendMgf
) objects seem to be invalid anyway. I don't know if this is intended, so this would influence what behaviour we expect from a no-file MzBackendMzR
.
sp <- Spectra(source = MsBackendMzR())
sp2 <- setBackend(sp, MsBackendMemory())
# Error in validObject(object) :
# invalid class “MsBackendMemory” object: The following columns have a wrong data type: mz, intensity.
# The expected data type(s) is/are: NumericList, NumericList
(Discovered accidentally because I did not have package "msdata" installed when building the Spectra.Rmd
vignette.)
Good point Michele. Will fix.
this should be fixed with the PR above.