Open MaliRemorker opened 5 years ago
My suggestion would be to add a test right at the top of the function and then either exit and ask people to load the settings first [then also need to update documentation] or invoke RmbDefaultSettings() and continue with a warning. The problem with the latter is that people should ideally be doing the pre-screening using the settings they will then use for the RMassBank workflow. Alternative: settings file is an input. Thoughts?
Absolutely the former. We must not assume default settings are the right settings.
@meowcat do you know offhand how to test whether settings are loaded in RMB? Can't find it in the documentation
yes, though that function is of course not exported, so either :::
or directly is.null(getOption("RMassBank"))
.
Without looking at your specific code, I suggest this pattern we use in RMassBank:
findMsMsHR.direct <- function(msRaw, cpdID, mode = "pH", confirmMode = 0, useRtLimit = TRUE,
ppmFine = getOption("RMassBank")$findMsMsRawSettings$ppmFine,
mzCoarse = getOption("RMassBank")$findMsMsRawSettings$mzCoarse,
fillPrecursorScan = getOption("RMassBank")$findMsMsRawSettings$fillPrecursorScan,
rtMargin = getOption("RMassBank")$rtMargin,
deprofile = getOption("RMassBank")$deprofile,
headerCache = NULL) { do.stuff() }
In this way, it is never opaque that there are parameters being accessed in a specific function call. Doesn't need to be as granular as this, settings = getOption("RMassBank")
would be simpler.
Right now, the thrown error sounds misleading: