For some overall context, I have a set of probabilities for each type of 3 letter substring (64 combinations in total) in my sequence to change to another given 3 letter substring. I want to be able to apply these probabilities onto every 3 letter substring in my sequence and change them if the probability indicates that it should.
Essentially, I want to randomly change 3 letter substrings within a very large string to another 3 letter substring based on known probabilities.
For example:
I have a string.
'GACTCGTAGCTAGCTG'
I have some probabilities for the substring 'GAC'
{'GAC>GAT': 0.05, 'GAC>GAG': 0.01 'GAC>GAA':0.03}
In this case, I would have a 5% chance of 'GAC' in my string to change to 'GAT', 1% chance 'GAC' changes to 'GAG' and 3% change 'GAC' changes to 'GAA' . What is the most efficient way to apply these probabilities for each 3 letter substring in my giant string.