k = unique((nchar(ctx) - 1)/2)
stopifnot(k%%1 == 0)
simplify_ctx_any <- function(x, k, ref_set = c("TT", "CC", "CT", "TC")){
bigK = nchar(x)
cpl = bigK - (k*2)
# they are both inclusive
cpi = k + 1
cpe = k+cpl
cp_str = stringr::str_sub(x, cpi, cpe)
mask = cp_str %in% ref_set
Biostrings::DNAStringSet(x) %>% Biostrings::reverseComplement() %>%
as.character() -> rc
ifelse(mask,
x,
rc) -> result_simpl
return(result_simpl)
}
in the function
helperMut::simplify_ctxthen add this function: