Browse code

Commit made by the Bioconductor Git-SVN bridge.

Commit id: 6599b4e00f742fc668f41353450efbaf98f0bbf1

using the generic functions from ProtGenerics and BiocGenerics



git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/mzR@100003 bc3139a8-67e5-0310-9ffc-ced21a209358

s.neumann authored on 28/02/2015 14:26:11
Showing 12 changed files

... ...
@@ -2,7 +2,7 @@ Package: mzR
2 2
 Type: Package
3 3
 Title: parser for netCDF, mzXML, mzData and mzML and mzIdentML files
4 4
        (mass spectrometry data)
5
-Version: 2.1.10
5
+Version: 2.1.11
6 6
 Author: Bernd Fischer, Steffen Neumann, Laurent Gatto, Qiang Kou
7 7
 Maintainer: Bernd Fischer <bernd.fischer@embl.de>, 
8 8
 	    Steffen Neumann <sneumann@ipb-halle.de>, 
... ...
@@ -18,7 +18,7 @@ Description: mzR provides a unified API to the common file formats and
18 18
 License: Artistic-2.0
19 19
 LazyLoad: yes
20 20
 Depends: Rcpp (>= 0.10.1), methods, utils
21
-Imports: Biobase, zlibbioc
21
+Imports: Biobase, zlibbioc, BiocGenerics (>= 0.13.6), ProtGenerics
22 22
 Suggests: msdata (>= 0.3.5), RUnit, mzID, BiocStyle, knitr, BiocGenerics
23 23
 VignetteBuilder: knitr
24 24
 LinkingTo: Rcpp, zlibbioc
... ...
@@ -1,6 +1,8 @@
1 1
 useDynLib(mzR)
2 2
 
3 3
 import(methods)
4
+import(BiocGenerics)
5
+import(ProtGenerics)
4 6
 import(zlibbioc)
5 7
 importClassesFrom(Biobase, "Versioned")
6 8
 importFrom(Biobase, validMsg)
... ...
@@ -1,5 +1,10 @@
1
+CHANGES IN VERSION 2.1.11
2
+-------------------------
3
+ o Using generics from BiocGenerics (fileName, score) and ProtGenerics
4
+   [2015-02-28 Sat]
5
+ 
1 6
 CHANGES IN VERSION 2.1.10
