diff --git a/R/MsBackendCached.R b/R/MsBackendCached.R index bb343b4b..880338c1 100644 --- a/R/MsBackendCached.R +++ b/R/MsBackendCached.R @@ -328,26 +328,6 @@ setMethod("spectraVariables", "MsBackendCached", function(object) { res <- x@localData[, local_cols, drop = FALSE] if (length(core_cols)) { res <- fillCoreSpectraVariables(res, columns = core_cols) - ## mzvals <- NULL - ## intvals <- NULL - ## lst <- NumericList(numeric(), compress = FALSE) - ## if (any(core_cols == "mz")) { - ## core_cols <- core_cols[core_cols != "mz"] - ## mzvals <- lst[rep(1, times = length(x))] - ## } - ## if (any(core_cols == "intensity")) { - ## core_cols <- core_cols[core_cols != "intensity"] - ## intvals <- lst[rep(1, times = length(x))] - ## } - ## if (length(core_cols)) - ## tmp <- DataFrame(lapply(.SPECTRA_DATA_COLUMNS[core_cols], - ## function(z, n) rep(as(NA, z), n), length(x))) - ## else tmp <- make_zero_col_DFrame(x@nspectra) - ## tmp$mz <- mzvals - ## tmp$intensity <- intvals - ## if (length(res)) - ## res <- cbind(res, tmp) - ## else res <- tmp if (any(core_cols == "dataStorage")) res$dataStorage <- dataStorage(x) } diff --git a/R/MsBackendDataFrame.R b/R/MsBackendDataFrame.R index 7cff9daf..53d44d5a 100644 --- a/R/MsBackendDataFrame.R +++ b/R/MsBackendDataFrame.R @@ -467,22 +467,8 @@ setMethod("spectraData", "MsBackendDataFrame", df_columns <- intersect(columns,colnames(object@spectraData)) res <- object@spectraData[, df_columns, drop = FALSE] other_columns <- setdiff(columns,colnames(object@spectraData)) - if (length(other_columns)) { + if (length(other_columns)) res <- fillCoreSpectraVariables(res, columns = other_columns) - ## other_res <- lapply(other_columns, .get_column, - ## x = object@spectraData) - ## names(other_res) <- other_columns - ## is_mz_int <- names(other_res) %in% c("mz", "intensity") - ## if (!all(is_mz_int)) - ## res <- cbind(res, as(other_res[!is_mz_int], "DataFrame")) - ## if (any(names(other_res) == "mz")) - ## res$mz <- if (length(other_res$mz)) other_res$mz - ## else NumericList(compress = FALSE) - ## if (any(names(other_res) == "intensity")) - ## res$intensity <- if (length(other_res$intensity)) - ## other_res$intensity - ## else NumericList(compress = FALSE) - } if (!all(columns %in% colnames(res))) stop("Column(s) ", paste0(columns[!columns %in% names(res)], collapse = ", "), " not available.", diff --git a/R/MsBackendMemory-functions.R b/R/MsBackendMemory-functions.R index 7872d628..adaf7fc9 100644 --- a/R/MsBackendMemory-functions.R +++ b/R/MsBackendMemory-functions.R @@ -49,15 +49,9 @@ MsBackendMemory <- function() { sp_vars <- setdiff(columns, p_vars) df_columns <- intersect(sp_vars, colnames(object@spectraData)) res <- object@spectraData[, df_columns, drop = FALSE] - ## Get missing core variables. other_columns <- setdiff(sp_vars, colnames(object@spectraData)) - if (length(other_columns)) { + if (length(other_columns)) res <- fillCoreSpectraVariables(res, other_columns) - ## other_res <- lapply(other_columns, .get_column, - ## x = object@spectraData) - ## names(other_res) <- other_columns - ## res <- cbind(res, as.data.frame(other_res)) - } if (any(columns == "mz")) res$mz <- mz(object) if (any(columns == "intensity")) diff --git a/R/MsBackendMzR-functions.R b/R/MsBackendMzR-functions.R index 012c1c15..86900584 100644 --- a/R/MsBackendMzR-functions.R +++ b/R/MsBackendMzR-functions.R @@ -103,14 +103,6 @@ MsBackendMzR <- function() { sp_cols <- columns[columns %in% cn] res <- x@spectraData[, sp_cols, drop = FALSE] if(!nrow(x@spectraData)) { - ## res$mz <- NumericList(compress = FALSE) - ## res$intensity <- NumericList(compress = FALSE) - ## other_cols <- setdiff(columns, c(sp_cols, "mz", "intensity")) - ## if (length(other_cols)) { - ## res_add <- lapply(.SPECTRA_DATA_COLUMNS[other_cols], - ## do.call, args = list()) - ## res <- cbind(res, res_add) - ## } res <- fillCoreSpectraVariables(res, setdiff(columns, c(sp_cols))) return(res[, columns, drop = FALSE]) } @@ -125,12 +117,8 @@ MsBackendMzR <- function() { compress = FALSE) } other_cols <- setdiff(columns, c(sp_cols, "mz", "intensity")) - if (length(other_cols)) { + if (length(other_cols)) res <- fillCoreSpectraVariables(res, other_cols) - ## other_res <- lapply(other_cols, .get_column, x = x@spectraData) - ## names(other_res) <- other_cols - ## res <- cbind(res, as(other_res, "DataFrame")) - } res[, columns, drop = FALSE] }