def _get_exon_cds(exon_cdna_seq, cdna_coding_start, cdna_coding_end,
    first_exon, last_exon):
    """
    Return the CDS of the exon.

    This function takes the cDNA sequence of the exon and the
    coding start and end coordinates to cut the sequence and
    return the coding sequence (CDS) of the exon.
    """
    cdna_len = len(exon_cdna_seq)
    cds_len = cdna_coding_end - cdna_coding_start + 1
    if cds_len == cdna_len:
        return exon_cdna_seq
    if first_exon:
        return exon_cdna_seq[-cds_len:]
    if last_exon:
        return exon_cdna_seq[:cds_len]
    raise ValueError('exon has {} bases instead of {}'.format(cdna_len,
        cds_len))
