def aai(seq1, seq2, threshold):
    """Determine AAI between sequences.

    The identify is only calculate across
    positions where both sequences have
    an amino acid. A threshold value is
    used to allow quick identification
    of highly similar sequences.

    Parameters
    ----------
    seq1 : str
        First sequence.
    seq2 : float
        Second sequence.
    threshold : float
        Minimum AAI required for reporting.

    Returns
    -------
    float
        AAI between sequences if it is greater than the
        specified threshold, else None.
    """
    assert len(seq1) == len(seq2)
    max_mismatches = (1.0 - threshold) * len(seq1)
    mismatches = 0
    matches = 0
    for c1, c2 in zip(seq1, seq2):
        if c1 == '-' or c2 == '-':
            continue
        elif c1 != c2:
            mismatches += 1
            if mismatches >= max_mismatches:
                return None
        else:
            matches += 1
    aai = float(matches) / max(1, matches + mismatches)
    if aai < threshold:
        return None
    return aai
