diff 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
line wrap: on
line diff
--- a/MsDb.R	Tue Mar 14 12:40:22 2017 -0400
+++ b/MsDb.R	Wed Apr 19 10:00:05 2017 -0400
@@ -9,21 +9,22 @@
 	# CLASS DECLARATION #
 	#####################
 	
-	MsDb <- setRefClass("MsDb", fields = list(.observers = "ANY", .prec = "list", .output.streams = "ANY", .input.stream = "ANY", .mz.tol.unit = "character"))
+	MsDb <- setRefClass("MsDb", fields = list(.observers = "ANY", .prec = "list", .output.streams = "ANY", .input.stream = "ANY", .mz.tol.unit = "character", .rt.unit = "character"))
 	
 	###############
 	# CONSTRUCTOR #
 	###############
 	
 	MsDb$methods( initialize = function(...) {
+		
+		callSuper(...)
 
 		.observers <<- NULL
 		.output.streams <<- NULL
 		.input.stream <<- NULL
 		.prec <<- MSDB.DFT.PREC
 		.mz.tol.unit <<- MSDB.DFT.MZTOLUNIT
-		
-		callSuper(...)
+		.rt.unit <<- MSDB.RTUNIT.SEC
 	})
 
 	####################
@@ -126,6 +127,10 @@
 		stop("Method setDbMsModes() not implemented in concrete class.")
 	})
 	
+	###################
+	# SET MZ TOL UNIT #
+	###################
+
 	MsDb$methods( setMzTolUnit = function(mztolunit) {
 
 		if ( ! mztolunit %in% MSDB.MZTOLUNIT.VALS)
@@ -134,6 +139,26 @@
 		.mz.tol.unit <<- mztolunit
 	})
 
+	###############
+	# SET RT UNIT #
+	###############
+
+	MsDb$methods( setRtUnit = function(unit) {
+
+		if ( ! unit %in% MSDB.RTUNIT.VALS)
+			stop(paste0("RT unit must be one of: ", paste(MSDB.RTUNIT.VALS, collapse = ', '), "."))
+
+		.rt.unit <<- unit
+	})
+
+	###############
+	# GET RT UNIT #
+	###############
+
+	MsDb$methods( getRtUnit = function(unit) {
+		return(.self$.rt.unit)
+	})
+
 	####################
 	# HANDLE COMPOUNDS #
 	####################
@@ -294,8 +319,6 @@
 #				peaks <- rbind(peaks, peaks.na)
 #
 #				# Sort
-#				print(colnames(peaks))
-#				print(x.colnames)
 #				peaks <- peaks[order(peaks[[x.colnames$mz]], peaks[[x.colnames$rt]], peaks[[MSDB.TAG.MOLID]], peaks[[MSDB.TAG.COL]]), ]
 #
 #				# Remove rownames