def get_cds_from_fasta(feature, fasta):
    """
    Get the sequence of a CDS from a FASTA file using a GFF feature
    for the CDS.

    :param feature: GFF feature for the CDS
    :type feature: gffutils.feature.Feature
    :param fasta: FASTA genes
    :type fasta: pyfaidx.Fasta
    :return: sequence
    :rtype: str or unicode
    :raises AssertionError: If sequence has length not divisible by 3
    :raises Exception: Exceptions specific to \
    gffutils.Feature.sequence (these are undocumented in the \
    gffutils documentation - a typical exception that can be thrown \
    is ``KeyError`` which can arise if the GFF file contains \
    information on a sequence that is not in the FASTA file).
    """
    sequence = feature.sequence(fasta)
    assert (len(sequence) % 3) == 0, \
        "Feature {} ({}) has length not divisible by 3".format(
            feature.seqid, sequence)
    return sequence