I'm trying to test out changing certain bases in a DNA sequence, but the way I have it written now is mutating all the bases of the same kind (i.e.: all 'A's to 'G's) instead of only changing the bases within the section of DNA I want to mutate.
I know this is because of how I have my replace function input set up, but I'm not sure how to specify which base I want changed based on the for loop - whichever base is targeted in each iteration of the for loop is the only one I want to mutate within that iteration. Here's what I have currently:
import random
word = 'GTGATCCAGT'
for base in word[5:]:
print base
if base == 'A':
new_base = random.choice('CTG')
print new_base
new_word = word.replace(base, new_base)
print new_word
elif base == 'C':
new_base = random.choice('ATG')
print new_base
new_word = word.replace(base, new_base)
print new_word
elif base == 'G':
new_base = random.choice('CTA')
print new_base
new_word = word.replace(base, new_base)
print new_word
elif base == 'T':
new_base = random.choice('AGC')
print new_base
new_word = word.replace(base, new_base)
print new_word
word = new_word
Thank you!