diff MsDb.R @ 2:20d69a062da3 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author prog
date Thu, 02 Mar 2017 08:55:00 -0500
parents e66bb061af06
children fb9c0409d85c
line wrap: on
line diff
--- a/MsDb.R	Sat Sep 03 17:02:01 2016 -0400
+++ b/MsDb.R	Thu Mar 02 08:55:00 2017 -0500
@@ -135,11 +135,20 @@
 	})
 
 	####################
+	# HANDLE COMPOUNDS #
+	####################
+	
+	# Returns TRUE if this database handles compounds directly (by IDs)
+	MsDb$methods( handleCompounds = function() {
+		return(TRUE)
+	})
+
+	####################
 	# GET MOLECULE IDS #
 	####################
 	
 	# Returns an integer vector of all molecule IDs stored inside the database.
-	MsDb$methods( getMoleculeIds = function() {
+	MsDb$methods( getMoleculeIds = function(max.results = NA_integer_) {
 		stop("Method getMoleculeIds() not implemented in concrete class.")
 	})
 
@@ -157,7 +166,7 @@
 	#################
 	
 	# Returns a numeric vector of all masses stored inside the database.
-	MsDb$methods( getMzValues = function(mode = NULL) {
+	MsDb$methods( getMzValues = function(mode = NULL, max.results = NA_integer_) {
 		stop("Method getMzValues() not implemented in concrete class.")
 	})
 	
@@ -218,7 +227,7 @@
 	# GET PEAK TABLE #
 	##################
 
-	MsDb$methods( getPeakTable = function(molid = NA_integer_, mode = NA_character_){
+	MsDb$methods( getPeakTable = function(molid = NA_integer_, mode = NA_character_) {
 		stop("Method getPeakTable() not implemented in concrete class.")
 	})
 
@@ -235,7 +244,7 @@
 	# rt.tol.x          Tolerance parameter for the equations : rtinf = rt - rt.tol.x - rt ^ rt.tol.y and rtsup = rt + rt.tol.x + rt ^ rt.tol.y
 	# rt.tol.y          Tolerance parameter. See rt.tol.x parameter.
 	# attribs           Only search for peaks whose attribution is among this set of attributions.
-	# molids            Only search for peaks whose molecule ID is among this vector of integer molecule IDs. Can also be a data frame with a retention time column x.colnames$rt and a molecule ID column MSDB.TAG.molid.
+	# molids            Only search for peaks whose molecule ID is among this vector of integer molecule IDs. Can also be a data frame with a retention time column x.colnames$rt and a molecule ID column MSDB.TAG.MOLID.
 	# molids.rt.tol     Retention time tolerance used when molids parameter is a data frame (rt, id)
 	# precursor.match   Remove peaks whose molecule precursor peak has not also been matched.
 	# precursor.rt.tol
@@ -261,7 +270,7 @@
 			precursors.ids <- precursors.ids[ ! duplicated(precursors.ids), ]
 
 			# Get all matching peaks whose molecule is inside the previously obtained list of molecules
-			.self$.doSearchForMzRtList(mode = mode, shift = shift, prec = prec, col = col, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, molids = precursors.ids, molids.rt.tol = precursor.rt.tol, same.cols = same.cols, same.rows = same.rows, peak.table = peak.table)
+			df <- .self$.doSearchForMzRtList(mode = mode, shift = shift, prec = prec, col = col, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, molids = precursors.ids, molids.rt.tol = precursor.rt.tol, same.cols = same.cols, same.rows = same.rows, peak.table = peak.table)
 # TODO 
 #
 #			peaks <- if (peak.table) results[['peaks']] else results
@@ -344,6 +353,7 @@
 
 		# Loop on all lines of input
 		peaks <- NULL
+		.self$.input.stream$reset()
 		while (.self$.input.stream$hasNextValues()) {
 
 			.self$.input.stream$nextValues()
@@ -369,7 +379,7 @@
 #				else {
 #					if (same.rows) {
 #						y[r, colnames(x.lines)] <- x.lines
-#						ids <- results[[MSDB.TAG.molid]]
+#						ids <- results[[MSDB.TAG.MOLID]]
 #						ids <- ids[ ! duplicated(ids)] # Remove duplicated values
 #						y[r, MSDB.TAG.msmatching] <- paste(ids, collapse = .self$.molids.sep)
 #					}
@@ -426,7 +436,7 @@
 
 		# List molecule IDs
 		if ( ! is.null(molids.rt.tol) && is.data.frame(molids)) {
-			ids <- molids[(rt >= molids[[MSDB.TAG.colrt]] - molids.rt.tol) & (rt <= molids[[MSDB.TAG.colrt]] + molids.rt.tol), MSDB.TAG.molid]
+			ids <- molids[(rt >= molids[[MSDB.TAG.COLRT]] - molids.rt.tol) & (rt <= molids[[MSDB.TAG.COLRT]] + molids.rt.tol), MSDB.TAG.MOLID]
 			if (length(ids) == 0)
 				# No molecule ID match for this retention time
 				return(data.frame()) # return empty result set