Mercurial > repos > prog > lcmsmatching
comparison MsDbOutputDataFrameStream.R @ 5:fb9c0409d85c draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
| author | prog |
|---|---|
| date | Wed, 19 Apr 2017 10:00:05 -0400 |
| parents | 20d69a062da3 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:b34c14151f25 | 5:fb9c0409d85c |
|---|---|
| 6 | 6 |
| 7 ##################### | 7 ##################### |
| 8 # CLASS DECLARATION # | 8 # CLASS DECLARATION # |
| 9 ##################### | 9 ##################### |
| 10 | 10 |
| 11 MsDbOutputDataFrameStream <- setRefClass("MsDbOutputDataFrameStream", contains = 'MsDbOutputStream', fields = list( .df = "ANY")) | 11 MsDbOutputDataFrameStream <- setRefClass("MsDbOutputDataFrameStream", contains = 'MsDbOutputStream', fields = list( .df = "ANY", .output.fields = "ANY")) |
| 12 | 12 |
| 13 ############### | 13 ############### |
| 14 # CONSTRUCTOR # | 14 # CONSTRUCTOR # |
| 15 ############### | 15 ############### |
| 16 | 16 |
| 17 MsDbOutputDataFrameStream$methods( initialize = function(keep.unused = FALSE, one.line = FALSE, match.sep = MSDB.DFT.MATCH.SEP, output.fields = msdb.get.dft.output.fields(), multval.field.sep = MSDB.DFT.OUTPUT.MULTIVAL.FIELD.SEP, first.val = FALSE, ascii = FALSE, noapostrophe = FALSE, noplusminus = FALSE, nogreek = FALSE, ...) { | 17 MsDbOutputDataFrameStream$methods( initialize = function(keep.unused = FALSE, one.line = FALSE, match.sep = MSDB.DFT.MATCH.SEP, output.fields = NULL, multval.field.sep = MSDB.DFT.OUTPUT.MULTIVAL.FIELD.SEP, first.val = FALSE, ascii = FALSE, noapostrophe = FALSE, noplusminus = FALSE, nogreek = FALSE, ...) { |
| 18 | |
| 19 callSuper(keep.unused = keep.unused, one.line = one.line, match.sep = match.sep, multval.field.sep = multval.field.sep, first.val = first.val, ascii = ascii, noapostrophe = noapostrophe, noplusminus = noplusminus, nogreek = nogreek, ...) | |
| 18 | 20 |
| 19 .df <<- data.frame() | 21 .df <<- data.frame() |
| 20 | 22 .output.fields <<- output.fields |
| 21 callSuper(keep.unused = keep.unused, one.line = one.line, match.sep = match.sep, output.fields = output.fields, multval.field.sep = multval.field.sep, first.val = first.val, ascii = ascii, noapostrophe = noapostrophe, noplusminus = noplusminus, nogreek = nogreek, ...) | |
| 22 }) | 23 }) |
| 23 | 24 |
| 24 ################## | 25 ################## |
| 25 # GET DATA FRAME # | 26 # GET DATA FRAME # |
| 26 ################## | 27 ################## |
| 55 x <- data.frame(mz = mz) | 56 x <- data.frame(mz = mz) |
| 56 colnames(x) <- MSDB.TAG.MZ | 57 colnames(x) <- MSDB.TAG.MZ |
| 57 if ( ! is.null(rt)) { | 58 if ( ! is.null(rt)) { |
| 58 x.rt <- data.frame(rt = rt) | 59 x.rt <- data.frame(rt = rt) |
| 59 colnames(x.rt) <- MSDB.TAG.RT | 60 colnames(x.rt) <- MSDB.TAG.RT |
| 61 if (.self$.rtunit == MSDB.RTUNIT.MIN) | |
| 62 x.rt[[MSDB.TAG.RT]] <- x.rt[[MSDB.TAG.RT]] / 60 | |
| 60 x <- cbind(x, x.rt) | 63 x <- cbind(x, x.rt) |
| 61 } | 64 } |
| 65 | |
| 62 | 66 |
| 63 # Merge input values with matched peaks | 67 # Merge input values with matched peaks |
| 64 if ( ! is.null(peaks)) { | 68 if ( ! is.null(peaks)) { |
| 65 | 69 |
| 66 # No rows | 70 # No rows |
| 67 if (nrow(peaks) == 0) | 71 if (nrow(peaks) == 0) { |
| 68 # Add NA values | 72 # Add NA values |
| 69 peaks[1, ] <- NA | 73 peaks[1, ] <- NA |
| 70 | 74 |
| 71 # Process existing rows | 75 # Process existing rows |
| 72 else { | 76 } else { |
| 77 | |
| 78 # Convert RT | |
| 79 if (.self$.rtunit == MSDB.RTUNIT.MIN) | |
| 80 if (MSDB.TAG.COLRT %in% colnames(peaks)) | |
| 81 peaks[[MSDB.TAG.COLRT]] <- peaks[[MSDB.TAG.COLRT]] / 60 | |
| 82 | |
| 73 # Process multi-value fields | 83 # Process multi-value fields |
| 74 for (c in colnames(peaks)) | 84 for (c in colnames(peaks)) |
| 75 if (c %in% MSDB.MULTIVAL.FIELDS) { | 85 if (c %in% MSDB.MULTIVAL.FIELDS) { |
| 76 | 86 |
| 77 # Keep only first value in multi-value fields | 87 # Keep only first value in multi-value fields |
