Make a silent mutation to the given codon list to remove the first instance 
    of the given bad sequence found in the gene sequence.  If the bad sequence 
    isn't found, nothing happens and the function returns false.  Otherwise the 
    function returns true.  You can use these return values to easily write a 
    loop totally purges the bad sequence from the codon list.  Both the 
    specific bad sequence in question and the list of all bad sequences are 
    expected to be regular expressions.

def remove_bad_sequence(codon_list, bad_seq, bad_seqs):
    """
    Make a silent mutation to the given codon list to remove the first instance 
    of the given bad sequence found in the gene sequence.  If the bad sequence 
    isn't found, nothing happens and the function returns false.  Otherwise the 
    function returns true.  You can use these return values to easily write a 
    loop totally purges the bad sequence from the codon list.  Both the 
    specific bad sequence in question and the list of all bad sequences are 
    expected to be regular expressions.
    """

    gene_seq = ''.join(codon_list)
    problem = bad_seq.search(gene_seq)

    if not problem:
        return False

    bs_start_codon = problem.start() // 3
    bs_end_codon = problem.end() // 3

    for i in range(bs_start_codon, bs_end_codon):
        problem_codon = codon_list[i]
        amino_acid = translate_dna(problem_codon)

        alternate_codons = [
                codon
                for codon in dna.ecoli_reverse_translate[amino_acid]
                if codon != problem_codon]

        for alternate_codon in alternate_codons:
            codon_list[i] = alternate_codon

            if problem_with_codon(i, codon_list, bad_seqs):
                codon_list[i] = problem_codon
            else:
                return True

    raise RuntimeError("Could not remove bad sequence '{}' from gene.".format(bs))