Closed jorainer closed 1 year ago
Unless we have observed/recorded this to be an issue in real life, I don't think it is worth the negative impact on performance.
Don't we check this when the object is constructed? If not, that's where this could be done, only once.
Agree.
This is based on discussion (and misunderstandings) in PR #259 and related issue #258 : many functions in
Spectra
assume the m/z values to be sorted (within each spectrum). Currently there is only a validator method forMsBackendDataFrame
checking that (https://github.com/rformassspectrometry/Spectra/blob/master/R/MsBackendDataFrame-functions.R#L55:L63).I'm wondering if it would not be better to enforce m/z sorting by adding a respective validator method directly to
MsBackend
?Maybe adding a new method
validOrderedMz
toMsBackend
which checks if m/z values are ordered and that is called within thevalidObject
forMsBackend
? That would allow certain backends to implement their own validator function (e.g. using SQL calls and thus avoiding to load all data into memory)?A concern is however that this might have a quite negative impact on performance (if it's called for each
validObject
) since it involves loading of all m/z values...any thoughts @lgatto @sgibb ?