def bases_to_complete_previous_codon(phase):
    """
    Return the bases at exon start that completes the previous codon.

    >>> bases_to_complete_previous_codon(0) # e.g. -----XXX
    0
    >>> bases_to_complete_previous_codon(2) # e.g. XX-----X
    1
    >>> bases_to_complete_previous_codon(1) # e.g. X-----XX
    2
    """
    if phase == 0:
        return 0
    if phase == 1:
        return 2
    if phase == 2:
        return 1
    raise ValueError('Only phases 0, 1 and 2 are allowed.')
