def apply_prot_to_nuc(aligned_prot, nuc):
    """
    Use aligned protein sequence to update the corresponding nucleotide
    sequence.
    :param aligned_prot:  str, aligned amino acid sequence
    :param nuc:  str, original nucleotide sequence
    :return: str, nucleotide sequence with codon gaps
    """
    res = ''
    i = 0
    for aa in aligned_prot:
        if aa == '-':
            res += '---'
            continue
        res += nuc[i:(i + 3)]
        i += 3
    return res