R/get_random_sequence.R

#' Creates many copies of a random DNA sequence of a prescribed length
#'
#' This uniformly chooses A, C, G or T at every position
#'
#' @param sequence_length The length of the sequence to be generated
#' @param n The number of copies of the random sequence to be returned
#' @return A list of characters (all the same) that are generated randomly
#' @export
get_random_sequence <- function(sequence_length, n = 1)
{
  return(rep(strsplit(
               # create a random DNA sequence
               stringi::stri_rand_strings(
                 1, sequence_length, pattern = "[TCAG]"),
               # split the string into nucleotides
               split = ""),
             # repeat the string n times
             n))
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.