Browse code

Commit made by the Bioconductor Git-SVN bridge. Consists of 1 commit.

Commit information:

Commit id: 9d0350c29e3c20e7ebbc6869675e59b61720fcc6

Add instrumentInfo() and runInfo() for CDF backend (closes #22), Add precompiled libpwiz.a to reduce compile time on Windows (closes #21), thanks to KK

Committed by: Steffen Neumann
Author Name: Steffen Neumann
Commit date: 2015-02-22 00:05:31 +0100
Author date: 2015-02-22 00:05:31 +0100


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

s.neumann authored on 21/02/2015 23:05:55
Showing 8 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.9
5
+Version: 2.1.10
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>, 
... ...
@@ -1,3 +1,8 @@
1
+CHANGES IN VERSION 2.1.10
2
+------------------------
3
+ o Add instrumentInfo() and runInfo() for CDF backend (closes issue #22) 
4
+ o Add precompiled libpwiz.a to reduce compile time on Windows (closes issue #21), thanks to KK
5
+
1 6
 CHANGES IN VERSION 2.1.9
2 7
 ------------------------
3 8
  o Fix a compiler warning on OSX in the pep_XML serialiser
... ...
@@ -108,63 +108,52 @@ setMethod("isInitialized",
108 108
           signature="mzRnetCDF",
109 109
           function(object) return(object@backend > 0))
110 110
 
111
-## setMethod("runInfo",
112
-##           signature="mzRnetCDF",
113
-##           function(object) {
114
-##             ##return(object@backend$getRunInfo())
115
-##             hd <- header(object)
116
-##             ll <- list()
117
-##             ll$'scanCount' <- length(object)
118
-##             ll$'lowMz' <- min(hd$lowMZ)
119
-##             ll$'highMz' <- max(hd$highMZ)
120
-##             ll$'dStartTime' <- min(hd$retentionTime)
121
-##             ll$'dEndTime' <- max(hd$retentionTime)
122
-##             ll$'msLevels' <- unique(hd$msLevel)
123
-##             return(ll)
124
-##           })
111
+setMethod("runInfo",
112
+           signature="mzRnetCDF",
113
+          function(object) 
114
+              return(netCDFRunInfo(object@backend)))
125 115
 
126 116
 
127
-## setMethod("instrumentInfo",
128
-##           signature="mzRnetCDF",
129
-##           function(object) 
130
-##           return(object@backend$getInstrumentInfo()))
131
-
117
+setMethod("instrumentInfo",
118
+          signature="mzRnetCDF",
119
+          function(object) 
120
+              return(netCDFInstrumentInfo(object@backend)))
132 121
 
133
-## setMethod("manufacturer",
134
-##           signature="mzRnetCDF",
135
-##           function(object) {
136
-##             info <- instrumentInfo(object)           
137
-##             return(info$manufacturer)
138
-##           })
139 122
 
140
-## setMethod("model",
141
-##           signature="mzRnetCDF",
142
-##           function(object) {
143
-##             info <- instrumentInfo(object)           
144
-##             return(info$model)
145
-##           })
123
+setMethod("manufacturer",
124
+          signature="mzRnetCDF",
125
+          function(object) {
126
+            info <- instrumentInfo(object)           
127
+            return(info$manufacturer)
128
+          })
146 129
 
147
-## setMethod("ionisation",
148
-##           signature="mzRnetCDF",
149
-##           function(object) {
150
-##             info <- instrumentInfo(object)           
151
-##             return(info$ionisation)
152
-##           })
130
+setMethod("model",
131
+          signature="mzRnetCDF",
132
+          function(object) {
133
+            info <- instrumentInfo(object)           
134
+            return(info$model)
135
+          })
153 136
 
154
-## setMethod("analyzer",
155
-##           signature="mzRnetCDF",
156
-##           function(object) {
157
-##             info <- instrumentInfo(object)           
158
-##             return(info$analyzer)
159
-##           })
137
+setMethod("ionisation",
138
+          signature="mzRnetCDF",
139
+          function(object) {
140
+            info <- instrumentInfo(object)           
141
+            return(info$ionisation)
142
+          })
160 143
 
161
-## setMethod("detector",
162
-##           signature="mzRnetCDF",
163
-##           function(object) {
164
-##             info <- instrumentInfo(object)           
165
-##             return(info$detector)
166
-##           })
144
+setMethod("analyzer",
145
+          signature="mzRnetCDF",
146
+          function(object) {
147
+            info <- instrumentInfo(object)           
148
+            return(info$analyzer)
149
+          })
167 150
 
151
+setMethod("detector",
152
+          signature="mzRnetCDF",
153
+          function(object) {
154
+            info <- instrumentInfo(object)           
155
+            return(info$detector)
156
+          })
168 157
 
169 158
 setMethod("show",
170 159
           signature="mzRnetCDF",
... ...
@@ -123,6 +123,33 @@ netCDFVarInt <- function(ncid, var) {
123 123
        PACKAGE = "mzR")$data
124 124
 }
125 125
 
126
+netCDFVarText <- function(ncid, var) {
127
+
128
+    if (is.character(var))
129
+        var <- netCDFVarID(ncid, var)
130
+    
131
+    if (!is.null(attr(var, "errortext")))
132
+        return(var)
133
+        
134
+    .C("NetCDFVarText",
135
+       as.integer(ncid),
136
+       as.integer(var),
137
+       data = character(1),
138
+       status = integer(1),
139
+       PACKAGE = "mzR")$data
140
+}
141
+
142
+netCDFAttText <- function(ncid, att) {
143
+
144
+    .C("NetCDFGlobalAttribute",
145
+       as.integer(ncid),
146
+       as.character(att),
147
+       data = character(1),
148
+       status = integer(1),
149
+       PACKAGE = "mzR")$data
150
+}
151
+
152
+
126 153
 netCDFMSPoints <- function(ncid, scanIndex) {
127 154
 
128 155
     if (!is.integer(scanIndex)) scanIndex <- as.integer(scanIndex)
... ...
@@ -168,3 +195,42 @@ netCDFRawData <- function(ncid) {
168 195
                 mz = pointValues$massValues,
169 196
                 intensity = pointValues$intensityValues))
170 197
 }
198
+
199
+netCDFRunInfo <- function(ncid) {
200
+
201
+    ncraw <- netCDFRawData(ncid)
202
+
203
+    return(list(scanCount = length(ncraw$scanindex),
204
+                lowMz = min (ncraw$mz),
205
+                highMz = max (ncraw$mz),
206
+                dStartTime = min (ncraw$rt),
207
+                dEndTime = max (ncraw$rt),
208
+                msLevels = NA))
209
+}
210
+
211
+
212
+netCDFInstrumentInfo <- function(ncid) {
213
+    
214
+    imodel <- netCDFVarText(ncid, "instrument_name")
215
+    if (!is.null(attr(imodel, "errortext")))
216
+        stop("Couldn't read instrument_name")
217
+
218
+    imanufacturer <- netCDFVarText(ncid, "instrument_mfr")
219
+    if (!is.null(attr(imodel, "errortext")))
220
+        stop("Couldn't read instrument_mfr")
221
+
222
+    iionisation <- netCDFAttText(ncid, "test_ionization_mode")
223
+    if (!is.null(attr(iionisation, "errortext")))
224
+        stop("Couldn't read test_ionization_mode")
225
+
226
+    idetector <- netCDFAttText(ncid, "test_detector_type")
227
+    if (!is.null(attr(idetector, "errortext")))
228
+        stop("Couldn't read test_detector_type")
229
+
230
+    ianalyzer <- NA
231
+
232
+    return(list(model = imodel, manufacturer=imanufacturer,
233
+                ionisation = iionisation, detector = idetector,
234
+                analyzer = ianalyzer))
235
+}
236
+
... ...
@@ -17,6 +17,6 @@ BUILT_RCPP_VERSION = package_version("@BUILT_RCPP_VERSION@")
17 17
       }
18 18
       require2 <- require
19 19
       require2("methods", character.only = TRUE, quietly = TRUE)
20
-      loadRcppModules()
20
+#      loadRcppModules()
21 21
       Sys.setenv("HDF5_DISABLE_VERSION_CHECK"=2)
22 22
 }
