R/is_dna_seq.R

Defines functions is_dna_seq

Documented in is_dna_seq

#' Determine if the string is a lowercase DNA sequence
#' of at least one base pair
#' @param s the string to be checked
#' @return TRUE if the string is a lowercase DNA sequence
#'   of at least one base pair
#' @author Richèl J.C. Bilderbeek
#' @examples
#'
#' # TRUE: valid and lowercase characters
#' is_dna_seq("acgt")
#'
#' # FALSE: Must be lowercase
#' is_dna_seq("AGCT")
#'
#' # FALSE: Must be only valid characters
#' is_dna_seq("xxxx")
#'
#' # FALSE: Must have at least one nucleotide
#' is_dna_seq("")
#' @export
is_dna_seq <- function(s) {
  stringr::str_match(s, "[acgt]*")[1, 1] != ""
}
richelbilderbeek/pirouette documentation built on Oct. 18, 2023, 3:09 p.m.