def format_alignment(align1, align2, score, begin, end):
    """Format the alignment prettily into a string.

    Since Biopython 1.71 identical matches are shown with a pipe
    character, mismatches as a dot, and gaps as a space.

    Note that spaces are also used at the start/end of a local
    alignment.

    Prior releases just used the pipe character to indicate the
    aligned region (matches, mismatches and gaps).
    """
    s = []
    s.append('%s\n' % align1)
    s.append(' ' * begin)
    for a, b in zip(align1[begin:end], align2[begin:end]):
        if a == b:
            s.append('|')
        elif a == '' or b == '':
            s.append(' ')
        else:
            s.append('.')
    s.append('\n')
    s.append('%s\n' % align2)
    s.append('  Score=%g\n' % score)
    return ''.join(s)
