Skip to content

Commit

Permalink
docs: add missing links and import extractByIndex from ProtGenerics
Browse files Browse the repository at this point in the history
  • Loading branch information
jorainer committed Jan 17, 2025
1 parent 1e59add commit 6e73d54
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 54 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MsBackendSql
Title: SQL-based Mass Spectrometry Data Backend
Version: 1.7.1
Version: 1.7.2
Authors@R:
c(person(given = "Johannes", family = "Rainer",
email = "Johannes.Rainer@eurac.edu",
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ importMethodsFrom(ProtGenerics,backendMerge)
importMethodsFrom(ProtGenerics,centroided)
importMethodsFrom(ProtGenerics,dataOrigin)
importMethodsFrom(ProtGenerics,dataStorage)
importMethodsFrom(ProtGenerics,extractByIndex)
importMethodsFrom(ProtGenerics,filterDataOrigin)
importMethodsFrom(ProtGenerics,filterMsLevel)
importMethodsFrom(ProtGenerics,filterPrecursorMzRange)
Expand All @@ -95,7 +96,6 @@ importMethodsFrom(ProtGenerics,spectraNames)
importMethodsFrom(ProtGenerics,tic)
importMethodsFrom(ProtGenerics,uniqueMsLevels)
importMethodsFrom(Spectra,backendBpparam)
importMethodsFrom(Spectra,extractByIndex)
importMethodsFrom(Spectra,reset)
importMethodsFrom(Spectra,show)
importMethodsFrom(Spectra,spectraData)
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# MsBackendSql 1.7

## Changes in 1.7.2

- Import `extractByIndex` from *ProtGenerics*.
- Add missing links in documentation.

## Changes in 1.7.1

- Complete unit tests to cover all code lines.
Expand Down Expand Up @@ -146,4 +151,4 @@

## Changes in 0.0.2

- First full implementation of `MsBackendSql`.
- First full implementation of `MsBackendSql`.
12 changes: 6 additions & 6 deletions R/MsBackendOfflineSql.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
#'
#' @param drv A *DBI* database driver object (such as `SQLite()` from the
#' `RSQLite` package or `MariaDB()` from the `RMariaDB` package). See
#' [dbConnect()] for more information.
#' [DBI::dbConnect()] for more information.
#'
#' @param dbname `character(1)` with the name of the database. Passed directly
#' to [dbConnect()].
#' to [DBI::dbConnect()].
#'
#' @param user `character(1)` with the user name for the database. Passed
#' directly to [dbConnect()].
#' directly to [DBI::dbConnect()].
#'
#' @param password `character(1)` with the password for the database. Note
#' that this password is stored (unencrypted) within the object. Passed
#' directly to [dbConnect()].
#' directly to [DBI::dbConnect()].
#'
#' @param host `character(1)` with the host running the database. Passed
#' directly to [dbConnect()].
#' directly to [DBI::dbConnect()].
#'
#' @param port `integer(1)` with the port number (optional). Passed directly to
#' [dbConnect()].
#' [DBI::dbConnect()].
#'
#' @param ... ignored.
#'
Expand Down
42 changes: 22 additions & 20 deletions R/MsBackendSql.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@
#'
#' @description
#'
#' The `MsBackendSql` is an implementation for the [MsBackend()] class for
#' [Spectra()] objects which stores and retrieves MS data from a SQL database.
#' New databases can be created from raw MS data files using
#' The `MsBackendSql` is an implementation for the [Spectra::MsBackend()] class
#' for [Spectra::Spectra()] objects which stores and retrieves MS data from a
#' SQL database. New databases can be created from raw MS data files using
#' `createMsBackendSqlDatabase()`.
#'
#' @details
#'
#' The `MsBackendSql` class is principally a *read-only* backend but by
#' extending the [MsBackendCached()] backend from the `Spectra` package it
#' allows changing and adding (**temporarily**) spectra variables **without**
#' changing the original data in the SQL database.
#' extending the [Spectra::MsBackendCached()] backend from the `Spectra`
#' package it allows changing and adding (**temporarily**) spectra variables
#' **without** changing the original data in the SQL database.
#'
#' @note
#'
#' The `MsBackendSql` backend keeps an (open) connection to the SQL database
#' with the data and hence does not support saving/loading of a backend to
#' disk (e.g. using `save` or `saveRDS`). Also, for the same reason, the
#' `MsBackendSql` does not support parallel processing. The `backendBpparam()`
#' method for `MsBackendSql` will thus always return a [SerialParam()] object.
#' method for `MsBackendSql` will thus always return a
#' [BiocParallel::SerialParam()] object.
#'
#' The [MsBackendOfflineSql()] could be used as an alternative as it supports
#' saving/loading the data to/from disk and supports also parallel processing.
Expand All @@ -53,7 +54,7 @@
#' `backendInitialize()` and providing all data with parameter `data`. In
#' addition it is possible to create a database from a `Spectra` object
#' changing its backend to a `MsBackendSql` or `MsBackendOfflineSql` using
#' the [setBackend()] function.
#' the [Spectra::setBackend()] function.
#' Existing SQL databases (created previously with
#' `createMsBackendSqlDatabase()` or `backendInitialize()` with the `data`
#' parameter) can be loaded using the *conventional* way to create/initialize
Expand Down Expand Up @@ -128,8 +129,9 @@
#' would return a `Spectra` object that uses a `MsBackendSql`).
#'
#' - `backendBpparam()`: whether a `MsBackendSql` supports parallel processing.
#' Takes a `MsBackendSql` and a parallel processing setup (see [bpparam()]
#' for details) as input and always returns a [SerialParam()] since
#' Takes a `MsBackendSql` and a parallel processing setup (see
#' [BiocParallel::bpparam()] for details) as input and always returns a
#' [BiocParallel::SerialParam()] since
#' `MsBackendSql` does **not** support parallel processing.
#'
#' - `dbconn()`: returns the connection to the database.
Expand All @@ -150,8 +152,8 @@
#' splitted using e.g. `split()`.
#'
#' In addition, `MsBackendSql` supports all other filtering methods available
#' through [MsBackendCached()]. Implementation of filter functions optimized
#' for `MsBackendSql` objects are:
#' through [Spectra::MsBackendCached()]. Implementation of filter functions
#' optimized for `MsBackendSql` objects are:
#'
#' - `filterDataOrigin()`: filter the object retaining spectra with `dataOrigin`
#' spectra variable values matching the provided ones with parameter
Expand Down Expand Up @@ -185,7 +187,7 @@
#' The functions listed here are specifically implemented for `MsBackendSql`.
#' In addition, `MsBackendSql` inherits and supports all data accessor,
#' filtering functions and data manipulation functions from
#' [MsBackendCached()].
#' [Spectra::MsBackendCached()].
#'
#' - `$`, `$<-`: access or set (add) spectra variables in `object`. Spectra
#' variables added or modified using the `$<-` are *cached* locally within
Expand Down Expand Up @@ -237,11 +239,11 @@
#' guarantees a minimal memory footpring of the object. Still, depending of
#' the number of spectra in the database, this `integer` vector might become
#' very large. Any data access will involve SQL calls to retrieve the data
#' from the database. By extending the [MsBackendCached()] object from the
#' `Spectra` package, the `MsBackendSql` supports to (temporarily, i.e. for
#' the duration of the R session) add or modify spectra variables. These are
#' however stored in a `data.frame` within the object thus increasing the
#' memory demand of the object.
#' from the database. By extending the [Spectra::MsBackendCached()] object
#' from the `Spectra` package, the `MsBackendSql` supports to (temporarily,
#' i.e. for the duration of the R session) add or modify spectra variables.
#' These are however stored in a `data.frame` within the object thus
#' increasing the memory demand of the object.
#'
#' @param backend For `createMsBackendSqlDatabase()`: MS backend that can be
#' used to import MS data from the raw files specified with
Expand All @@ -254,7 +256,7 @@
#' the default).
#'
#' @param BPPARAM for `backendBpparam()`: `BiocParallel` parallel processing
#' setup. See [bpparam()] for more information.
#' setup. See [BiocParallel::bpparam()] for more information.
#'
#' @param chunksize For `createMsBackendSqlDatabase()`: `integer(1)` defining
#' the number of input that should be processed per iteration. With
Expand Down Expand Up @@ -532,7 +534,7 @@ setMethod("[", "MsBackendSql", function(x, i, j, ..., drop = FALSE) {

#' @rdname MsBackendSql
#'
#' @importMethodsFrom Spectra extractByIndex
#' @importMethodsFrom ProtGenerics extractByIndex
#'
#' @export
setMethod("extractByIndex", c("MsBackendSql", "ANY"), function(object, i) {
Expand Down
12 changes: 6 additions & 6 deletions man/MsBackendOfflineSql.Rd

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

40 changes: 21 additions & 19 deletions man/MsBackendSql.Rd

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

9 changes: 9 additions & 0 deletions tests/testthat/test_MsBackendOfflineSql.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,12 @@ test_that("setBackend,Spectra,MsBackendOfflineSql works", {
expect_equal(msLevel(ref), msLevel(res))
unlink(dbf)
})

test_that("filterRt,MsBackendOfflineSql works properly", {
ref <- Spectra(c(mm14_file, mm8_file))
dbname_test <- tempfile()
res <- setBackend(ref, MsBackendOfflineSql(), drv = SQLite(),
dbname = dbname_test)
expect_output(show(ref), "MsBackendMzR")
expect_output(show(res), "MsBackendOfflineSql")
})

0 comments on commit 6e73d54

Please sign in to comment.