R/reverseCigar.R

Defines functions reverseCigar

Documented in reverseCigar

#'@title Reverses the order of operations in a cigar string
#'@description For example, the string "20M5D15M" would become "15M5D20M"
#'@param cigars the cigar strings.
#'@return The reversed cigar string
reverseCigar <- function(cigars){
  wdths <- explodeCigarOpLengths(cigars)
  ops <- explodeCigarOps(cigars)
  temp <- rev(relist(rev(paste0(unlist(wdths), unlist(ops))), rev(wdths)))
  result <- as.character(Map(base::paste, temp, collapse = ""))
}

Try the CrispRVariants package in your browser

Any scripts or data that you put into this service are public.

CrispRVariants documentation built on Nov. 8, 2020, 11:09 p.m.