Skip to content

Commit

Permalink
Merge pull request #23 from jorainer/devel
Browse files Browse the repository at this point in the history
refactor: add extractByIndex method
  • Loading branch information
cpanse authored Oct 1, 2024
2 parents cc1c4f2 + 6cbef4c commit 8c8a65a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MsBackendRawFileReader
Type: Package
Title: Mass Spectrometry Backend for Reading Thermo Fisher Scientific raw Files
Version: 1.11.5
Version: 1.11.6
Authors@R: c(person(given = "Christian",
family = "Panse", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1975-3064")),
Expand All @@ -11,7 +11,7 @@ Authors@R: c(person(given = "Christian",
person(given = "Roger", family = "Gine Bertomeu",
email = "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0003-0288-9619")))
Depends: R (>= 4.1), methods, Spectra (>= 1.5.8)
Depends: R (>= 4.1), methods, Spectra (>= 1.15.10)
Imports:
ProtGenerics (>= 1.35.3),
MsCoreUtils,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(MsBackendRawFileReader)
export(ioBenchmark)
exportClasses(MsBackendRawFileReader)
exportMethods("[")
exportMethods(extractByIndex)
exportMethods(filterScan)
exportMethods(intensity)
exportMethods(mz)
Expand All @@ -30,3 +31,4 @@ importMethodsFrom(ProtGenerics,intensity)
importMethodsFrom(ProtGenerics,mz)
importMethodsFrom(ProtGenerics,peaksData)
importMethodsFrom(ProtGenerics,scanIndex)
importMethodsFrom(Spectra,extractByIndex)
7 changes: 1 addition & 6 deletions R/MsBackendRawFileReader-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ NULL
#' @importFrom S4Vectors extractROWS
#' @importFrom MsCoreUtils i2index
#' @importFrom methods slot<-
.subset_backend_MsBackendRawFileReader <- function(x, i) {
if (missing(i))
return(x)
idx <- i
i <- MsCoreUtils::i2index(i, length(x), rownames(x@spectraData))

.subset_backend_MsBackendRawFileReader <- function(x, i = integer()) {
slot(x, "spectraData", check = FALSE) <- S4Vectors::extractROWS(x@spectraData, i)

# check if item is complete otherwise retrieval of data through using
Expand Down
11 changes: 10 additions & 1 deletion R/MsBackendRawFileReader.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,18 @@ setMethod("peaksData", "MsBackendRawFileReader",
#' @importFrom IRanges NumericList
#' @exportMethod [
setMethod("[", "MsBackendRawFileReader", function(x, i, j, ..., drop = FALSE) {
.subset_backend_MsBackendRawFileReader(x, i)
i <- MsCoreUtils::i2index(i, length(x), rownames(x@spectraData))
extractByIndex(x, i)
})

#' @rdname hidden_aliases
#' @importMethodsFrom Spectra extractByIndex
#' @export
setMethod("extractByIndex", c("MsBackendRawFileReader", "ANY"),
function(object, i) {
.subset_backend_MsBackendRawFileReader(object, i)
})

#' @importClassesFrom IRanges NumericList
#' @rdname hidden_aliases
#' @importMethodsFrom ProtGenerics intensity
Expand Down
3 changes: 3 additions & 0 deletions man/hidden_aliases.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c8a65a

Please sign in to comment.