ProtGenerics/DESCRIPTION0000644000175200017520000000144214136077635015723 0ustar00biocbuildbiocbuildPackage: ProtGenerics Title: Generic infrastructure for Bioconductor mass spectrometry packages Description: S4 generic functions and classes needed by Bioconductor proteomics packages. Version: 1.26.0 Author: Laurent Gatto , Johannes Rainer Maintainer: Laurent Gatto biocViews: Infrastructure, Proteomics, MassSpectrometry URL: https://github.com/RforMassSpectrometry/ProtGenerics Depends: methods Suggests: testthat License: Artistic-2.0 NeedsCompilation: no RoxygenNote: 7.1.1 git_url: https://git.bioconductor.org/packages/ProtGenerics git_branch: RELEASE_3_14 git_last_commit: 2033289 git_last_commit_date: 2021-10-26 Date/Publication: 2021-10-26 Packaged: 2021-10-26 22:22:21 UTC; biocbuild ProtGenerics/NAMESPACE0000644000175200017520000000006014136050775015423 0ustar00biocbuildbiocbuildimport(methods) exportPattern("^[[:alpha:]]+") ProtGenerics/NEWS0000644000175200017520000000621714136050775014715 0ustar00biocbuildbiocbuildCHANGES IN VERSION 1.25.1 ------------------------- o add bin, compareChromatograms and compareSpectra CHANGES IN VERSION 1.25.0 ------------------------- o Bioc devel (3.14) version bump CHANGES IN VERSION 1.23.9 ------------------------- o Added new uniqueMsLevel generic <2021-04-08 Thu> CHANGES IN VERSION 1.23.8 ------------------------- o Added new filterPrecursorCharge generic <2021-04-06 Tue> CHANGES IN VERSION 1.23.7 ------------------------- o Add ProcessingStep object and related methods (moved from Spectra) CHANGES IN VERSION 1.23.6 ------------------------- o Added quantify generics (moved from MSnbase) <2021-01-02 Sat> CHANGES IN VERSION 1.23.5 ------------------------- o new alignRt generic. CHANGES IN VERSION 1.23.4 ------------------------- o new virtual Param class. CHANGES IN VERSION 1.23.3 ------------------------- o new filterIntensity generic. CHANGES IN VERSION 1.23.2 ------------------------- o new compounds generic. CHANGES IN VERSION 1.23.1 ------------------------- o new calculateFragments generic (moved from MSnbase) CHANGES IN VERSION 1.19.3 ------------------------- o new impute generic CHANGES IN VERSION 1.19.2 ------------------------- o new filterNA generic CHANGES IN VERSION 1.19.1 ------------------------- o new aggregateFeatures generic CHANGES IN VERSION 1.17.4 ------------------------- o New generics needed in Spectra and Chromatograms packages <2019-08-20 Tue> CHANGES IN VERSION 1.17.3 ------------------------- o New tolerance generic <2019-08-16 Fri> CHANGES IN VERSION 1.17.2 ------------------------- o New generics (see issue #8) <2019-05-12 Sun> CHANGES IN VERSION 1.17.1 ------------------------- o Move many generics from MSnbase <2019-05-11 Sat> CHANGES IN VERSION 1.9.1 ------------------------ o add writeMSData <2017-09-20 Wed> CHANGES IN VERSION 1.5.1 ------------------------ o added isCentroided generic <2016-07-23 Sat> CHANGES IN VERSION 1.5.0 ------------------------ o Version bump Bioc devel CHANGES IN VERSION 1.4.0 ------------------------ o Version bump Bioc 3.3 CHANGES IN VERSION 1.3.3 ------------------------ o exporting mz<- generic <2015-10-19 Mon> CHANGES IN VERSION 1.3.2 ------------------------ o Not depending on BiocGenerics <2015-10-16 Fri> CHANGES IN VERSION 1.3.1 ------------------------ o added chomatogram generic (previously defined in MSnbase) <2015-10-15 Thu> CHANGES IN VERSION 1.3.0 ------------------------ o Bioc release 3.3 CHANGES IN VERSION 1.2.0 ------------------------ o Bioc release 3.2 CHANGES IN VERSION 1.1.1 ------------------------ o new mz<- generic function <2015-10-01 Thu> CHANGES IN VERSION 1.1.0 ------------------------ o Bioc devel version 3.2 CHANGES IN VERSION 1.0.0 ------------------------ o Bioc release version 3.1 CHANGES IN VERSION 0.99.3 ------------------------- o update man with when and why ProtGenerics [2015-03-16 Mon] CHANGES IN VERSION 0.99.2 ------------------------- o updating DESCRIPTION as with BiocContributions::clean [2015-03-03 Tue] CHANGES IN VERSION 0.99.1 ------------------------- o Adding NEWS file [2015-02-27 Fri] CHANGES IN VERSION 0.99.0 ------------------------- o adding ProtGenerics to Manifest ProtGenerics/R/0000755000175200017520000000000014136050775014411 5ustar00biocbuildbiocbuildProtGenerics/R/DataClasses.R0000644000175200017520000000306714136050775016731 0ustar00biocbuildbiocbuild#' @title Generic parameter class #' #' @name Param #' #' @rdname Param #' #' @author Johannes Rainer #' #' @description #' #' The `Param` class is a virtual class which can be used as *base* class #' from which *parameter* classes can inherit. #' #' The methods implemented for the `Param` class are: #' #' - `as.list`: coerces the `Param` class to a `list` with list elements #' representing the object's slot values, names the slot names. *Hidden* #' slots (i.e. those with a name starting with `.`) are not returned. In #' addition, a `Param` class can be coerced to a `list` using #' `as(object, "list")`. #' #' - `show`: prints the content of the `Param` object (i.e. the individual #' slots and their value). #' #' @param object `Param` object. #' #' @param x `Param` object. #' #' @param ... ignored. NULL #' @rdname Param setClass("Param", contains = "VIRTUAL") #' @rdname Param setMethod("as.list", signature(x = "Param"), function(x, ...) { snames <- slotNames(x) skip <- grep(snames, pattern = "^\\.") if (length(skip)) snames <- snames[-skip] res <- vector("list", length(snames)) names(res) <- snames for (i in seq_along(res)) res[[i]] <- slot(x, name = snames[i]) res }) #' @rdname Param setMethod("show", "Param", function(object) { cat("Object of class: ", class(object), "\n") lst <- as.list(object) cat(" Parameters:\n") for (i in seq_along(lst)) { cat(" - ", names(lst)[i], ": ", sep = "") print(lst[[i]]) } }) setAs("Param", "list", function(from, to) { as.list(from) }) ProtGenerics/R/ProcessingStep.R0000644000175200017520000000626014136050775017510 0ustar00biocbuildbiocbuildsetClassUnion("characterOrFunction", c("character", "function")) #' @title Processing step #' #' @aliases ProcessingStep-class characterOrFunction-class #' #' @description #' #' Class containing the function and arguments to be applied in a lazy-execution #' framework. #' #' Objects of this class are created using the `ProcessingStep()` function. The #' processing step is executed with the `executeProcessingStep()` function. #' #' @details #' #' This object contains all relevant information of a data analysis processing #' step, i.e. the function and all of its arguments to be applied to the data. #' This object is mainly used to record possible processing steps of a #' `Spectra` or `OnDiskMSnExp` object (from the `Spectra` and `MSnbase` #' packages, respectively). #' #' @return The `ProcessingStep` function returns and object of type #' `ProcessingStep`. #' #' @author Johannes Rainer #' #' @exportClass ProcessingStep #' #' @md #' #' @examples #' #' ## Create a simple processing step object #' ps <- ProcessingStep(sum) #' #' executeProcessingStep(ps, 1:10) #' #' @name ProcessingStep NULL setClass("ProcessingStep", representation = representation( FUN = "characterOrFunction", ARGS = "list" ), prototype = prototype( ARGS = list(), FUN = character() ), validity = function(object) { msg <- character() ## Fails with un-exported functions. if (length(object@FUN)) { if (!is.function(object@FUN)) { res <- try(match.fun(object@FUN), silent = TRUE) if (is(res, "try-error")) msg <- c(msg, paste0("Function '", object@FUN, "' not found.")) } } if (length(msg)) msg else TRUE }) #' @param FUN `function` or `character` representing a function name. #' #' @param ARGS `list` of arguments to be passed along to `FUN`. #' #' @rdname ProcessingStep #' #' @md #' #' @export ProcessingStep <- function(FUN = character(), ARGS = list()) { if (missing(FUN)) FUN <- character() new("ProcessingStep", FUN = FUN, ARGS = ARGS) } .cat_fun <- function(x) { if (is.function(x)) "user-provided function" else x } #' @rdname ProcessingStep #' #' @exportMethod show setMethod("show", "ProcessingStep", function(object) { cat("Object of class \"", class(object), "\"\n", sep = "") cat(" Function: ", .cat_fun(object@FUN), "\n", sep = "") args <- object@ARGS if (length(args) > 0) { cat(" Arguments:\n") for (i in seq_along(args)) { cat(" o ", names(args)[i], " = ", .cat_fun(args[[i]]), "\n", sep = "") } } }) #' @param object `ProcessingStep` object. #' #' @param ... optional additional arguments to be passed along. #' #' @rdname ProcessingStep #' #' @md #' #' @export executeProcessingStep <- function(object, ...) { if (!is(object, "ProcessingStep")) stop("'object' is supposed to be a 'ProcessingStep' object!") do.call(object@FUN, args = c(list(...), object@ARGS)) } ProtGenerics/R/protgenerics.R0000644000175200017520000002332314136050775017243 0ustar00biocbuildbiocbuild## ------------------------------------------------------------- ## Data slots ## ------------------------------------------------------------- setGeneric("processingData", function(object, ...) standardGeneric("processingData")) setGeneric("processingData<-", function(object, ..., value) standardGeneric("processingData<-")) setGeneric("spectraVariables", function(object, ...) standardGeneric("spectraVariables")) setGeneric("spectraNames", function(object, ...) standardGeneric("spectraNames")) setGeneric("spectraNames<-", function(object, ..., value) standardGeneric("spectraNames<-")) setGeneric("spectraData", function(object, ...) standardGeneric("spectraData")) setGeneric("spectraData<-", function(object, ..., value) standardGeneric("spectraData<-")) setGeneric("dataOrigin", function(object, ...) standardGeneric("dataOrigin")) setGeneric("dataOrigin<-", function(object, value) standardGeneric("dataOrigin<-")) setGeneric("dataStorage", function(object, ...) standardGeneric("dataStorage")) setGeneric("dataStorage<-", function(object, value) standardGeneric("dataStorage<-")) ## ------------------------------------------------------------- ## Metadata ## ------------------------------------------------------------- setGeneric("ionCount", function(object, ...) standardGeneric("ionCount")) setGeneric("scanIndex", function(object, ...) standardGeneric("scanIndex")) setGeneric("precursorMz", function(object, ...) standardGeneric("precursorMz")) setGeneric("precursorMz<-", function(object, ..., value) standardGeneric("precursorMz<-")) setGeneric("precursorIntensity", function(object, ...) standardGeneric("precursorIntensity")) setGeneric("precursorIntensity<-", function(object, ..., value) standardGeneric("precursorIntensity<-")) setGeneric("precursorCharge", function(object, ...) standardGeneric("precursorCharge")) setGeneric("precursorCharge<-", function(object, ..., value) standardGeneric("precursorCharge<-")) setGeneric("acquisitionNum", function(object, ...) standardGeneric("acquisitionNum")) setGeneric("precAcquisitionNum", function(object, ...) standardGeneric("precAcquisitionNum")) setGeneric("precScanNum", function(object, ...) standardGeneric("precScanNum")) setGeneric("msLevel", function(object, ...) standardGeneric("msLevel")) setGeneric("msLevel<-", function(object, ..., value) standardGeneric("msLevel<-")) setGeneric("uniqueMsLevel", function(object, ...) standardGeneric("uniqueMsLevel")) setGeneric("collisionEnergy", function(object, ...) standardGeneric("collisionEnergy")) setGeneric("collisionEnergy<-", function(object, ..., value) standardGeneric("collisionEnergy<-")) setGeneric("polarity", function(object, ...) standardGeneric("polarity")) setGeneric("polarity<-", function(object, ..., value) standardGeneric("polarity<-")) setGeneric("tic", function(object, ...) standardGeneric("tic")) setGeneric("rtime", function(object, ...) standardGeneric("rtime")) setGeneric("rtime<-", function(object, ..., value) standardGeneric("rtime<-")) setGeneric("centroided", function(object, ...) standardGeneric("centroided")) setGeneric("centroided<-", function(object, ..., value) standardGeneric("centroided<-")) setGeneric("smoothed", function(object) standardGeneric("smoothed")) setGeneric("smoothed<-", function(object, ..., value) standardGeneric("smoothed<-")) setGeneric("isCentroided", function(object, ...) standardGeneric("isCentroided")) setGeneric("isolationWindowTargetMz", function(object, ...) standardGeneric("isolationWindowTargetMz")) setGeneric("isolationWindowTargetMz<-", function(object, ..., value) standardGeneric("isolationWindowTargetMz<-")) setGeneric("isolationWindowLowerMz", function(object, ...) standardGeneric("isolationWindowLowerMz")) setGeneric("isolationWindowLowerMz<-", function(object, ..., value) standardGeneric("isolationWindowLowerMz<-")) setGeneric("isolationWindowUpperMz", function(object, ...) standardGeneric("isolationWindowUpperMz")) setGeneric("isolationWindowUpperMz<-", function(object, ..., value) standardGeneric("isolationWindowUpperMz<-")) setGeneric("productMz", function(object, ...) standardGeneric("productMz")) setGeneric("productMz<-", function(object, ..., value) standardGeneric("productMz<-")) setGeneric("compounds", function(object, ...) standardGeneric("compounds")) ## ------------------------------------------------------------- ## Raw data ## ------------------------------------------------------------- setGeneric("peaks", function(object, ...) standardGeneric("peaks")) setGeneric("peaks<-", function(object, ..., value) standardGeneric("peaks<-")) setGeneric("intensity", function(object, ...) standardGeneric("intensity")) setGeneric("intensity<-", function(object, ..., value) standardGeneric("intensity<-")) setGeneric("mz", function(object, ...) standardGeneric("mz")) setGeneric("mz<-", function(object, ..., value) standardGeneric("mz<-")) setGeneric("spectra", function(object, ...) standardGeneric("spectra")) setGeneric("spectra<-", function(object, ..., value) standardGeneric("spectra<-")) setGeneric("scans", function(object, ...) standardGeneric("scans")) setGeneric("chromatograms", function(object, ...) standardGeneric("chromatograms")) setGeneric("chromatogram", function(object, ...) standardGeneric("chromatogram")) setGeneric("mass", function(object, ...) standardGeneric("mass")) setGeneric("ions", function(object, ...) standardGeneric("ions")) ## ------------------------------------------------------------- ## Identification ## ------------------------------------------------------------- setGeneric("modifications", function(object, ...) standardGeneric("modifications")) setGeneric("database", function(object, ...) standardGeneric("database")) setGeneric("psms", function(object, ...) standardGeneric("psms")) setGeneric("peptides", function(object, ...) standardGeneric("peptides")) setGeneric("proteins", function(object, ...) standardGeneric("proteins")) setGeneric("accessions", function(object, ...) standardGeneric("accessions")) setGeneric("tolerance", function(object, ...) standardGeneric("tolerance")) setGeneric("calculateFragments", function(sequence, object, ...) standardGeneric("calculateFragments")) ## ------------------------------------------------------------- ## Instrument ## ------------------------------------------------------------- setGeneric("msInfo", function(object) standardGeneric("msInfo")) setGeneric("expemail", function(object) standardGeneric("expemail")) setGeneric("exptitle", function(object) standardGeneric("exptitle")) setGeneric("ionSource", function(object) standardGeneric("ionSource")) setGeneric("ionSourceDetails", function(object) standardGeneric("ionSourceDetails")) setGeneric("analyser", function(object) standardGeneric("analyser")) setGeneric("analyzer", function(object) standardGeneric("analyzer")) setGeneric("analyzerDetails", function(object) standardGeneric("analyzerDetails")) setGeneric("analyserDetails", function(object) standardGeneric("analyserDetails")) setGeneric("detectorType", function(object) standardGeneric("detectorType")) setGeneric("instrumentManufacturer", function(object) standardGeneric("instrumentManufacturer")) setGeneric("instrumentCustomisations", function(object) standardGeneric("instrumentCustomisations")) setGeneric("instrumentModel", function(object) standardGeneric("instrumentModel")) ## ------------------------------------------------------------- ## Data-processing ## ------------------------------------------------------------- setGeneric("smooth", function(x, ...) standardGeneric("smooth")) ## stats::smooth already exists setGeneric("combineFeatures", function(object, ...) standardGeneric("combineFeatures")) setGeneric("aggregateFeatures", function(object, ...) standardGeneric("aggregateFeatures")) setGeneric("impute", function(object, ...) standardGeneric("impute")) setGeneric("alignRt", function(x, y, ...) standardGeneric("alignRt")) setGeneric("quantify", function(object, ...) standardGeneric("quantify")) setGeneric("bin", function(x, ...) standardGeneric("bin")) setGeneric("compareSpectra", function(x, y, ...) standardGeneric("compareSpectra")) setGeneric("compareChromatograms", function(x, y, ...) standardGeneric("compareChromatograms")) ## ------------------------------------------------------------- ## IO ## ------------------------------------------------------------- setGeneric("writeMSData", function(object, file, ...) standardGeneric("writeMSData")) ## ------------------------------------------------------------- ## Filtering ## ------------------------------------------------------------- setGeneric("filterAcquisitionNum", function(object, ...) standardGeneric("filterAcquisitionNum")) setGeneric("filterDataOrigin", function(object, ...) standardGeneric("filterDataOrigin")) setGeneric("filterDataStorage", function(object, ...) standardGeneric("filterDataStorage")) setGeneric("filterEmptySpectra", function(object, ...) standardGeneric("filterEmptySpectra")) setGeneric("filterIsolationWindow", function(object, ...) standardGeneric("filterIsolationWindow")) setGeneric("filterMsLevel", function(object, ...) standardGeneric("filterMsLevel")) setGeneric("filterPolarity", function(object, ...) standardGeneric("filterPolarity")) setGeneric("filterPrecursorMz", function(object, ...) standardGeneric("filterPrecursorMz")) setGeneric("filterPrecursorCharge", function(object, ...) standardGeneric("filterPrecursorCharge")) setGeneric("filterProductMz", function(object, ...) standardGeneric("filterProductMz")) setGeneric("filterPrecursorScan", function(object, ...) standardGeneric("filterPrecursorScan")) setGeneric("filterRt", function(object, ...) standardGeneric("filterRt")) setGeneric("filterMz", function(object, ...) standardGeneric("filterMz")) setGeneric("filterNA", function(object, ...) standardGeneric("filterNA")) setGeneric("filterIntensity", function(object, ...) standardGeneric("filterIntensity")) ProtGenerics/README.md0000644000175200017520000001643714136050775015502 0ustar00biocbuildbiocbuild # Generic infrastructure for Bioconductor mass spectrometry packages ## Description: These generic functions and classes provide basic interfaces to operations on and data access to mass spectrometry infrastructure in the Bioconductor project. For the details, please consult the respective methods' manual pages. ## Usage: ```r psms(object, ...) peaks(object, ...) modifications(object, ...) database(object, ...) rtime(object, ...) tic(object, ...) spectra(object, ...) intensity(object, ...) mz(object, ...) peptides(object, ...) proteins(object, ...) accessions(object, ...) scans(object, ...) mass(object, ...) ions(object, ...) chromatograms(object, ...) chromatogram(object, ...) isCentroided(object, ...) ## and many more - see below ``` ## Arguments: - `object`: Object of class for which methods are defined. - `...`: Further arguments, possibly used by downstream methods. ## Details: ### When should one define a generics?: Generics are appropriate for functions that have _generic_ names, i.e. names that occur in multiple circumstances, (with different input classes, most often defined in different packages) or, when (multiple) dispatching is better handled by the generics mechanism rather than the developer. The dispatching mechanism will then automatically call the appropriate method and save the user from explicitly calling `package::method` or the developer to handle the multiple input types cases. When no such conflict exists or is unlikely to happen (for example when the name of the function is specific to a package or domain, or for class slots accessors and replacement methods), the usage of a generic is arguably questionable, and in most of these cases, simple, straightforward functions would be perfectly valid. ### When to define a generic in `ProtGenerics`?: `ProtGenerics` is not meant to be the central package for generics, nor should it stop developers from defining the generics they need. It is a means to centralise generics that are defined in different packages (for example `mzR::psms` and `mzID::psms`, or `IRanges::score` and `mzR::score`, now `BioGenerics::score`) or generics that live in a rather big package (say `mzR`) on which one wouldn't want to depend just for the sake of that generics' definition. The goal of `ProtGenerics` is to step in when namespace conflicts arise so as to to facilitate inter-operability of packages. In case such conflict appears due to multiple generics, we would (1) add these same definitions in `ProtGenerics`, (2) remove the definitions from the packages they stem from, which then (3) only need to import `ProtGenerics`. This would be very minor/straightforward changes for the developers and would resolve issues when they arise. More generics can be added on request by opening an issue or sending a pull request on: [https://github.com/lgatto/ProtGenerics](https://github.com/lgatto/ProtGenerics) ## See Also: - The `BiocGenerics` package for S4 generic functions needed by many Bioconductor packages. - `showMethods` for displaying a summary of the methods defined for a given generic function. - `selectMethod` for getting the definition of a specific method. - `setGeneric` and `setMethod` for defining generics and methods. ## Examples: ```r library("ProtGenerics") ## ## Attaching package: 'ProtGenerics' ## The following object is masked from 'package:stats': ## ## smooth ## List all the symbols defined in this package: ls('package:ProtGenerics') ## [1] "accessions" "acquisitionNum" ## [3] "aggregateFeatures" "alignRt" ## [5] "analyser" "analyserDetails" ## [7] "analyzer" "analyzerDetails" ## [9] "as.list" "bin" ## [11] "calculateFragments" "centroided" ## [13] "centroided<-" "chromatogram" ## [15] "chromatograms" "collisionEnergy" ## [17] "collisionEnergy<-" "combineFeatures" ## [19] "compareChromatograms" "compareSpectra" ## [21] "compounds" "database" ## [23] "dataOrigin" "dataOrigin<-" ## [25] "dataStorage" "dataStorage<-" ## [27] "detectorType" "executeProcessingStep" ## [29] "expemail" "exptitle" ## [31] "filterAcquisitionNum" "filterDataOrigin" ## [33] "filterDataStorage" "filterEmptySpectra" ## [35] "filterIntensity" "filterIsolationWindow" ## [37] "filterMsLevel" "filterMz" ## [39] "filterNA" "filterPolarity" ## [41] "filterPrecursorCharge" "filterPrecursorMz" ## [43] "filterPrecursorScan" "filterProductMz" ## [45] "filterRt" "impute" ## [47] "instrumentCustomisations" "instrumentManufacturer" ## [49] "instrumentModel" "intensity" ## [51] "intensity<-" "ionCount" ## [53] "ions" "ionSource" ## [55] "ionSourceDetails" "isCentroided" ## [57] "isolationWindowLowerMz" "isolationWindowLowerMz<-" ## [59] "isolationWindowTargetMz" "isolationWindowTargetMz<-" ## [61] "isolationWindowUpperMz" "isolationWindowUpperMz<-" ## [63] "mass" "modifications" ## [65] "msInfo" "msLevel" ## [67] "msLevel<-" "mz" ## [69] "mz<-" "peaks" ## [71] "peaks<-" "peptides" ## [73] "polarity" "polarity<-" ## [75] "precAcquisitionNum" "precScanNum" ## [77] "precursorCharge" "precursorCharge<-" ## [79] "precursorIntensity" "precursorIntensity<-" ## [81] "precursorMz" "precursorMz<-" ## [83] "processingData" "processingData<-" ## [85] "ProcessingStep" "productMz" ## [87] "productMz<-" "proteins" ## [89] "psms" "quantify" ## [91] "rtime" "rtime<-" ## [93] "scanIndex" "scans" ## [95] "smooth" "smoothed" ## [97] "smoothed<-" "spectra" ## [99] "spectra<-" "spectraData" ## [ reached getOption("max.print") -- omitted 8 entries ] library("mzR") ## Loading required package: Rcpp ## What methods exists for 'peaks' showMethods("peaks") ## Function: peaks (package ProtGenerics) ## object="mzRnetCDF" ## object="mzRpwiz" ## object="mzRramp" ## To look at one method in particular getMethod("peaks", "mzRpwiz") ## Method Definition: ## ## function (object, ...) ## { ## .local <- function (object, scans) ## .peaks(object, scans) ## .local(object, ...) ## } ## ## ## ## Signatures: ## object ## target "mzRpwiz" ## defined "mzRpwiz" ``` ProtGenerics/man/0000755000175200017520000000000014136050775014763 5ustar00biocbuildbiocbuildProtGenerics/man/Param.Rd0000644000175200017520000000177514136050775016324 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/DataClasses.R \docType{class} \name{Param} \alias{Param} \alias{Param-class} \alias{as.list,Param-method} \alias{show,Param-method} \title{Generic parameter class} \usage{ \S4method{as.list}{Param}(x, ...) \S4method{show}{Param}(object) } \arguments{ \item{x}{`Param` object.} \item{...}{ignored.} \item{object}{`Param` object.} } \description{ The `Param` class is a virtual class which can be used as *base* class from which *parameter* classes can inherit. The methods implemented for the `Param` class are: - `as.list`: coerces the `Param` class to a `list` with list elements representing the object's slot values, names the slot names. *Hidden* slots (i.e. those with a name starting with `.`) are not returned. In addition, a `Param` class can be coerced to a `list` using `as(object, "list")`. - `show`: prints the content of the `Param` object (i.e. the individual slots and their value). } \author{ Johannes Rainer } ProtGenerics/man/ProcessingStep.Rd0000644000175200017520000000302014136050775020215 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ProcessingStep.R \name{ProcessingStep} \alias{ProcessingStep} \alias{ProcessingStep-class} \alias{characterOrFunction-class} \alias{show,ProcessingStep-method} \alias{executeProcessingStep} \title{Processing step} \usage{ ProcessingStep(FUN = character(), ARGS = list()) \S4method{show}{ProcessingStep}(object) executeProcessingStep(object, ...) } \arguments{ \item{FUN}{\code{function} or \code{character} representing a function name.} \item{ARGS}{\code{list} of arguments to be passed along to \code{FUN}.} \item{object}{\code{ProcessingStep} object.} \item{...}{optional additional arguments to be passed along.} } \value{ The \code{ProcessingStep} function returns and object of type \code{ProcessingStep}. } \description{ Class containing the function and arguments to be applied in a lazy-execution framework. Objects of this class are created using the \code{ProcessingStep()} function. The processing step is executed with the \code{executeProcessingStep()} function. } \details{ This object contains all relevant information of a data analysis processing step, i.e. the function and all of its arguments to be applied to the data. This object is mainly used to record possible processing steps of a \code{Spectra} or \code{OnDiskMSnExp} object (from the \code{Spectra} and \code{MSnbase} packages, respectively). } \examples{ ## Create a simple processing step object ps <- ProcessingStep(sum) executeProcessingStep(ps, 1:10) } \author{ Johannes Rainer } ProtGenerics/man/protgenerics.Rd0000644000175200017520000001426714136050775017770 0ustar00biocbuildbiocbuild\name{ProtGenerics} \alias{ProtGenerics-package} \alias{ProtGenerics} \alias{psms} \alias{peaks} \alias{peaks<-} \alias{modifications} \alias{database} \alias{rtime} \alias{tic} \alias{spectra} \alias{spectra<-} \alias{ionCount} \alias{scanIndex} \alias{precursorMz} \alias{precursorIntensity} \alias{precursorCharge} \alias{precursorCharge<-} \alias{acquisitionNum} \alias{precAcquisitionNum} \alias{precScanNum} \alias{msLevel} \alias{uniqueMsLevel} \alias{collisionEnergy} \alias{polarity} \alias{intensity} \alias{mz} \alias{mz<-} \alias{combineFeatures} \alias{aggregateFeatures} \alias{impute} \alias{processingData} \alias{processingData<-} \alias{msInfo} \alias{expemail} \alias{exptitle} \alias{ionSource} \alias{ionSourceDetails} \alias{analyser} \alias{analyzer} \alias{analyzerDetails} \alias{analyserDetails} \alias{detectorType} \alias{instrumentManufacturer} \alias{instrumentCustomisations} \alias{smooth} \alias{centroided} \alias{centroided<-} \alias{smoothed} \alias{smoothed<-} \alias{instrumentModel} \alias{peptides} \alias{proteins} \alias{accessions} \alias{scans} \alias{mass} \alias{ions} \alias{chromatograms} \alias{chromatogram} \alias{isCentroided} \alias{writeMSData} \alias{isolationWindowTargetMz} \alias{isolationWindowTargetMz<-} \alias{isolationWindowLowerMz} \alias{isolationWindowLowerMz<-} \alias{isolationWindowUpperMz} \alias{isolationWindowUpperMz<-} \alias{intensity<-} \alias{precursorMz<-} \alias{precursorIntensity<-} \alias{msLevel<-} \alias{collisionEnergy<-} \alias{polarity<-} \alias{rtime<-} \alias{spectraNames} \alias{spectraNames<-} \alias{spectraData} \alias{spectraData<-} \alias{spectraVariables} \alias{dataOrigin} \alias{dataOrigin<-} \alias{dataStorage} \alias{dataStorage<-} \alias{productMz} \alias{productMz<-} \alias{filterAcquisitionNum} \alias{filterDataOrigin} \alias{filterDataStorage} \alias{filterEmptySpectra} \alias{filterIsolationWindow} \alias{filterMsLevel} \alias{filterPolarity} \alias{filterPrecursorMz} \alias{filterPrecursorCharge} \alias{filterProductMz} \alias{filterPrecursorScan} \alias{filterRt} \alias{filterMz} \alias{filterNA} \alias{tolerance} \alias{calculateFragments} \alias{compounds} \alias{filterIntensity} \alias{alignRt} \alias{quantify} \alias{bin} \alias{compareSpectra} \alias{compareChromatograms} \title{ S4 generic functions for Bioconductor proteomics infrastructure } \description{ These generic functions provide basic interfaces to operations on and data access to proteomics and mass spectrometry infrastructure in the Bioconductor project. For the details, please consult the respective methods' manual pages. } \details{ \subsection{When should one define a generics?}{ Generics are appropriate for functions that have \emph{generic} names, i.e. names that occur in multiple circumstances, (with different input classes, most often defined in different packages) or, when (multiple) dispatching is better handled by the generics mechanism rather than the developer. The dispatching mechanism will then automatically call the appropriate method and save the user from explicitly calling \code{package::method} or the developer to handle the multiple input types cases. When no such conflict exists or is unlikely to happen (for example when the name of the function is specific to a package or domain, or for class slots accessors and replacement methods), the usage of a generic is arguably questionable, and in most of these cases, simple, straightforward functions would be perfectly valid. } \subsection{When to define a generic in \code{ProtGenerics}?}{ \code{ProtGenerics} is not meant to be the central package for generics, nor should it stop developers from defining the generics they need. It is a means to centralise generics that are defined in different packages (for example \code{mzR::psms} and \code{mzID::psms}, or \code{IRanges::score} and \code{mzR::score}, now \code{BioGenerics::score}) or generics that live in a rather big package (say \code{mzR}) on which one wouldn't want to depend just for the sake of that generics' definition. The goal of \code{ProtGenerics} is to step in when namespace conflicts arise so as to to facilitate inter-operability of packages. In case such conflict appears due to multiple generics, we would (1) add these same definitions in \code{ProtGenerics}, (2) remove the definitions from the packages they stem from, which then (3) only need to import \code{ProtGenerics}. This would be very minor/straightforward changes for the developers and would resolve issues when they arise. More generics can be added on request by opening an issue or sending a pull request on: \url{https://github.com/lgatto/ProtGenerics} } } \usage{ psms(object, ...) peaks(object, ...) modifications(object, ...) database(object, ...) rtime(object, ...) tic(object, ...) spectra(object, ...) intensity(object, ...) mz(object, ...) peptides(object, ...) proteins(object, ...) accessions(object, ...) scans(object, ...) mass(object, ...) ions(object, ...) chromatograms(object, ...) chromatogram(object, ...) isCentroided(object, ...) writeMSData(object, file, ...) } \arguments{ \item{object}{Object of class for which methods are defined. } \item{file}{for \code{writeMSData}}: the name of the file to which the data should be exported. \item{\dots}{Further arguments, possibly used by downstream methods. } } \seealso{ \itemize{ \item The \pkg{BiocGenerics} package for S4 generic functions needed by many Bioconductor packages. \item \code{\link[methods]{showMethods}} for displaying a summary of the methods defined for a given generic function. \item \code{\link[methods]{selectMethod}} for getting the definition of a specific method. \item \code{\link[methods]{setGeneric}} and \code{\link[methods]{setMethod}} for defining generics and methods. } } \author{ Laurent Gatto } \examples{ ## List all the symbols defined in this package: ls('package:ProtGenerics') \dontrun{ ## What methods exists for 'peaks' showMethods("peaks") ## To look at one method in particular getMethod("peaks", "mzRpwiz") } } \keyword{methods} ProtGenerics/tests/0000755000175200017520000000000014136050775015352 5ustar00biocbuildbiocbuildProtGenerics/tests/testthat/0000755000175200017520000000000014136050775017212 5ustar00biocbuildbiocbuildProtGenerics/tests/testthat.R0000644000175200017520000000011014136050775017325 0ustar00biocbuildbiocbuildlibrary("testthat") library("ProtGenerics") test_check("ProtGenerics") ProtGenerics/tests/testthat/test_ProcessingStep.R0000644000175200017520000000231314136050775023343 0ustar00biocbuildbiocbuildtest_that("ProcessingStep constructor", { ps <- new("ProcessingStep", FUN = "mean", ARGS = list(na.rm = TRUE)) expect_match(capture.output(show(ps))[1], "Object of class \"ProcessingStep\"") expect_error(new("ProcessingStep", FUN = "aaaa")) ps <- ProcessingStep(mean, list(na.rm = TRUE)) expect_true(validObject(ps)) }) test_that("ProcessingStep executeProcessingStep", { ps <- ProcessingStep("sum", list(c(1, 4, 5))) expect_identical(executeProcessingStep(ps), 10) ps <- ProcessingStep("sum", list(c(1, 4, 5, NA))) ## Pass optional arguments to ... expect_identical(executeProcessingStep(ps, na.rm = TRUE), 10) }) test_that(".cat_fun works", { res <- .cat_fun("sum") expect_equal(res, "sum") res <- .cat_fun(sum) expect_equal(res, "user-provided function") }) test_that("show,ProcessingStep works", { ps <- ProcessingStep(sum, list(1:4)) expect_output(show(ps), "user-provided function") ps <- ProcessingStep(function(z) z + 4) expect_output(show(ps), "user-provided function") ps <- ProcessingStep("sum", list(a = sqrt)) expect_output(show(ps), "Function: sum") expect_output(show(ps), "a = user-provided function") })