Browse code

new .hasSpectra function

Laurent authored on 16/05/2018 07:30:42
Showing 2 changed files

  • NEWS index 0439c90c80..a7b5664d21 100644
  • R/utils.R index 8c33a5c3ee..f84b300acb 100644
... ...
@@ -1,6 +1,8 @@
1 1
 CHANGES IN VERSION 2.15.1
2 2
 -------------------------
3
- o Fix type (see https://github.com/sneumann/mzR/pull/162)
3
+ o Fix typo (see https://github.com/sneumann/mzR/pull/162)
4
+ o New .hasSpectra private function (see
5
+   https://github.com/lgatto/MSnbase/issues/343)
4 6
 
5 7
 CHANGES IN VERSION 2.15.0
6 8
 -------------------------
... ...
@@ -40,3 +40,11 @@ setMethod("isolationWindow", "character",
40 40
     x <- lapply(x, base::unique)
41 41
     any(sapply(x, function(xx) nrow(xx) > 1))
42 42
 }
43
+
44
+
45
+.hasSpectra <- function(x) {
46
+    if (is.character(x) & file.exists(x))
47
+        x <- mzR::openMSfile(x)
48
+    stopifnot(inherits(x, "mzR"))
49
+    return(as.logical(length(x)))
50
+}