def _fix_sequence(seq):
    """Returns string where terminal gaps are replaced with terminal CCA.
    
        Some of the sequence in the Genomic tRNA Database have gaps where the
        acceptor stem (terminal CCA) should be.  This function checks the
        number of terminal gaps and replaces with appropriate part of terminal
        CCA.
    """
    if seq.endswith('---'):
        seq = seq[:-3] + 'CCA'
    elif seq.endswith('--'):
        seq = seq[:-2] + 'CA'
    elif seq.endswith('-'):
        seq = seq[:-1] + 'A'
    return seq
