QualityScaledXStringSet-class {Biostrings} | R Documentation

## QualityScaledBStringSet, QualityScaledDNAStringSet, QualityScaledRNAStringSet and QualityScaledAAStringSet objects

### Description

The QualityScaledBStringSet class is a container for storing a `BStringSet` object with an `XStringQuality` object.

Similarly, the QualityScaledDNAStringSet (or QualityScaledRNAStringSet, or QualityScaledAAStringSet) class is a container for storing a `DNAStringSet` (or `RNAStringSet`, or `AAStringSet`) objects with an `XStringQuality` object.

### Usage

    ## Constructors:
    QualityScaledBStringSet(x, quality)
    QualityScaledDNAStringSet(x, quality)
    QualityScaledRNAStringSet(x, quality)
    QualityScaledAAStringSet(x, quality)

    ## Read/write a QualityScaledXStringSet object from/to a FASTQ file:
    readQualityScaledDNAStringSet(filepath,
                    quality.scoring=c("phred", "solexa", "illumina"),
                    nrec=-1L, skip=0L, seek.first.rec=FALSE,
                    use.names=TRUE)

    writeQualityScaledXStringSet(x, filepath, append=FALSE,
                    compress=FALSE, compression_level=NA)

### Arguments

`x` | For the `QualityScaled*StringSet` constructors: Either a character vector, or an XString, XStringSet or XStringViews object. For `writeQualityScaledXStringSet`: A QualityScaledDNAStringSet object or other QualityScaledXStringSet derivative.
`quality` | An XStringQuality derivative.
`filepath, nrec, skip, seek.first.rec, use.names, append, compress, compression_level` | See `?`XStringSet-io``.
`quality.scoring` | Specify the quality scoring used in the FASTQ file. Must be one of `"phred"` (the default), `"solexa"`, or `"illumina"`. If set to `"phred"` (or `"solexa"` or `"illumina"`), the qualities will be stored in a PhredQuality (or SolexaQuality or IlluminaQuality, respectively) object.

### Details

The `QualityScaledBStringSet`, `QualityScaledDNAStringSet`, `QualityScaledRNAStringSet` and `QualityScaledAAStringSet` functions are constructors that can be used to "naturally" turn `x` into an QualityScaledXStringSet object of the desired base type.

### Accessor methods

The QualityScaledXStringSet class derives from the XStringSet class hence all the accessor methods defined for an XStringSet object can also be used on an QualityScaledXStringSet object. Common methods include (in the code snippets below, `x` is an QualityScaledXStringSet object):

  `length(x)`: The number of sequences in `x`.

  `width(x)`: A vector of non-negative integers containing the number of letters for each element in `x`.

  `nchar(x)`: The same as `width(x)`.

  `names(x)`: `NULL` or a character vector of the same length as `x` containing a short user-provided description or comment for each element in `x`.

  `quality(x)`: The quality of the strings.

### Subsetting and appending

In the code snippets below, `x` and `values` are XStringSet objects, and `i` should be an index specifying the elements to extract.

  `x[i]`: Return a new QualityScaledXStringSet object made of the selected elements.

### Author(s)

P. Aboyoun

### See Also

- BStringSet, DNAStringSet, RNAStringSet, and AAStringSet objects.

- XStringQuality objects.

- `readDNAStringSet` and `writeXStringSet` for reading/writing a DNAStringSet object (or other XStringSet derivative) from/to a FASTA or FASTQ file.

### Examples

    ## ---------------------------------------------------------------------
    ## QualityScaled*StringSet() CONSTRUCTORS
    ## ---------------------------------------------------------------------

    x1 <- DNAStringSet(c("TTGA", "CTCN"))
    q1 <- PhredQuality(c("*+,-", "6789"))
    qdna1 <- QualityScaledDNAStringSet(x1, q1)
    qdna1

    ## ---------------------------------------------------------------------
    ## READ/WRITE A QualityScaledDNAStringSet OBJECT FROM/TO A FASTQ FILE
    ## ---------------------------------------------------------------------

    filepath <- system.file("extdata", "s_1_sequence.txt",
                            package="Biostrings")

    ## By default, readQualityScaledDNAStringSet() assumes that the FASTQ
    ## file contains "Phred quality scores" (this is the standard Sanger
    ## variant to assess reliability of a base call):
    qdna2 <- readQualityScaledDNAStringSet(filepath)
    qdna2

    outfile2a <- tempfile()
    writeQualityScaledXStringSet(qdna2, outfile2a)

    outfile2b <- tempfile()
    writeQualityScaledXStringSet(qdna2, outfile2b, compress=TRUE)

    ## Use 'quality.scoring="solexa"' or 'quality.scoring="illumina"' if the
    ## quality scores are Solexa quality scores:
    qdna3 <- readQualityScaledDNAStringSet(filepath, quality.scoring="solexa")
    qdna3

    outfile3a <- tempfile()
    writeQualityScaledXStringSet(qdna3, outfile3a)

    outfile3b <- tempfile()
    writeQualityScaledXStringSet(qdna3, outfile3b, compress=TRUE)

    ## Sanity checks:
    stopifnot(identical(readLines(outfile2a), readLines(filepath)))
    stopifnot(identical(readLines(outfile2a), readLines(outfile2b)))
    stopifnot(identical(readLines(outfile3a), readLines(filepath)))
    stopifnot(identical(readLines(outfile3a), readLines(outfile3b)))

[Package Biostrings version 2.56.0 Index]