Learning Scientific Programming with Python (2nd edition)

P2.4.5: DNA codons

Question P2.4.5

A DNA sequence encodes each amino acid making up a protein as a three-nucleotide sequence called a codon. For example, the sequence fragment AGTCTTATATCT contains the codons (AGT, CTT, ATA, TCT) if read from the first position ("frame''). If read in the second frame it yields the codons (GTC, TTA, TAT) and in the third (TCT, TAT, ATC).

Write some Python code to extract the codons into a list of 3-letter strings given a sequence and frame as an integer value (0, 1 or 2).