comparison 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
comparison
equal deleted inserted replaced
4:b34c14151f25 5:fb9c0409d85c
5 5
6 ##################### 6 #####################
7 # CLASS DECLARATION # 7 # CLASS DECLARATION #
8 ##################### 8 #####################
9 9
10 MsDbInputDataFrameStream <- setRefClass("MsDbInputDataFrameStream", contains = 'MsDbInputStream', fields = list( .df = "ANY", .i = "integer")) 10 MsDbInputDataFrameStream <- setRefClass("MsDbInputDataFrameStream", contains = 'MsDbInputStream', fields = list( .df = "ANY", .i = "integer", .rtunit = 'character'))
11 11
12 ############### 12 ###############
13 # CONSTRUCTOR # 13 # CONSTRUCTOR #
14 ############### 14 ###############
15 15
16 MsDbInputDataFrameStream$methods( initialize = function(df = data.frame(), input.fields = msdb.get.dft.input.fields(), ...) { 16 MsDbInputDataFrameStream$methods( initialize = function(df = data.frame(), input.fields = msdb.get.dft.input.fields(), rtunit = MSDB.RTUNIT.SEC, ...) {
17
18 callSuper(input.fields = input.fields, ...)
17 19
18 .df <<- df 20 .df <<- df
19 .i <<- 0L 21 .i <<- 0L
20 22 .rtunit <<- rtunit
21 callSuper(input.fields = input.fields, ...)
22 }) 23 })
23 24
24 ########## 25 ##########
25 # GET MZ # 26 # GET MZ #
26 ########## 27 ##########
37 # GET RT # 38 # GET RT #
38 ########## 39 ##########
39 40
40 MsDbInputDataFrameStream$methods( getRt = function() { 41 MsDbInputDataFrameStream$methods( getRt = function() {
41 42
42 if (.self$.i > 0 && .self$.i <= nrow(.self$.df) && ! is.null(.self$.input.fields[[MSDB.TAG.RT]])) 43 rt <- NULL
43 return(.self$.df[.self$.i, .self$.input.fields[[MSDB.TAG.RT]]])
44 44
45 return(NULL) 45 if (.self$.i > 0 && .self$.i <= nrow(.self$.df) && ! is.null(.self$.input.fields[[MSDB.TAG.RT]])) {
46 rt <- .self$.df[.self$.i, .self$.input.fields[[MSDB.TAG.RT]]]
47 if (.self$.rtunit == MSDB.RTUNIT.MIN)
48 rt <- rt * 60
49 }
50
51 return(rt)
46 }) 52 })
47 53
48 ########### 54 ###########
49 # GET ALL # 55 # GET ALL #
50 ########### 56 ###########