R/getCodons.R

Defines functions getCodons

Documented in getCodons

#' Get the codons of a RNA sequence
#'
#' @param rnaSequence
#' @param start
#'
#' @return codons
#' @export
#'
#' @examples
#' getCodons("AUGGACUGAUCGAUGU", start = 1)
#' [1] "AUG" "GAC" "UGA" "UCG" "AUG"
#'
getCodons <- function(rnaSequence, start = 1){
  rnaLength <- nchar(rnaSequence)
  codons <- substring(rnaSequence,
                      first = seq(from = start, to = rnaLength-3+1, by = 3),
                      last = seq(from = 3+start-1, to = rnaLength, by = 3))
  return(codons)
}
rforbiodatascience22/group_11_package documentation built on April 6, 2022, 11:19 a.m.