def conservedSegment(self, **kwargs):
        "calculate fractional identity for this pairwise alignment"
        start1 = self.sourcePath.start
        s1 = str(self.sourcePath).upper()
        start2 = self.targetPath.start
        s2 = str(self.targetPath).upper()
        i1 = None
        segment = []
        n = 0
        # Find unbroken identity segments.
        for srcPath, destPath in self.items():
            isrc = start1 - srcPath.start
            idest = destPath.start - start2
            for i in xrange(len(srcPath)):
                if s1[isrc + i] == s2[idest + i]: # EXACT MATCH
                    if i1 is None: # START NEW IDENTITY-SEGMENT
                        seg1, i1 = isrc + i, isrc + i
                        seg2, i2 = idest + i, idest + i
                    elif i1 + 1 != isrc + i or i2 + 1 != idest + i:
                        # Not contiguous, break.
                        segment.append((seg1 + start1, seg2 + start2,
                                        i1 + 1 - seg1, n))
                        n = 0 # RESET MISMATCH COUNT
                        seg1, i1 = isrc + i, isrc + i
                        seg2, i2 = idest + i, idest + i
                    else:
                        i1 = isrc + i
                        i2 = idest + i
                else: # MISMATCH
                    if i1 is not None: # BREAK PREVIOUS SEGMENT
                        segment.append((seg1 + start1, seg2 + start2,
                                        i1 + 1 - seg1, n))
                        i1 = None
                        n = 0 # RESET MISMATCH COUNT
                    n += 1 # COUNT MISMATCH
        if i1 is not None:
            segment.append((seg1 + start1, seg2 + start2, i1 + 1 - seg1, n))
        return self.longestSegment(segment, **kwargs)
dataset/ETHPy150Open cjlee112/pygr/pygr/sequence.py/Seq2SeqEdge.conservedSegment/swapped operands of `-`