Browse code

fix merge conflict

From: Laurent <lg390@cam.ac.uk>

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

l.gatto authored on 15/12/2016 11:00:07
Showing 11 changed files

... ...
@@ -15,4 +15,4 @@ apt_packages:
15 15
 # Set CXX1X for R-devel, as R-devel does not detect CXX1X support for gcc 4.6.3,
16 16
 # Thanks to jimhester pointing this out!
17 17
 before_install:
18
-  - echo "$TRAVIS_R_VERSION_STRING" ; if [[ "$TRAVIS_R_VERSION_STRING" = 'bioc-devel' ]]; then mkdir ~/.R && echo 'SHLIB_CXX1XLD=g++ \nCXX1X=g++ ' > ~/.R/Makevars; fi
18
+  - echo "$TRAVIS_R_VERSION_STRING" ; if [[ "$TRAVIS_R_VERSION_STRING" = 'bioc-devel' ]]; then mkdir ~/.R && echo 'SHLIB_CXX1XLD=g++ \nCXX1X=g++ ' > ~/.R/Makevars; fi
19 19
\ No newline at end of file
... ...
@@ -25,7 +25,7 @@ exportMethods(close,
25 25
               detector,
26 26
               header,
27 27
               peaksCount,
28
-              peaks,
28
+              peaks, spectra,
29 29
               get3Dmap,
30 30
               softwareInfo,
31 31
               sampleInfo,
... ...
@@ -1,14 +1,19 @@
1 1
 CHANGES IN VERSION 2.9.1
2 2
 ------------------------
3
+ o Delete RAMPAdapter pointer in pwiz backend (by jotsetung)
4
+   <2016-11-20 Sun>
5
+ o Use spectra in addition to peaks (see issue #15)
6
+   <2016-12-09 Fri>
7
+ o New pwiz (commit 946d23d75dc70a7a4913d8e05e3d59b9255f278e)
3 8
 
4 9
 CHANGES IN VERSION 2.9.0
5 10
 ------------------------
6
- o Version for Bioc devel 3.5
11
+ o Bioc devel 3.5
7 12
  
8 13
 CHANGES IN VERSION 2.8.0
9 14
 ------------------------
10
- o Version for Bioc release 3.4
11
- 
15
+ o Bioc release 3.4
16
+
12 17
 CHANGES IN VERSION 2.7.13
13 18
 -------------------------
14 19
  o Fix waring on OSX (see issue #60)
... ...
@@ -22,29 +22,32 @@ setMethod("length",
22 22
             return(length(scanindex))
23 23
           })
24 24
 
25
-setMethod("peaks",
26
-          signature=c("mzRnetCDF"),
25
+setMethod("peaks", "mzRnetCDF",
27 26
           function(object, scans) {
28
-              if (missing(scans)) 
27
+              if (missing(scans))
29 28
                   scans <- 1:length(object)
30
-
31 29
               rawdata <- netCDFRawData(object@backend)
32 30
 
33 31
               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]))
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],
36
+                               intensity = rawdata$intensity[idx]))
38 37
               } 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])
38
+                  return(sapply(scans, function(x) {
39
+                      idx <- seq(rawdata$scanindex[x] + 1,
40
+                                 min(rawdata$scanindex[x + 1],
41
+                                     length(rawdata$mz), na.rm = TRUE))
42
+                      cbind(mz = rawdata$mz[idx],
43
+                            intensity = rawdata$intensity[idx])
44 44
                   }, simplify = FALSE))
45 45
               }
46 46
           })
47 47
 
48
+setMethod("spectra", "mzRnetCDF",
49
+          function(object, scans) peaks(object, scans))
50
+
48 51
 ## setMethod("peaksCount",
49 52
 ##           signature=c("mzRnetCDF","numeric"),
50 53
 ##           function(object,scans) {
... ...
@@ -59,38 +59,28 @@ setMethod("detector",
59 59
           })
60 60
 
61 61
 setMethod("header",
62
-          signature=c("mzRpwiz","missing"),
62
+          signature = c("mzRpwiz", "missing"),
63 63
           function(object) return(object@backend$getAllScanHeaderInfo()))
64 64
 
