Browse code

Extract start time stamp from netCDF (issue #66)

- Extract start time stamp (netcdf_file_date_time_stamp) from netCDF files.
- Update documentation and unit tests.

jotsetung authored on 03/08/2017 04:52:27
Showing 3 changed files

... ...
@@ -191,9 +191,11 @@ netCDFRawData <- function(ncid) {
191 191
     if (!is.null(attr(pointValues, "errortext")))
192 192
         stop("Couldn't read mass/intensity values")
193 193
 
194
+    startTimeStamp <- netCDFAttText(ncid, "netcdf_file_date_time_stamp")
194 195
     return(list(rt = rt, tic = tic, scanindex = scanindex, 
195 196
                 mz = pointValues$massValues,
196
-                intensity = pointValues$intensityValues))
197
+                intensity = pointValues$intensityValues,
198
+                startTimeStamp = startTimeStamp))
197 199
 }
198 200
 
199 201
 netCDFRunInfo <- function(ncid) {
... ...
@@ -206,7 +208,7 @@ netCDFRunInfo <- function(ncid) {
206 208
                 dStartTime = min (ncraw$rt),
207 209
                 dEndTime = max (ncraw$rt),
208 210
                 msLevels = NA,
209
-                startTimeStamp = NA))
211
+                startTimeStamp = ncraw$startTimeStamp))
210 212
 }
211 213
 
212 214
 
... ...
@@ -39,7 +39,7 @@ test_runStartTimeStamp_cdf <- function() {
39 39
     fh <- mzR::openMSfile(f, backend = "netCDF")
40 40
     run_info <- runInfo(fh)
41 41
     checkTrue(any(names(run_info) == "startTimeStamp"))
42
-    checkTrue(is.na(run_info$startTimeStamp))
42
+    checkTrue(is.character(run_info$startTimeStamp))
43 43
     mzR::close(fh)
44 44
 }
45 45
 
... ...
@@ -57,8 +57,8 @@ para(object)
57 57
   including \code{scanCount}, \code{lowMZ}, \code{highMZ},
58 58
   \code{dStartTime}, \code{dEndTime} and \code{startTimeStamp}. Note
59 59
   that \code{startTimeStamp} can only be extracted from \emph{mzML}
60
-  files using the \emph{pwiz} backend. A \code{NA} is reported if its
61
-  value is not available.
60
+  files using the \emph{pwiz} backend or from \emph{CDF} files. A
61
+  \code{NA} is reported if its value is not available.
62 62
   The \code{instrumentInfo} method returns a named \code{list} including
63 63
   instrument manufacturer, model, ionisation technique, analyzer and
64 64
   detector. \code{mzRpwiz} will give more additional information including
... ...
@@ -84,12 +84,19 @@ para(object)
84 84
 
85 85
 \examples{
86 86
  library(msdata)
87
- filepath <- system.file("microtofq", package = "msdata")
88
- file <- list.files(filepath, pattern="MM14.mzML",
89
-                     full.names=TRUE, recursive = TRUE)
87
+
88
+ file <- system.file("microtofq/MM8.mzML", package = "msdata")
90 89
  mz <- openMSfile(file)
91 90
  fileName(mz)
92 91
  instrumentInfo(mz)
92
+ runInfo(mz)
93
+ close(mz)
94
+
95
+ file <- system.file("cdf/ko15.CDF", package = "msdata")
96
+ mz <- openMSfile(file, backend = "netCDF")
97
+ fileName(mz)
98
+ instrumentInfo(mz)
99
+ runInfo(mz)
93 100
  close(mz)
94 101
  
95 102
  file <- system.file("mzid", "Tandem.mzid.gz", package="msdata")