def pIdentity(self, mode=max, trapOverflow=True):
        "calculate fractional identity for this pairwise alignment"
        nid = 0
        start1 = self.sourcePath.start
        s1 = str(self.sourcePath).upper()
        start2 = self.targetPath.start
        s2 = str(self.targetPath).upper()
        for srcPath, destPath in self.items():
            isrc = srcPath.start - start1
            idest = destPath.start - start2
            for i in xrange(len(srcPath)):
                if s1[isrc + i] == s2[idest + i]:
                    nid += 1
        x = nid / float(self.length(mode))
        if trapOverflow and x > 1.:
            raise ValueError('''pIdentity overflow due to multiple hits
                             (see docs)? To avoid this error message,
                             use trapOverflow=False option.''')
        return x
dataset/ETHPy150Open cjlee112/pygr/pygr/sequence.py/Seq2SeqEdge.pIdentity/original