Is there a function that takes an amino acid string and returns all biologically possible substitutions?
1
0
Entering edit mode
wilson_ava • 0
@b596fb38
Last seen 4 weeks ago
United States

A short example of what I am trying to accomplish:

Starting String: VSC

Potential AA substitutions:\ V to L/A\ S to T\ C to M

Output:ASC,LSC,ATC,LTC,ATM,LTM,VSM,VTM .... and other potential matches

I have thought about using expand.grid or another similar function, but I need more specificity for these substitutions. Ex: S should not be substituted for M.

Biostrings aminoacid motifbreakR • 419 views
ADD COMMENT
0
Entering edit mode
Aidan ▴ 40
@3efa9cc7
Last seen 4 days ago
United States

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?

ADD COMMENT

Login before adding your answer.

Traffic: 277 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6