7
+-------------------------
2 8
  o Add instrumentInfo() and runInfo() for CDF backend (closes issue #22) 
3 9
  o Add precompiled libpwiz.a to reduce compile time on Windows (closes issue #21), thanks to KK
4 10
 
... ...
@@ -1,11 +1,7 @@
1 1
 setGeneric("runInfo", function(object) standardGeneric("runInfo"))
2 2
 setGeneric("mzidInfo", function(object) standardGeneric("mzidInfo"))
3
-setGeneric("psms", function(object) standardGeneric("psms"))
4
-setGeneric("score", function(object) standardGeneric("score"))
5 3
 setGeneric("para", function(object) standardGeneric("para"))
6
-setGeneric("modifications", function(object) standardGeneric("modifications"))
7 4
 setGeneric("substitutions", function(object) standardGeneric("substitutions"))
8
-setGeneric("database", function(object) standardGeneric("database"))
9 5
 setGeneric("enzymes", function(object) standardGeneric("enzymes"))
10 6
 setGeneric("tolerance", function(object) standardGeneric("tolerance"))
11 7
 setGeneric("instrumentInfo", function(object) standardGeneric("instrumentInfo"))
... ...
@@ -14,7 +10,6 @@ setGeneric("sampleInfo", function(object) standardGeneric("sampleInfo"))
14 10
 setGeneric("sourceInfo", function(object) standardGeneric("sourceInfo"))
15 11
 setGeneric("writeMSfile", function(object, filename, outformat) standardGeneric("writeMSfile"))
16 12
 setGeneric("chromatogramsInfo", function(object) standardGeneric("chromatogramsInfo"))
17
-setGeneric("fileName", function(object) standardGeneric("fileName"))
18 13
 setGeneric("creationDate", function(object) standardGeneric("creationDate"))
19 14
 setGeneric("manufacturer", function(object) standardGeneric("manufacturer"))
20 15
 setGeneric("model", function(object) standardGeneric("model"))
... ...
@@ -26,8 +21,18 @@ setGeneric("initializeRamp",
26 21
            signature=c("object"),
27 22
            function(object) standardGeneric("initializeRamp"))
28 23
 setGeneric("header", function(object,scans,...) standardGeneric("header"))
29
-setGeneric("peaks", function(object,scans,...) standardGeneric("peaks"))
30 24
 setGeneric("peaksCount", function(object,scans,...) standardGeneric("peaksCount"))
31 25
 setGeneric("get3Dmap",
32 26
            signature=c("object"),
33 27
            function(object,scans,lowMz,highMz,resMz,...) standardGeneric("get3Dmap"))
28
+
29
+
30
+### BiocGenerics
31
+## setGeneric("score", function(x, ...) standardGeneric("score"))
32
+## setGeneric("fileName", function(object, ...) standardGeneric("fileName"))
33
+
34
+### ProtGenerics
35
+## setGeneric("psms", function(object, ...) standardGeneric("psms"))
36
+## setGeneric("peaks", function(object, ...) standardGeneric("peaks"))
37
+## setGeneric("database", function(object, ...) standardGeneric("database"))
38
+## setGeneric("modifications", function(object, ...) standardGeneric("modifications"))
... ...
@@ -13,7 +13,7 @@ setMethod("psms",
13 13
           
14 14
 setMethod("score",
15 15
           signature=c("mzRident"),
16
-          function(object) return(object@backend$getScore()))
16
+          function(x) return(x@backend$getScore()))
17 17
           
18 18
 setMethod("para",
19 19
           signature=c("mzRident"),
... ...
@@ -23,33 +23,26 @@ setMethod("length",
23 23
           })
24 24
 
25 25
 setMethod("peaks",
26
-          signature=c("mzRnetCDF","numeric"),
27
-          function(object,scans) {
28
-
29
-            rawdata <- netCDFRawData(object@backend)
30
-
31
-            if (length(scans)==1) {
32
-              idx <- seq(rawdata$scanindex[scans]+1,
33
-                         min(rawdata$scanindex[scans+1],
34
-                             length(rawdata$mz), na.rm=TRUE))              
35
-              return(cbind(mz=rawdata$mz[idx],intensity=rawdata$intensity[idx]))
36
-            } else {
37
-              return(sapply(scans,function(x) {
38
-                idx <- seq(rawdata$scanindex[x]+1,
39
-                           min(rawdata$scanindex[x+1],
40
-                               length(rawdata$mz), na.rm=TRUE))
41
-                cbind(mz=rawdata$mz[idx],intensity=rawdata$intensity[idx])
42
-              }, simplify = FALSE))
43
-            }
44
-          })
45
-
46
-setMethod("peaks",
47
-          signature=c("mzRnetCDF","missing"),
48
-          function(object) {
49
-            n <- length(object)
50
-            if (n==1)
51
-              return(list(peaks(object,1:n))) ## full experiments are always returned as lists
52
-            return(peaks(object,1:n))
26
+          signature=c("mzRnetCDF"),
27
+          function(object, scans) {
28
+              if (missing(scans)) 
29
+                  scans <- 1:length(object)
30
+
31
+              rawdata <- netCDFRawData(object@backend)
32
+
33
+              if (length(scans) == 1) {
34
+                  idx <- seq(rawdata$scanindex[scans]+1,
35
+                             min(rawdata$scanindex[scans+1],
36
+                                 length(rawdata$mz), na.rm=TRUE))              
37
+                  return(cbind(mz=rawdata$mz[idx],intensity=rawdata$intensity[idx]))
38
+              } else {
39
+                  return(sapply(scans,function(x) {
40
+                      idx <- seq(rawdata$scanindex[x]+1,
41
+                                 min(rawdata$scanindex[x+1],
42
+                                     length(rawdata$mz), na.rm=TRUE))
43
+                      cbind(mz=rawdata$mz[idx],intensity=rawdata$intensity[idx])
44
+                  }, simplify = FALSE))
45
+              }
53 46
           })
54 47
 
55 48
 ## setMethod("peaksCount",
... ...
@@ -73,22 +73,18 @@ setMethod("header",
73 73
           })
74 74
           
75 75
 setMethod("peaks",
76
-          signature=c("mzRpwiz","numeric"),
77
-          function(object,scans) {
78
-            if (length(scans)==1) {
79
-              return(object@backend$getPeakList(scans)$peaks)
80
-            } else {
81
-              return(sapply(scans,function(x) object@backend$getPeakList(x)$peaks, simplify = FALSE))
82
-            }
83
-          })
84
-
85
-setMethod("peaks",
86
-          signature=c("mzRpwiz","missing"),
87
-          function(object) {
88
-            n <- length(object)
89
-            if (n==1)
90
-              return(list(peaks(object,1:n))) ## full experiments are always returned as lists
91
-            return(peaks(object,1:n))
76
+          signature=c("mzRpwiz"),
77
+          function(object, scans) {
78
+              if (mising(scans))
79
+                  scans <- 1:length(object)
80
+
81
+              if (length(scans) == 1) {
82
+                  return(object@backend$getPeakList(scans)$peaks)
83
+              } else {
84
+                  return(sapply(scans,
85
+                                function(x) object@backend$getPeakList(x)$peaks,
86
+                                simplify = FALSE))
87
+              }
92 88
           })
93 89
 
94 90
 setMethod("peaksCount",
... ...
@@ -18,22 +18,18 @@ setMethod("length",
18 18
           function(x) return(x@backend$getLastScan()))
19 19
 
20 20
 setMethod("peaks",
21
-          signature=c("mzRramp","numeric"),
22
-          function(object,scans) {
23
-            if (length(scans)==1) {
24
-              return(object@backend$getPeakList(scans)$peaks)
25
-            } else {
26
-              return(sapply(scans,function(x) object@backend$getPeakList(x)$peaks, simplify = FALSE))
27
-            }
28
-          })
29
-
30
-setMethod("peaks",
31
-          signature=c("mzRramp","missing"),
32
-          function(object) {
33
-            n <- length(object)
34
-            if (n==1)
35
-              return(list(peaks(object,1:n))) ## full experiments are always returned as lists
36
-            return(peaks(object,1:n))
21
+          signature=c("mzRramp"),
22
+          function(object, scans) {
23
+              if (missing(scans))
24
+                  scans <- 1:length(object)
25
+              
26
+              if (length(scans) == 1) {
27
+                  return(object@backend$getPeakList(scans)$peaks)
28
+              } else {
29
+                  return(sapply(scans,
30
+                                function(x) object@backend$getPeakList(x)$peaks,
31
+                                simplify = FALSE))
32
+              }
37 33
           })
38 34
 
39 35
 setMethod("peaksCount",
... ...
@@ -36,17 +36,19 @@ sampleInfo(object)
36 36
 sourceInfo(object)
37 37
 model(object)
38 38
 mzidInfo(object)
39
-modifications(object)
40
-psms(object)
39
+modifications(object, ...)
40
+psms(object, ...)
41 41
 substitutions(object)
42
-database(object)
42
+database(object, ...)
43 43
 enzymes(object)
44 44
 tolerance(object)
45
-score(object)
45
+score(x, ...)
46 46
 para(object)
47 47
 }
48 48
 \arguments{
49 49
   \item{object}{An instantiated \code{mzR} object.}
50
+  \item{x}{An instantiated \code{mzR} object.}
51
+  \item{...}{ Additional arguments, currently ignored. }
50 52
 }
51 53
 
52 54
 \description{
... ...
@@ -54,12 +54,12 @@
54 54
 \alias{peaksCount,mzRramp,numeric-method}
55 55
 \alias{peaksCount,mzRpwiz,missing-method}
56 56
 \alias{peaksCount,mzRpwiz,numeric-method}
57
-\alias{peaks,mzRramp,missing-method}
58
-\alias{peaks,mzRramp,numeric-method}
59
-\alias{peaks,mzRpwiz,missing-method}
60
-\alias{peaks,mzRpwiz,numeric-method}
61
-\alias{peaks,mzRnetCDF,missing-method}
62
-\alias{peaks,mzRnetCDF,numeric-method}
57
+\alias{peaks,mzRramp-method}
58
+\alias{peaks,mzRramp-method}
59
+\alias{peaks,mzRpwiz-method}
60
+\alias{peaks,mzRpwiz-method}
61
+\alias{peaks,mzRnetCDF-method}
62
+\alias{peaks,mzRnetCDF-method}
63 63
 \alias{runInfo,mzRramp-method}
64 64
 \alias{runInfo,mzRpwiz-method}
65 65
 \alias{runInfo,mzRnetCDF-method}
... ...
@@ -15,7 +15,7 @@
15 15
 
16 16
  isInitialized(object)
17 17
 
18
- fileName(object)
18
+ fileName(object, ...)
19 19
  
20 20
  openIDfile(filename, verbose = FALSE)
21 21
 }
... ...
@@ -26,6 +26,7 @@
26 26
     use. Currently 'Ramp', 'netCDF'  and 'pwiz' are available.}
27 27
   \item{object}{ An instantiated mzR object. }
28 28
   \item{verbose}{ Enable verbose output. }
29
+  \item{...}{ Additional arguments, currently ignored. }
29 30
 }
30 31
 
31 32
 \description{
... ...
@@ -13,7 +13,7 @@
13 13
 
14 14
  peaksCount(object, scans, ...)
15 15
 
16
- peaks(object, scans, ...)
16
+ peaks(object, ...)
17 17
 
18 18
  get3Dmap(object, scans, lowMz, highMz, resMz, ...)
19 19
 }
... ...
@@ -26,7 +26,8 @@
26 26
     peaks is returned. } 
27 27
   \item{lowMz, highMz}{\code{Numeric}s defining the m/z range to be returned.}
28 28
   \item{resMz}{a \code{numeric} defining the m/z resolution.}
29
-  \item{...}{Other arguments. Currently ignored.}
29
+  \item{...}{Other arguments. A \code{scan} parameter can be passed to
30
+    \code{peaks}.}
30 31
 }
31 32
 
32 33
 \description{