def testDel(string, i, c):
    fm = fmindex.createFM(string)
    before = fm.bwt
    fm.delBase(i)
    afterString = string[:i] + c + string[i:]
    afterfm = fmindex.FMindex(afterString)

    if afterfm.bwt == fm.bwt:
        output.extend(["PASS: "******" " + n.format(str(i))])
    else:
        output.extend(["FAIL: " + c + " " + n.format(str(i))])
    return fm
def main():
    string = sys.argv[1]
    if '$' in string:
        print "Don't include $ in genome"
        sys.exit(0)
    fm = fmindex.createFM(string)
    if fm.getInverse() != string:
        print "LF function does not correctly inverse BWT. Not equal", string, fm.getInverse()
        sys.exit(0)
    if len(sys.argv) == 4:
        fm = testIns(string, int(sys.argv[3]), sys.argv[2])
    else:
        stressTest(string)
def stressTest(string):
    numCorrect = 0
    numTotal = 0
    for i in range(0, len(string) - 1):
        for c in "ACGT":
            fm = fmindex.createFM(string)
            afterString = string[:i] + string[: i + 1]
            afterfm = fmindex.FMindex(afterString)
            fm = testDel(string, i, c)
            if afterfm.bwt == fm.bwt:
                numCorrect += 1
            numTotal += 1
    print "\n".join(output)
    print string
    print numCorrect, "PASS;", numTotal - numCorrect, "FAIL;", "SCORE:", float(numCorrect) / float(numTotal) * 100
示例#4
0
def stressTest(string): 
    numCorrect = 0
    numTotal = 0
    for i in range(0, len(string)):
        for c in "ACGT":
            fm = fmindex.createFM(string)
#            print "Testing i =", i, ", c =,", c
#            print "Before: T =", string +'$ ', "BWT =", fm.bwt
            afterString = string[:i] + c + string[i:]
            afterfm = fmindex.FMindex(afterString)
            fm = testIns(string, i, c)
            if afterfm.bwt == fm.bwt:
                numCorrect+=1
            numTotal+=1
    print '\n'.join(output)
    print string
    print  numCorrect,"PASS;",numTotal-numCorrect,"FAIL;","SCORE:",float(numCorrect)/float(numTotal)*100
示例#5
0
def testIns(string, i, c):
    fm = fmindex.createFM(string)
    before = fm.bwt
    fm.insBase(i, c)
    afterString = string[:i] + c + string[i:]
    afterfm = fmindex.FMindex(afterString)
    
    if afterfm.bwt == fm.bwt:
        output.extend(["PASS: "******" " + n.format(str(i))])
    else:
        output.extend(["FAIL: " + c + " " + n.format(str(i))])
    '''print "Correct result:", afterfm.bwt
    print "Actual results:", fm.bwt
    print " Actual | Correct"
    for j in range(len(afterfm.bwt)):
        correctResults=' '.join([str(afterfm.sa[j]),str(afterfm.isa[j]), sorted(afterfm.bwt)[j], afterfm.bwt[j]])
        if j >= len(fm.bwt):
            actualResults = "         |"
        else:
            actualResults=' '.join([str(fm.sa[j]),str(fm.isa[j]),sorted(fm.bwt)[j],fm.bwt[j], "|"])
        print actualResults, correctResults
    '''
    return fm
示例#6
0
	def setTemplate(self, genome):
		self.fm = fmindex.createFM(genome) #also fm.count, fm.occ, fm.sa
示例#7
0
	def __init__(self, genome):
		self.fm = fmindex.createFM(genome)