def alignment_string(aligned_seq1, aligned_seq2):
    """
    Construct a special string showing identities, gaps, and mismatches.
    This string is printed between the two aligned sequences and shows the
    identities (|), gaps (-), and mismatches (:). As the string is constructed,
    it also counts number of identities, gaps, and mismatches and returns the
    counts along with the alignment string.
    AAGGATGCCTCAAATCGATCT-TTTTCTTGG-
    ::||::::::||:|::::::: |:  :||:|   <-- alignment string
    CTGGTACTTGCAGAGAAGGGGGTA--ATTTGG
    """
    # Build the string as a list of characters to avoid costly string
    # concatenation.
    idents, gaps, mismatches = 0, 0, 0
    algnment_string = []
    for base1, base2 in zip(aligned_seq1, aligned_seq2):
        if base1 == base2:
            algnment_string.append('|')
            idents += 1
        elif '-' in (base1, base2):
            algnment_string.append(' ')
            gaps += 1
        else:
            algnment_string.append(':')
            mismatches += 1

    return ''.join(algnment_string), idents, gaps, mismatches