SRUtil-class {ShortRead} | R Documentation

## ".SRUtil" and related classes

### Description

These classes provide important utility functions in the ShortRead package, but may occasionally be seen by the user and are documented here for that reason.

### Objects from the Class

Utility classes include:

- `.SRUtil-class` a virtual base class from which all utility classes are derived.

- `SRError-class` created when errors occur in ShortRead package code.

- `SRWarn-class` created when warnings occur in ShortRead package code

- `SRList-class` representing a list (heterogeneous collection) of objects. The S4Vectors::SimpleList class is a better choice for a list-like container.

- `SRVector-class` representing a vector (homogeneous collection, i.e., all elements of the same class) of objects.

Objects from these classes are not normally constructed by the user. However, constructors are available, as follows.

`SRError(type, fmt, ...)`, `SRWarn(type, fmt, ...)`:

type

  `character(1)` vector describing the type of the error. `type` must come from a pre-defined list of types.

fmt

  a `sprintf`-style format string for the message to be reported with the error.

...

  additional arguments to be interpolated into `fmt`.

`SRList(...)`

...

  elements of any type or length to be placed into the `SRList`. If the length of `...` is 1 and the argument is a list, then the list itself is placed into `SRList`.

`SRVector(..., vclass)`

...

  elements all satisfying an `is` relationship with `vclass`, to be placed in `SRVector`.

vclass

  the class to which all elements in `...` belong. If `vclass` is missing and `length(list(...))` is greater than zero, then `vclass` is taken to be the class of the first argument of `...`.

`SRVector` errors:

SRVectorClassDisagreement

  this error occurs when not all arguments `...` satisfy an ‘is’ relationship with `vclass`.

### Slots

`SRError` and `SRWarn` have the following slots defined:

`.type`:

  Object of class `"character"` containing the type of error or warning. `.type` must come from a pre-defined list of types, see, e.g., `ShortRead:::.SRError_types`.

`.message`:

  Object of class `"character"` containing a detailed message describing the error or warning.

`SRList` has the following slot defined:

`.srlist`:

  Object of class `"list"` containing the elements in the list.

`SRVector` extends `SRList`, with the following additional slot:

`vclass`:

  Object of class `"character"` naming the type of object all elements of `SRVector` must be.

### Methods

Accessors are available for all slots, and have the same name as the slot, e.g., `vclass` to access the `vclass` slot of `SRVector`. Internal slots (those starting with ‘.’ also have accessors, but these are not exported e.g., `ShortRead:::.type`.

`SRList` has the following methods:

length

  `signature(x = "SRList")`: return the (`integer(1)`) length of the `SRList`.

names

  `signature(x = "SRList")`: return a character vector of list element names. The length of the returned vector is the same as the length of `x`.

names<-

  `signature(x = "SRList", value = "character")`: assign `value` as names for members of `x`.

[

  `signature(x = "SRList", i = "ANY", j = "missing")`: subset the list using standard R list subset paradigms.

[[

  `signature(x = "SRList", i = "ANY", j = "missing")`: select element ‘i’ from the list, using standard R list selection paradigms.

lapply

  `signature(X = "SRList", FUN="ANY")`: apply a function to all elements of `X`, with additional arguments interpreted as with `lapply`.

sapply

  `signature(X = "SRList")`: apply a function to all elements of `X`, simplifying the result if possible. Additional arguments interpreted as with `sapply`.

srlist

  `signature(object="SRList")`: coerce the SRList object to a list.

show

  `signature(object = "SRList")`: display an informative summary of the object content, including the length of the list represented by `object`.

detail

  `signature(x = "SRList")`: display a more extensive version of the object, as one might expect from printing a standard list in R.

`SRVector` inherits all methods from `SRList`, and has the following additional methods:

show

  `signature(object = "SRVector")`: display an informative summary of the object content, e.g., the vector class (`vclass`) and length.

detail

  `signature(x = "SRVector")`: display a more extensive version of the object, as one might expect from a printing a standard R list.

### Author(s)

Martin Morgan

### Examples

    getClass(".SRUtil", where=getNamespace("ShortRead"))
    ShortRead:::.SRError_types
    ShortRead:::.SRWarn_types

    detail(SRList(1:5, letters[1:5]))

    tryCatch(SRVector(1:5, letters[1:5]),
             SRVectorClassDisagreement=function(err) {
                 cat("caught:", conditionMessage(err), "\n")
             })

[Package ShortRead version 1.50.0 Index]