diff MsDbInputDataFrameStream.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/MsDbInputDataFrameStream.R	Tue Mar 14 12:40:22 2017 -0400
+++ b/MsDbInputDataFrameStream.R	Wed Apr 19 10:00:05 2017 -0400
@@ -7,18 +7,19 @@
 	# CLASS DECLARATION #
 	#####################
 	
-	MsDbInputDataFrameStream <- setRefClass("MsDbInputDataFrameStream", contains = 'MsDbInputStream', fields = list( .df = "ANY", .i = "integer"))
+	MsDbInputDataFrameStream <- setRefClass("MsDbInputDataFrameStream", contains = 'MsDbInputStream', fields = list( .df = "ANY", .i = "integer", .rtunit = 'character'))
 	
 	###############
 	# CONSTRUCTOR #
 	###############
 	
-	MsDbInputDataFrameStream$methods( initialize = function(df = data.frame(), input.fields = msdb.get.dft.input.fields(), ...) {
+	MsDbInputDataFrameStream$methods( initialize = function(df = data.frame(), input.fields = msdb.get.dft.input.fields(), rtunit = MSDB.RTUNIT.SEC, ...) {
+		
+		callSuper(input.fields = input.fields, ...)
 
 		.df <<- df
 		.i <<- 0L
-		
-		callSuper(input.fields = input.fields, ...)
+		.rtunit <<- rtunit
 	})
 
 	##########
@@ -39,10 +40,15 @@
 
 	MsDbInputDataFrameStream$methods( getRt = function() {
 
-		if (.self$.i > 0 && .self$.i <= nrow(.self$.df) && ! is.null(.self$.input.fields[[MSDB.TAG.RT]]))
-			return(.self$.df[.self$.i, .self$.input.fields[[MSDB.TAG.RT]]])
+		rt <- NULL
 
-		return(NULL)
+		if (.self$.i > 0 && .self$.i <= nrow(.self$.df) && ! is.null(.self$.input.fields[[MSDB.TAG.RT]])) {
+			rt <- .self$.df[.self$.i, .self$.input.fields[[MSDB.TAG.RT]]]
+			if (.self$.rtunit == MSDB.RTUNIT.MIN)
+				rt <- rt * 60
+		}
+
+		return(rt)
 	})
 
 	###########