Skip to content

Commit

Permalink
Removed netCDF.h, can already be used by xcmsRaw
Browse files Browse the repository at this point in the history
  • Loading branch information
sneumann committed Sep 10, 2018
1 parent bda1e08 commit dfbd825
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 370 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Expand Up @@ -17,12 +17,12 @@ Description: mzR provides a unified API to the common file formats and
License: Artistic-2.0
LazyLoad: yes
Depends: Rcpp (>= 0.10.1), methods, utils
Imports: Biobase, BiocGenerics (>= 0.13.6), ProtGenerics (>= 1.9.1)
Imports: Biobase, BiocGenerics (>= 0.13.6), ProtGenerics (>= 1.9.1), ncdf4
Suggests: msdata (>= 0.15.1), RUnit, mzID, BiocStyle (>= 2.5.19), knitr, XML
VignetteBuilder: knitr
LinkingTo: Rcpp, zlibbioc, Rhdf5lib (>= 1.1.4)
RcppModules: Ramp, Pwiz, Ident
SystemRequirements: C++11, GNU make, NetCDF
SystemRequirements: C++11, GNU make
URL: https://github.com/sneumann/mzR/
BugReports: https://github.com/sneumann/mzR/issues/
biocViews: Infrastructure, DataImport, Proteomics, Metabolomics,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Expand Up @@ -6,8 +6,8 @@ import(ProtGenerics)
importClassesFrom(Biobase, "Versioned")
importFrom(Biobase, validMsg)
importFrom("utils", "packageVersion")
##importFrom(Rcpp, "loadRcppModules")
import(Rcpp)
import(ncdf4)

export(openMSfile,
openIDfile,
Expand Down
16 changes: 13 additions & 3 deletions R/DataClasses.R
Expand Up @@ -2,8 +2,10 @@
## Defines supported backend APIs
## - NULL: default
## - C++Object: for Rcpp modules for ramp and pwiz backends
## - ncdf4 for netCDF files
setOldClass("ncdf4")
setClassUnion("msAPI",
c("C++Object","integer", "NULL"))
c("C++Object","ncdf4", "NULL"))

##############################################################
## mzR main virtual class
Expand Down Expand Up @@ -60,10 +62,18 @@ setClass("mzRpwiz",
##############################################################
## mzRnetCDF - netCDF backend
setClass("mzRnetCDF",
representation(),
representation(backend="ncdf4"),
contains=c("mzR"),
prototype=prototype(
new("Versioned", versions=c(mzR="0.0.1")))
new("Versioned", versions=c(mzR="0.0.2"))),
validity=function(object) {
msg <- validMsg(NULL,NULL)
if (is.null(object@backend))
msg <- validMsg(msg,"ncdf4 object not initialised.")
if (is.null(object@backend$id))
msg <- validMsg(msg,"ncdf4 object is closed.")
if (is.null(msg)) TRUE
else msg }
)

##############################################################
Expand Down
28 changes: 7 additions & 21 deletions R/methods-mzRnetCDF.R
@@ -1,25 +1,7 @@
## setMethod("get3Dmap",
## signature="mzRnetCDF",
## function(object,scans,lowMz,highMz,resMz)
## return(object@backend$get3DMap(scans,lowMz,highMz,resMz)))

## setMethod("initializeRamp",
## signature="mzRnetCDF",
## function(object) {
## if (!file.exists(fileName(object)))
## stop("File ",fileName(object)," not found.\n")
## object@backend$open(fileName(object), declaredOnly = TRUE)
## if (isInitialized(object)) invisible(TRUE)
## else stop("Could not initialize ramp slot.")
## })

setMethod("length",
signature=c("mzRnetCDF"),
function(x) {
scanindex <- netCDFVarInt(x@backend, "scan_index")
if (!is.null(attr(scanindex, "errortext")))
stop("Couldn't read scan indicies from ", x@backend)
return(length(scanindex))
return(netCDFVarLen(x@backend, var="scan_number"))
})

setMethod("peaks", "mzRnetCDF",
Expand Down Expand Up @@ -102,11 +84,15 @@ setMethod("header",

setMethod("close",
signature="mzRnetCDF",
function(con,...) return( netCDFClose(con@backend) ))
function(con,...) {
if (validObject(con))
netCDFClose(con@backend)
con@backend$id <- NULL
invisible(TRUE)} )

setMethod("isInitialized",
signature="mzRnetCDF",
function(object) return(object@backend > 0))
function(object) return(class(object@backend) == "ncdf4" && validObject(object)))

setMethod("runInfo",
signature="mzRnetCDF",
Expand Down

0 comments on commit dfbd825

Please sign in to comment.