It's unclear where III comes from.
But maybe this can help:
(1) Create datastructure to hold sequences:
(2) Chunk DNA sequence:
But maybe this can help:
(1) Create datastructure to hold sequences:
amino_acids = {**dict.fromkeys(['ATT', 'ATC', 'ATA'], 'Isoleucine'), **dict.fromkeys(['CTT', 'CTC', 'CTA', 'CTG', 'TTA', 'TTG'], 'Leucine'), **dict.fromkeys(['GTT', 'GTC', 'GTA', 'GTG'], 'Valine'), **dict.fromkeys(['TTT', 'TTC'], 'Phenylalanine'), **dict.fromkeys(['ATG'], 'Methionine')}amino_acids is dictionary where DNA codon is key and value is corresponding amino acid:
# amino_acid {'ATT': 'Isoleucine', 'ATC': 'Isoleucine', 'ATA': 'Isoleucine', 'CTT': 'Leucine', 'CTC': 'Leucine', 'CTA': 'Leucine', 'CTG': 'Leucine', 'TTA': 'Leucine', 'TTG': 'Leucine', 'GTT': 'Valine', 'GTC': 'Valine', 'GTA': 'Valine', 'GTG': 'Valine', 'TTT': 'Phenylalanine', 'TTC': 'Phenylalanine', 'ATG': 'Methionine'}
(2) Chunk DNA sequence:
x = 3 dna = 'ATTCTTTTCATGCTCCTGTTACTAAA' chunks = [dna[y-x:y] for y in range(x, len(dna)+x, x) if len(dna[y-x:y]) == 3]Which nicely chops off trailing AA-s:
['ATT', 'CTT', 'TTC', 'ATG', 'CTC', 'CTG', 'TTA', 'CTA'](3) Iterate over chunks and replace sequence with amino acid:
>>> [amino_acids[sequence] for sequence in chunks] ['Isoleucine', 'Leucine', 'Phenylalanine', 'Methionine', 'Leucine', 'Leucine', 'Leucine', 'Leucine']
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.