I need to write an algorithm that generates random DNA sequences, without tandem repeats, but I don't know how to make the computer recognize these tandem repeats. Can anyone help me?
This is what I have so far, but it only deletes tandem repeats of length 2 (ex: CGATT ==> CGATA)
from random import randint
def generate_DNA(n):
alphabet = ['A','C','T','G']
seq = []
while len(seq) < n:
j = alphabet[randint(0,3)]
seq.append(j)
for i in range(1,len(seq)):
if seq[i] == seq[i-1]:
del seq[i]
return seq
print(generate_DNA(10))
Aucun commentaire:
Enregistrer un commentaire