calculate percent identity

def calc_pident_ignore_gaps(a, b):
    """
    calculate percent identity
    """
    m = 0 # matches
    mm = 0 # mismatches
    for A, B in zip(list(a), list(b)):
        if A == '-' or A == '.' or B == '-' or B == '.':
            continue
        if A == B:
            m += 1
        else:
            mm += 1
    try:
        return float(float(m)/float((m + mm))) * 100
    except:
        return 0