comparison MsDb.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
7 7
8 ##################### 8 #####################
9 # CLASS DECLARATION # 9 # CLASS DECLARATION #
10 ##################### 10 #####################
11 11
12 MsDb <- setRefClass("MsDb", fields = list(.observers = "ANY", .prec = "list", .output.streams = "ANY", .input.stream = "ANY", .mz.tol.unit = "character")) 12 MsDb <- setRefClass("MsDb", fields = list(.observers = "ANY", .prec = "list", .output.streams = "ANY", .input.stream = "ANY", .mz.tol.unit = "character", .rt.unit = "character"))
13 13
14 ############### 14 ###############
15 # CONSTRUCTOR # 15 # CONSTRUCTOR #
16 ############### 16 ###############
17 17
18 MsDb$methods( initialize = function(...) { 18 MsDb$methods( initialize = function(...) {
19
20 callSuper(...)
19 21
20 .observers <<- NULL 22 .observers <<- NULL
21 .output.streams <<- NULL 23 .output.streams <<- NULL
22 .input.stream <<- NULL 24 .input.stream <<- NULL
23 .prec <<- MSDB.DFT.PREC 25 .prec <<- MSDB.DFT.PREC
24 .mz.tol.unit <<- MSDB.DFT.MZTOLUNIT 26 .mz.tol.unit <<- MSDB.DFT.MZTOLUNIT
25 27 .rt.unit <<- MSDB.RTUNIT.SEC
26 callSuper(...)
27 }) 28 })
28 29
29 #################### 30 ####################
30 # SET INPUT STREAM # 31 # SET INPUT STREAM #
31 #################### 32 ####################
124 125
125 MsDb$methods( setDbMsModes = function(modes) { 126 MsDb$methods( setDbMsModes = function(modes) {
126 stop("Method setDbMsModes() not implemented in concrete class.") 127 stop("Method setDbMsModes() not implemented in concrete class.")
127 }) 128 })
128 129
130 ###################
131 # SET MZ TOL UNIT #
132 ###################
133
129 MsDb$methods( setMzTolUnit = function(mztolunit) { 134 MsDb$methods( setMzTolUnit = function(mztolunit) {
130 135
131 if ( ! mztolunit %in% MSDB.MZTOLUNIT.VALS) 136 if ( ! mztolunit %in% MSDB.MZTOLUNIT.VALS)
132 stop(paste0("M/Z tolerance unit must be one of: ", paste(MSDB.MZTOLUNIT.VALS, collapse = ', '), ".")) 137 stop(paste0("M/Z tolerance unit must be one of: ", paste(MSDB.MZTOLUNIT.VALS, collapse = ', '), "."))
133 138
134 .mz.tol.unit <<- mztolunit 139 .mz.tol.unit <<- mztolunit
140 })
141
142 ###############
143 # SET RT UNIT #
144 ###############
145
146 MsDb$methods( setRtUnit = function(unit) {
147
148 if ( ! unit %in% MSDB.RTUNIT.VALS)
149 stop(paste0("RT unit must be one of: ", paste(MSDB.RTUNIT.VALS, collapse = ', '), "."))
150
151 .rt.unit <<- unit
152 })
153
154 ###############
155 # GET RT UNIT #
156 ###############
157
158 MsDb$methods( getRtUnit = function(unit) {
159 return(.self$.rt.unit)
135 }) 160 })
136 161
137 #################### 162 ####################
138 # HANDLE COMPOUNDS # 163 # HANDLE COMPOUNDS #
139 #################### 164 ####################
292 # 317 #
293 # # Put back unfound peaks 318 # # Put back unfound peaks
294 # peaks <- rbind(peaks, peaks.na) 319 # peaks <- rbind(peaks, peaks.na)
295 # 320 #
296 # # Sort 321 # # Sort
297 # print(colnames(peaks))
298 # print(x.colnames)
299 # peaks <- peaks[order(peaks[[x.colnames$mz]], peaks[[x.colnames$rt]], peaks[[MSDB.TAG.MOLID]], peaks[[MSDB.TAG.COL]]), ] 322 # peaks <- peaks[order(peaks[[x.colnames$mz]], peaks[[x.colnames$rt]], peaks[[MSDB.TAG.MOLID]], peaks[[MSDB.TAG.COL]]), ]
300 # 323 #
301 # # Remove rownames 324 # # Remove rownames
302 # rownames(peaks) <- NULL 325 # rownames(peaks) <- NULL
303 # 326 #