def _print_first_difference(arec, brec, ignore_case=False, ignore_N=False,
         report_match=True):
    """
    Returns the first different nucleotide in two sequence comparisons
    """
    aseq, bseq = arec.seq, brec.seq
    asize, bsize = len(aseq), len(bseq)

    matched = True
    for i, (a, b) in enumerate(izip_longest(aseq, bseq)):
        if ignore_case and None not in (a, b):
            a, b = a.upper(), b.upper()

        if ignore_N and ('N' in (a, b) or (a, b) in 'X'):
            continue

        if a != b:
            matched = False
            break

    if i + 1 == asize and matched:
        if report_match:
            print green("Two sequences match")
        match = True
    else:
        print red("Two sequences do not match")

        snippet_size = 20  # show the context of the difference

        print red("Sequence start to differ at position %d:" % (i + 1))

        begin = max(i - snippet_size, 0)
        aend = min(i + snippet_size, asize)
        bend = min(i + snippet_size, bsize)

        print red(aseq[begin:i] + "|" + aseq[i:aend])
        print red(bseq[begin:i] + "|" + bseq[i:bend])
        match = False

    return match
dataset/ETHPy150Open tanghaibao/jcvi/formats/fasta.py/_print_first_difference/swapped operands of `in`