diff 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
line wrap: on
line diff
--- a/MsDbOutputDataFrameStream.R	Tue Mar 14 12:40:22 2017 -0400
+++ b/MsDbOutputDataFrameStream.R	Wed Apr 19 10:00:05 2017 -0400
@@ -8,17 +8,18 @@
 	# CLASS DECLARATION #
 	#####################
 	
-	MsDbOutputDataFrameStream <- setRefClass("MsDbOutputDataFrameStream", contains = 'MsDbOutputStream', fields = list( .df = "ANY"))
+	MsDbOutputDataFrameStream <- setRefClass("MsDbOutputDataFrameStream", contains = 'MsDbOutputStream', fields = list( .df = "ANY", .output.fields = "ANY"))
 	
 	###############
 	# CONSTRUCTOR #
 	###############
 	
-	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, ...) {
+	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, ...) {
+		
+		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, ...)
 
 		.df <<- data.frame()
-		
-		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, ...)
+		.output.fields <<- output.fields
 	})
 
 	##################
@@ -57,19 +58,28 @@
 		if ( ! is.null(rt)) {
 			x.rt <- data.frame(rt = rt)
 			colnames(x.rt) <- MSDB.TAG.RT
+			if (.self$.rtunit == MSDB.RTUNIT.MIN)
+				x.rt[[MSDB.TAG.RT]] <- x.rt[[MSDB.TAG.RT]] / 60
 			x <- cbind(x, x.rt)
 		}
 
+
 		# Merge input values with matched peaks
 		if ( ! is.null(peaks)) {
 
 			# No rows
-			if (nrow(peaks) == 0)
+			if (nrow(peaks) == 0) {
 				# Add NA values
 				peaks[1, ] <- NA
 
 			# Process existing rows
-			else {
+			} else {
+
+				# Convert RT
+				if (.self$.rtunit == MSDB.RTUNIT.MIN)
+					if (MSDB.TAG.COLRT %in% colnames(peaks))
+						peaks[[MSDB.TAG.COLRT]] <- peaks[[MSDB.TAG.COLRT]] / 60
+
 				# Process multi-value fields
 				for (c in colnames(peaks))
 					if (c %in% MSDB.MULTIVAL.FIELDS) {