... ...
@@ -93,6 +93,12 @@ MZROBJECTS=cramp.o ramp_base64.o ramp.o RcppRamp.o RcppRampModule.o rnetCDF.o Rc
93 93
 
94 94
 OBJECTS= $(MZROBJECTS) $(PWIZOBJECTS) rampR.o R_init_mzR.o
95 95
 
96
+
97
+
98
+
99
+MZROBJECTS=rnetCDF.o 
100
+OBJECTS= $(MZROBJECTS) 
101
+
96 102
 ##
97 103
 ## R complains about assert(), hence -D_NODEBUG
98 104
 ##  http://www.gamedev.net/topic/555511-is-there-a-way-to-only-disable-boost-debug-checks/
... ...
@@ -75,6 +75,28 @@ void NetCDFVarInt(const int *ncid, const int *varid, int *data, int *status) {
75 75
     *status = nc_get_var_int(*ncid, *varid, data);
76 76
 }
77 77
 
78
+void NetCDFVarText(const int *ncid, const int *varid, char **data, int *status) {
79
+    
80
+    int    varLen;
81
+    
82
+    NetCDFVarLen(ncid, varid, &varLen, status);
83
+    if (*status)
84
+        return;
85
+
86
+    *status = nc_get_var_text(*ncid, *varid, data[0]);
87
+}
88
+
89
+void NetCDFGlobalAttribute(const int *ncid, const char **attname, char **data, int *status) {
90
+    
91
+    size_t    attLen;
92
+
93
+    *status = nc_inq_attlen (*ncid, NC_GLOBAL, attname[0], &attLen);
94
+    if (*status)
95
+        return;
96
+    
97
+    *status = nc_get_att_text(*ncid, NC_GLOBAL, attname[0], data[0]);
98
+}
99
+
78 100
 void NetCDFMSPoints(const int *ncid, const int *scanNumber, 
79 101
                     const int *scanIndex, const int *pointNumber, 
80 102
                     double *massValues, double *intensityValues, int *status) {
... ...
@@ -14,6 +14,10 @@ void NetCDFVarDouble(const int *ncid, const int *varid, double *data, int *statu
14 14
 
15 15
 void NetCDFVarInt(const int *ncid, const int *varid, int *data, int *status);
16 16
 
17
+void NetCDFVarText(const int *ncid, const int *varid, char **data, int *status);
18
+
19
+void NetCDFGlobalAttribute(const int *ncid, const char **attname, char **data, int *status);
20
+
17 21
 void NetCDFMSPoints(const int *ncid, const int *scanNumber,
18 22
                     const int *scanIndex, const int *pointNumber,
19 23
                     double *massValues, double *intensityValues, int *status);