Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
jorainer committed Feb 19, 2025
1 parent c1b3016 commit fdc7973
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 55 deletions.
20 changes: 0 additions & 20 deletions R/MsBackendCached.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 1 addition & 15 deletions R/MsBackendDataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 1 addition & 7 deletions R/MsBackendMemory-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
14 changes: 1 addition & 13 deletions R/MsBackendMzR-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand All @@ -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]
}

Expand Down

0 comments on commit fdc7973

Please sign in to comment.