# This function converts a scalar string of quality values into a vector of Phred scores.
# The conversion calculation is: Phred score = ASCII value of letter - offset
#' Title Decodes a FastQ quality string into scores
#'
#' @param qualities A sfastq quality string
#' @param offset The Phred encoding offset value
#'
#' @return A numeric vector of Phred scores
#' @export
#'
#' @examples
decode_qualities <- function(qualities, offset=33) {
assertthat::assert_that(assertthat::is.scalar(qualities))
assertthat::assert_that(assertthat::is.string(qualities))
assertthat::assert_that(assertthat::is.scalar(offset))
assertthat::assert_that(assertthat::is.number(offset))
if (!(offset==33 | offset==64)) {
base::stop("Offset can only be 33 or 64")
}
as.integer(base::charToRaw(qualities)) - offset -> phred_scores
if (any(phred_scores < 1)) {
base::stop("Negative phred scores produced - check offset")
}
return(phred_scores)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.