Sorry for the slow response, I was on vacation.
As far as I'm aware, there isn't a function to do this in Biostrings, but it should be pretty simple to do on your own using expand.grid
and a lookup table. For example, using your inputs:
make_possible_subs <- function(aa,mapping){
split_val <- strsplit(aa, '')[[1]]
expand.grid(mapping[split_val]) |> apply(1L, paste, collapse='')
}
test <- "VSC"
lookup_map <- list(
V=c("V","L","A"),
S=c("S","T"),
C=c("C","M")
)
make_possible_subs(test, lookup_map)
## Output:
## [1] "VSC" "LSC" "ASC" "VTC" "LTC" "ATC" "VSM" "LSM" "ASM" "VTM" "LTM" "ATM"
If you need it as an AAString
, you could just pipe the apply
call to AAStringSet
at the end.
Does that solution accomplish what you're looking for, or are there other restrictions to the problem that make this approach infeasible?