Mercurial > repos > prog > lcmsmatching
diff MsDbOutputDataFrameStream.R @ 2:20d69a062da3 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author | prog |
---|---|
date | Thu, 02 Mar 2017 08:55:00 -0500 |
parents | 253d531a0193 |
children | fb9c0409d85c |
line wrap: on
line diff
--- a/MsDbOutputDataFrameStream.R Sat Sep 03 17:02:01 2016 -0400 +++ b/MsDbOutputDataFrameStream.R Thu Mar 02 08:55:00 2017 -0500 @@ -25,7 +25,7 @@ # GET DATA FRAME # ################## - MsDbOutputDataFrameStream$methods( getDataFrame = function(...) { + MsDbOutputDataFrameStream$methods( getDataFrame = function() { # Put at least a column name if empty if (nrow(.self$.df) == 0) @@ -34,6 +34,15 @@ return(.self$.df) }) + # Move columns to beginning {{{1 + + MsDbOutputDataFrameStream$methods( moveColumnsToBeginning = function(cols) { + all.cols <- colnames(.self$.df) + other.cols <- all.cols[ ! all.cols %in% cols] + cols <- cols[cols %in% all.cols] + .df <<- .self$.df[c(cols, other.cols)] + }) + ################# # MATCHED PEAKS # ################# @@ -44,8 +53,12 @@ # Set input values x <- data.frame(mz = mz) - if ( ! is.null(rt)) - x <- cbind(x, data.frame(rt = rt)) + colnames(x) <- MSDB.TAG.MZ + if ( ! is.null(rt)) { + x.rt <- data.frame(rt = rt) + colnames(x.rt) <- MSDB.TAG.RT + x <- cbind(x, x.rt) + } # Merge input values with matched peaks if ( ! is.null(peaks)) { @@ -74,8 +87,12 @@ # Concatenate results in one line if (.self$.one.line) { # For each column, concatenate all values in one string. - for (c in seq(peaks)) - peaks[1, c] <- paste0(peaks[[c]], collapse = .self$.match.sep, FUN.VALUE = '') + for (c in seq(peaks)) { + v <- peaks[[c]] + v <- v[ ! is.na(v)] # remove NA values + v <- v[ ! duplicated(v)] # remove duplicates + peaks[1, c] <- paste0(v, collapse = .self$.match.sep, FUN.VALUE = '') + } peaks <- peaks[1, ] # Keep only first line } }