diff MsXlsDb.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/MsXlsDb.R	Sat Sep 03 17:02:01 2016 -0400
+++ b/MsXlsDb.R	Thu Mar 02 08:55:00 2017 -0500
@@ -39,6 +39,7 @@
 	MsXlsDb$methods( initialize = function(db_dir = NA_character_, limit = NA_integer_, cache_dir = NA_character_, cache = FALSE, ...) {
 
 		# Initialize members
+		                # TODO check that db_dir is not null neither na, and tests that it exists and is a directory.
 		.db_dir <<- if ( ! is.null(db_dir)) db_dir else NA_character_
 		.limit <<- if ( ! is.null(limit) && ! is.na(limit) && limit > 0) limit else NA_integer_
 		cache_dir <- if (cache && is.na(cache_dir) && ! is.na(db_dir)) file.path(db_dir, 'cache') else cache_dir
@@ -283,7 +284,7 @@
 	#################
 	
 	# Returns a numeric vector of all masses stored inside the database.
-	MsXlsDb$methods( getMzValues = function(mode = NULL) {
+	MsXlsDb$methods( getMzValues = function(mode = NULL, max.results = NA_integer_) {
 
 		mz <- numeric()
 
@@ -295,6 +296,10 @@
 		# Remove duplicated
 		mz <- mz[ ! duplicated(mz)]
 
+		# Apply cut-off
+		if ( ! is.na(max.results))
+			mz <- mz[1:max.results]
+
 		return(mz)
 	})