65 65
 setMethod("header",
66
-          signature=c("mzRpwiz","numeric"),
66
+          signature = c("mzRpwiz", "numeric"),
67 67
           function(object, scans) {
68
-            if (length(scans)==1) {
68
+            if (length(scans) == 1) {
69 69
               return(object@backend$getScanHeaderInfo(scans))
70 70
             } else {
71 71
               return(data.frame(t(sapply(scans,function(x) unlist(object@backend$getScanHeaderInfo(x))))))
72 72
             }
73 73
           })
74 74
 
75
-setMethod("peaks",
76
-          signature=c("mzRpwiz"),
77
-          function(object, scans) {
78
-              if (missing(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
-              }
88
-          })
75
+setMethod("peaks", "mzRpwiz",
76
+          function(object, scans) .peaks(object, scans))
77
+setMethod("spectra", "mzRpwiz",
78
+          function(object, scans) .peaks(object, scans))
89 79
 
90 80
 setMethod("peaksCount",
91
-          signature=c("mzRpwiz","numeric"),
92
-          function(object,scans) {
93
-            if (length(scans)==1) {
81
+          signature = c("mzRpwiz", "numeric"),
82
+          function(object, scans) {
83
+            if (length(scans) == 1) {
94 84
               return(object@backend$getPeakList(scans)$peaksCount)
95 85
             } else {
96 86
               return(sapply(scans,function(x) object@backend$getPeakList(x)$peaksCount))
... ...
@@ -98,14 +88,14 @@ setMethod("peaksCount",
98 88
           })
99 89
 
100 90
 setMethod("peaksCount",
101
-          signature=c("mzRpwiz","missing"),
91
+          signature = c("mzRpwiz", "missing"),
102 92
           function(object) {
103 93
             n <- length(object)
104 94
             return(peaksCount(object,1:n))
105 95
           })
106 96
 
107 97
 setMethod("runInfo",
108
-          signature="mzRpwiz",
98
+          signature = "mzRpwiz",
109 99
           function(object) {
110 100
             hd <- header(object)
111 101
             ll <- list()
... ...
@@ -7,7 +7,7 @@ setMethod("initializeRamp",
7 7
           signature="mzRramp",
8 8
           function(object) {
9 9
             if (!file.exists(fileName(object)))
10
-              stop("File ",fileName(object)," not found.\n")
10
+                stop("File ", fileName(object), " not found.\n")
11 11
             object@backend$open(fileName(object), declaredOnly = TRUE)
12 12
             if (isInitialized(object)) invisible(TRUE)
13 13
             else stop("Could not initialize ramp slot.")
... ...
@@ -17,36 +17,27 @@ setMethod("length",
17 17
           signature=c("mzRramp"),
18 18
           function(x) return(x@backend$getLastScan()))
19 19
 
20
-setMethod("peaks",
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
-              }
33
-          })
20
+setMethod("peaks", "mzRramp",
21
+          function(object, scans) .peaks(object, scans))
22
+
23
+setMethod("spectra", "mzRramp",
24
+          function(object, scans) .peaks(object, scans))
34 25
 
35 26
 setMethod("peaksCount",
36 27
           signature=c("mzRramp","numeric"),
37 28
           function(object,scans) {
38
-            if (length(scans)==1) {
39
-              return(object@backend$getPeakList(scans)$peaksCount)
40
-            } else {
41
-              return(sapply(scans,function(x) object@backend$getPeakList(x)$peaksCount))
42
-            }
29
+              if (length(scans)==1) {
30
+                  return(object@backend$getPeakList(scans)$peaksCount)
31
+              } else {
32
+                  return(sapply(scans,function(x) object@backend$getPeakList(x)$peaksCount))
33
+              }
43 34
           })
44 35
 
45 36
 setMethod("peaksCount",
46 37
           signature=c("mzRramp","missing"),
47 38
           function(object) {
48
-            n <- length(object)
49
-            return(peaksCount(object,1:n))
39
+              n <- length(object)
40
+              return(peaksCount(object,1:n))
50 41
           })
51 42
 
52 43
 setMethod("header",
... ...
@@ -56,11 +47,11 @@ setMethod("header",
56 47
 setMethod("header",
57 48
           signature=c("mzRramp","numeric"),
58 49
           function(object, scans) {
59
-            if (length(scans)==1) {
60
-              return(object@backend$getScanHeaderInfo(scans))
61
-            } else {
62
-              return(data.frame(t(sapply(scans,function(x) unlist(object@backend$getScanHeaderInfo(x))))))
63
-            }
50
+              if (length(scans)==1) {
51
+                  return(object@backend$getScanHeaderInfo(scans))
52
+              } else {
53
+                  return(data.frame(t(sapply(scans,function(x) unlist(object@backend$getScanHeaderInfo(x))))))
54
+              }
64 55
           })
65 56
 
66 57
 setMethod("close", 
... ...
@@ -74,87 +65,87 @@ setMethod("isInitialized",
74 65
 setMethod("runInfo",
75 66
           signature="mzRramp",
76 67
           function(object) {
77
-            ##return(object@backend$getRunInfo())
78
-            hd <- header(object)
79
-            ll <- list()
80
-            ll$'scanCount' <- length(object)
81
-            ll$'lowMz' <- min(hd$lowMZ)
82
-            ll$'highMz' <- max(hd$highMZ)
83
-            ll$'dStartTime' <- min(hd$retentionTime)
84
-            ll$'dEndTime' <- max(hd$retentionTime)
85
-            ll$'msLevels' <- unique(hd$msLevel)
86
-            return(ll)
68
+              ##return(object@backend$getRunInfo())
69
+              hd <- header(object)
70
+              ll <- list()
71
+              ll$'scanCount' <- length(object)
72
+              ll$'lowMz' <- min(hd$lowMZ)
73
+              ll$'highMz' <- max(hd$highMZ)
74
+              ll$'dStartTime' <- min(hd$retentionTime)
75
+              ll$'dEndTime' <- max(hd$retentionTime)
76
+              ll$'msLevels' <- unique(hd$msLevel)
77
+              return(ll)
87 78
           })
88 79
 
89 80
 
90 81
 setMethod("instrumentInfo",
91 82
           signature="mzRramp",
92 83
           function(object) 
93
-          return(object@backend$getInstrumentInfo()))
84
+              return(object@backend$getInstrumentInfo()))
94 85
 
95 86
 
96 87
 setMethod("manufacturer",
97 88
           signature="mzRramp",
98 89
           function(object) {
99
-            info <- instrumentInfo(object)           
100
-            return(info$manufacturer)
90
+              info <- instrumentInfo(object)           
91
+              return(info$manufacturer)
101 92
           })
102 93
 
103 94
 setMethod("model",
104 95
           signature="mzRramp",
105 96
           function(object) {
106
-            info <- instrumentInfo(object)           
107
-            return(info$model)
97
+              info <- instrumentInfo(object)           
98
+              return(info$model)
108 99
           })
109 100
 
110 101
 setMethod("ionisation",
111 102
           signature="mzRramp",
112 103
           function(object) {
113
-            info <- instrumentInfo(object)           
114
-            return(info$ionisation)
104
+              info <- instrumentInfo(object)           
105
+              return(info$ionisation)
115 106
           })
116 107
 
117 108
 setMethod("analyzer",
118 109
           signature="mzRramp",
119 110
           function(object) {
120
-            info <- instrumentInfo(object)           
121
-            return(info$analyzer)
111
+              info <- instrumentInfo(object)           
112
+              return(info$analyzer)
122 113
           })
123 114
 
124 115
 setMethod("detector",
125 116
           signature="mzRramp",
126 117
           function(object) {
127
-            info <- instrumentInfo(object)           
128
-            return(info$detector)
118
+              info <- instrumentInfo(object)           
119
+              return(info$detector)
129 120
           })
130 121
 
131 122
 
132 123
 setMethod("show",
133 124
           signature="mzRramp",
134 125
           function(object) {
135
-            if (!isInitialized(object)) {
136
-              cat("Your object's ramp slot is not initialized.\n")
137
-              cat("Use initializeRamp(object) to fix this.\n")
138
-            } else {
139
-              filename <- fileName(object)
140
-              ## info <- instrumentInfo(object)
141
-              ## run  <- runInfo(object)
142
-              cat("Mass Spectrometry file handle.\n")
143
-              cat("Filename: ", basename(filename), "\n")
144
-              cat("Number of scans: ", length(object), "\n")
145
-              ## if (any(info != "")) {
146
-              ##   cat("Manufacturer: ", info$manufacturer, "\n")
147
-              ##   cat("Model:        ", info$model, "\n")
148
-              ##   cat("Ionisation:   ", info$ionisation, "\n")
149
-              ##   cat("Analyzer:     ", info$analyzer, "\n")
150
-              ##   cat("Detector:     ", info$detector, "\n")
151
-              ## }
152
-              ## cat("Number of scans: ", run$scanCount, "\n")
153
-              ## cat("lowMZ:        ", run$lowMZ, " \thighMZ: ", run$highMZ, "\n")
154
-              ## cat("startMZ:      ", run$startMZ, " \tendMZ: ",  run$endMZ, "\n")
155
-              ## cat("dStartTime:   ", run$dStartTime, " \tdEndTime: ", run$dEndTime, "\n")
156
-            }
157
-            invisible(NULL)
126
+              if (!isInitialized(object)) {
127
+                  cat("Your object's ramp slot is not initialized.\n")
128
+                  cat("Use initializeRamp(object) to fix this.\n")
129
+              } else {
130
+                  filename <- fileName(object)
131
+                  ## info <- instrumentInfo(object)
132
+                  ## run  <- runInfo(object)
133
+                  cat("Mass Spectrometry file handle.\n")
134
+                  cat("Filename: ", basename(filename), "\n")
135
+                  cat("Number of scans: ", length(object), "\n")
136
+                  ## if (any(info != "")) {
137
+                  ##   cat("Manufacturer: ", info$manufacturer, "\n")
138
+                  ##   cat("Model:        ", info$model, "\n")
139
+                  ##   cat("Ionisation:   ", info$ionisation, "\n")
140
+                  ##   cat("Analyzer:     ", info$analyzer, "\n")
141
+                  ##   cat("Detector:     ", info$detector, "\n")
142
+                  ## }
143
+                  ## cat("Number of scans: ", run$scanCount, "\n")
144
+                  ## cat("lowMZ:        ", run$lowMZ, " \thighMZ: ", run$highMZ, "\n")
145
+                  ## cat("startMZ:      ", run$startMZ, " \tendMZ: ",  run$endMZ, "\n")
146
+                  ## cat("dStartTime:   ", run$dStartTime, " \tdEndTime: ", run$dEndTime, "\n")
147
+              }
148
+              invisible(NULL)
158 149
           })
159 150
 
160 151
 setMethod("isolationWindow", "mzRramp",
... ...
@@ -1,3 +1,16 @@
1
+.peaks <- function(object, scans) {
2
+    if (missing(scans))
3
+        scans <- 1:length(object)
4
+    if (length(scans) == 1) {
5
+        return(object@backend$getPeakList(scans)$peaks)
6
+    } else {
7
+        return(sapply(scans,
8
+                      function(x) object@backend$getPeakList(x)$peaks,
9
+                      simplify = FALSE))
10
+    }
11
+}
12
+
13
+
1 14
 setMethod("isolationWindow", "character",
2 15
           function(object, ...) .isolationWindow(object, ...))
3 16
 
4 17
deleted file mode 100644
... ...
@@ -77,11 +77,19 @@ test_mzData.gz <- function() {
77 77
     close(mzdata)    
78 78
 }
79 79
 
80
+<<<<<<< HEAD
80 81
 test_peaks_scans <- function() {
82
+=======
83
+test_peaks_spectra <- function() {
84
+>>>>>>> master
81 85
     library("msdata")
82 86
     f <- proteomics(full.names = TRUE)
83 87
     x <- openMSfile(f[1])
84 88
     p <- peaks(x, 1:10)
89
+<<<<<<< HEAD
85 90
     s <- scans(x, 1:10)
91
+=======
92
+    s <- spectra(x, 1:10)
93
+>>>>>>> master
86 94
     checkIdentical(p, s)
87 95
 }
... ...
@@ -55,11 +55,11 @@
55 55
 \alias{peaksCount,mzRpwiz,missing-method}
56 56
 \alias{peaksCount,mzRpwiz,numeric-method}
57 57
 \alias{peaks,mzRramp-method}
58
-\alias{peaks,mzRramp-method}
59
-\alias{peaks,mzRpwiz-method}
58
+\alias{spectra,mzRramp-method}
60 59
 \alias{peaks,mzRpwiz-method}
60
+\alias{spectra,mzRpwiz-method}
61 61
 \alias{peaks,mzRnetCDF-method}
62
-\alias{peaks,mzRnetCDF-method}
62
+\alias{spectra,mzRnetCDF-method}
63 63
 \alias{runInfo,mzRramp-method}
64 64
 \alias{runInfo,mzRpwiz-method}
65 65
 \alias{runInfo,mzRnetCDF-method}
... ...
@@ -152,6 +152,10 @@
152 152
     \item{peaks}{\code{signature(object = "mzRramp", scans = "numeric")}: ... }
153 153
     \item{peaks}{\code{signature(object = "mzRnetCDF", scans = "missing")}: ... }
154 154
     \item{peaks}{\code{signature(object = "mzRnetCDF", scans = "numeric")}: ... }
155
+    \item{spectra}{\code{signature(object = "mzRramp", scans = "missing")}: ... }
156
+    \item{spectra}{\code{signature(object = "mzRramp", scans = "numeric")}: ... }
157
+    \item{spectra}{\code{signature(object = "mzRnetCDF", scans = "missing")}: ... }
158
+    \item{spectra}{\code{signature(object = "mzRnetCDF", scans = "numeric")}: ... }
155 159
     \item{runInfo}{\code{signature(object = "mzRramp")}: ... }
156 160
 
157 161
   }
... ...
@@ -1,5 +1,6 @@
1 1
 \name{peaks}
2 2
 \alias{peaks}
3
+\alias{spectra}
3 4
 \alias{header}
4 5
 \alias{peaksCount}
5 6
 \alias{get3Dmap}
... ...
@@ -13,7 +14,9 @@
13 14
 
14 15
  peaksCount(object, scans, ...)
15 16
 
16
- peaks(object, ...)
17
+ peaks(object, ...) 
18
+
19
+ spectra(object, ...) ## same as peaks
17 20
 
18 21
  get3Dmap(object, scans, lowMz, highMz, resMz, ...)
19 22
 }
... ...
@@ -21,7 +24,7 @@
21 24
 \arguments{
22 25
   \item{object}{An instantiated \code{mzR} object.}
23 26
   \item{scans}{A \code{numeric} specifying which scans to
24
-    return. Optional for the \code{header}, \code{peaks} and
27
+    return. Optional for the \code{header}, \code{peaks}, \code{scans} and
25 28
     \code{peaksCount} methods. If ommited, the requested data for all
26 29
     peaks is returned. } 
27 30
   \item{lowMz, highMz}{\code{Numeric}s defining the m/z range to be returned.}
... ...
@@ -31,25 +34,27 @@
31 34
 }
32 35
 
33 36
 \description{
34
-  Access the MS raw data. The \code{peaks} and \code{peaksCount}
35
-  functions return the (m/z,intensity) pairs and the number peaks in the
36
-  spectrum/spectra. \code{peaks} returns a single matrix if \code{scans}
37
-  is a \code{numeric} of length 1 and a list of matrices if several scans are
38
-  asked for or no \code{scans} argument is provided (i.e all spectra in
39
-  the oject are retured). \code{peaksCount} will return a numeric of
40
-  length \code{n}. 
37
+
38
+  Access the MS raw data. The \code{peaks}, \code{spectra} (can be used
39
+  interchangeably) and \code{peaksCount} functions return the (m/z,
40
+  intensity) pairs and the number peaks in the
41
+  spectrum/spectra. \code{peaks} and \code{spectra} return a single matrix
42
+  if \code{scans} is a \code{numeric} of length 1 and a list of matrices
43
+  if several scans are asked for or no \code{scans} argument is provided
44
+  (i.e all spectra in the oject are retured). \code{peaksCount} will
45
+  return a numeric of length \code{n}.
41 46
   
42 47
   The \code{\link{header}} function returns a list containing
43
- \code{seqNum}, \code{acquisitionNum} , \code{msLevel},
44
- \code{peaksCount}, \code{totIonCurrent}, \code{retentionTime},
45
- \code{basePeakMZ}, \code{basePeakIntensity}, \code{collisionEnergy},
46
- \code{ionisationEnergy}, \code{lowM}, \code{highMZ},
47
- \code{precursorScanNum}, \code{precursorMZ}, \code{precursorCharge},
48
- \code{precursorIntensity}, \code{mergedScan},
49
- \code{mergedResultScanNum}, \code{mergedResultStartScanNum} and 
50
- \code{mergedResultEndScanNum}, when available in the original file. If
51
- multiple scans are queried, a \code{data.frame} is returned with the
52
- scans reported along the rows.
48
+  \code{seqNum}, \code{acquisitionNum} , \code{msLevel},
49
+  \code{peaksCount}, \code{totIonCurrent}, \code{retentionTime},
50
+  \code{basePeakMZ}, \code{basePeakIntensity}, \code{collisionEnergy},
51
+  \code{ionisationEnergy}, \code{lowM}, \code{highMZ},
52
+  \code{precursorScanNum}, \code{precursorMZ}, \code{precursorCharge},
53
+  \code{precursorIntensity}, \code{mergedScan},
54
+  \code{mergedResultScanNum}, \code{mergedResultStartScanNum} and
55
+  \code{mergedResultEndScanNum}, when available in the original file. If
56
+  multiple scans are queried, a \code{data.frame} is returned with the
57
+  scans reported along the rows.
53 58
 
54 59
  The \code{get3Dmap} function performs a simple resampling between
55 60
  \code{lowMz} and \code{highMz} with \code{reMz} resolution. A matrix of
... ...
@@ -66,7 +71,6 @@
66 71
   Steffen Neumann and Laurent Gatto
67 72
 }
68 73
 
69
-
70 74
 \examples{
71 75
  library(msdata)
72 76
  filepath <- system.file("microtofq", package = "msdata")