예제 #1
0
def mafIsHardExtracted(name, outblocks, maf):
    blockSet = set()
    for b in outblocks:
        blockSet.add(b.hashify())
    f = open(maf)
    lastLine = mtt.processHeader(f)
    r = mtt.extractBlockStr(f, lastLine)
    observedBlocks = set()
    while r is not None:
        b = rawBlockToObj(r)
        if b is not None:
            if b.hashify() not in blockSet:
                print '\n[%s]' % name
                print 'dang, hashed output contains'
                print b.hashify()
                print 'not in hashed expected output'
                print blockSet
                f.close()
                return False
            else:
                observedBlocks.add(b.hashify())
        r = mtt.extractBlockStr(f)
    for b in blockSet:
        if b not in observedBlocks:
            print '\n[%s]' % name
            print 'dang, expected hashed output block'
            print b
            print 'not observed in hashed output blocks'
            for block in observedBlocks:
                print block
            f.close()
            return False
    f.close()        
    return True
예제 #2
0
def mafIsSorted(maf):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    observedNonTargetBlocks = []
    expectedNonTargetBlocks = list(g_nonTargetBlocks)
    for i in xrange(0, len(expectedNonTargetBlocks)):
        observedNonTargetBlocks.append(mtt.extractBlockStr(f, lastLine).replace(" ", ""))
        lastLine = None
        expectedNonTargetBlocks[i] = expectedNonTargetBlocks[i].replace(" ", "")
    if observedNonTargetBlocks != expectedNonTargetBlocks:
        f.close()
        print "\nnon-target block failure observed:"
        print "".join(observedNonTargetBlocks)
        print "!= expected:"
        print "".join(expectedNonTargetBlocks)
        return False
    sortedBlocks = []
    expectedTargetBlocks = list(g_targetBlocks)
    for i in xrange(0, len(expectedTargetBlocks)):
        sortedBlocks.append(mtt.extractBlockStr(f).replace(" ", ""))
        expectedTargetBlocks[i] = expectedTargetBlocks[i].replace(" ", "")
    for i in xrange(0, len(sortedBlocks)):
        if sortedBlocks[i] != expectedTargetBlocks[i]:
            f.close()
            print "\nsorted block failure"
            print sortedBlocks[i]
            print "!="
            print expectedTargetBlocks[i]
            print "observed "
            print sortedBlocks
            print "!= expected "
            print expectedTargetBlocks
            return False
    f.close()
    return True
예제 #3
0
def mafIsExtracted(maf):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    for i in xrange(0, len(g_overlappingBlocks)):
        b = mtt.extractBlockStr(f, lastLine)
        lastLine = None
        if b not in g_overlappingBlocks:
            print 'dang'
            print b
            print '!='
            print g_overlappingBlocks
            return False
    return True
예제 #4
0
def mafIsExtracted(maf):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    for i in xrange(0, len(g_overlappingBlocks)):
        b = mtt.extractBlockStr(f, lastLine)
        lastLine = None
        if hashStr(b) not in g_overlappingBlocksHashed:
            print 'dang, block'
            print b
            print 'is not in set of expected output'
            print g_overlappingBlocks
            f.close()
            return False
    f.close()
    return True
def mafIsFiltered(maf, blockList):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    for i in xrange(0, len(blockList)):
        # walk through the maf, assessing the equivalence to the blockList items
        b = mtt.extractBlockStr(f, lastLine)
        lastLine = None
        if b != blockList[i]:
            print 'dang'
            print 'observed:'
            print b
            print '!='
            print 'expected:'
            print blockList[i]
            return False
    return True
def mafIsFiltered(maf, blockList):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    for i in xrange(0, len(blockList)):
        # walk through the maf, assessing the equivalence to the blockList items
        b = mtt.extractBlockStr(f, lastLine)
        lastLine = None
        if b != blockList[i]:
            print 'dang'
            print 'observed:'
            print b
            print '!='
            print 'expected:'
            print blockList[i]
            return False
    return True
예제 #7
0
def mafIsCoerced(filename, expected):
    f = open(filename)
    lastLine = mtt.processHeader(f)
    # walk through the maf, assessing the equivalence to the blockList items
    b = mtt.extractBlockStr(f, lastLine)
    maf = ''
    while (b is not None):
        lastLine = None
        maf += b
        b = mtt.extractBlockStr(f, lastLine)
    if hashify(maf) != hashify(expected):
        print '\ndang'
        print 'observed:'
        print maf
        print '!='
        print 'expected:'
        print expected
        return False
    return True
def mafIsCorrect(filename, expected):
    f = open(filename)
    lastLine = mtt.processHeader(f)
    # walk through the maf, assessing the equivalence to the blockList items
    b = mtt.extractBlockStr(f, lastLine)
    maf = ''
    while (b is not None):
        lastLine = None
        maf += b
        b = mtt.extractBlockStr(f, lastLine)
    if hashify(maf) != hashify(expected):
        print '\ndang'
        print 'observed:'
        print maf
        print '!='
        print 'expected:'
        print expected
        return False
    return True
예제 #9
0
def mafIsFiltered(filename, expected, header):
    f = open(filename)
    lastLine = mtt.processHeader(f)
    maf = ''
    b = mtt.extractBlockStr(f, lastLine)
    while (b is not None):
        lastLine = None
        maf += b
        b = mtt.extractBlockStr(f, lastLine)
    if maf != expected:
        print 'dang'
        print 'observed:'
        print maf
        print '!='
        print 'expected:'
        print expected
        f.close()
        return False
    f.close()
    return True
예제 #10
0
def mafIsOrdered(filename, expected, header):
    f = open(filename)
    lastLine = mtt.processHeader(f)
    maf = ''
    b = mtt.extractBlockStr(f, lastLine)
    while (b is not None):
        lastLine = None
        maf += b
        b = mtt.extractBlockStr(f, lastLine)
    if hashify(maf) != hashify(expected):
        print 'dang'
        print 'observed:'
        print maf
        print '!='
        print 'expected:'
        print expected
        f.close()
        return False
    f.close()
    return True
def mafIsClosed(maf, outList):
    if not os.path.exists(maf):
        return False
    f = open(maf)
    lastLine = mtt.processHeader(f)
    block = mtt.extractBlockStr(f, lastLine)
    if block is None:
        return False
    while block is not None:
        lastLine = None
        block = block.strip()
        block = block.split('\n')
        block = block[1:]  # throw away alignment line
        for line in block:
            line = line.strip()
            if line == '':
                continue
            if line not in outList:
                return False
        block = mtt.extractBlockStr(f, lastLine)
    f.close()
    return True
def mafIsClosed(maf, outList):
    if not os.path.exists(maf):
        return False
    f = open(maf)
    lastLine = mtt.processHeader(f)
    block = mtt.extractBlockStr(f, lastLine)
    if block is None:
        return False
    while block is not None:
        lastLine = None
        block = block.strip()
        block = block.split('\n')
        block = block[1:] # throw away alignment line
        for line in block:
            line = line.strip()
            if line == '':
                continue
            if line not in outList:
                return False
        block = mtt.extractBlockStr(f, lastLine)
    f.close()
    return True
예제 #13
0
def mafIsSorted(maf):
    f = open(maf)
    lastLine = mtt.processHeader(f)
    observedNonTargetBlocks = []
    expectedNonTargetBlocks = list(g_nonTargetBlocks)
    for i in xrange(0, len(expectedNonTargetBlocks)):
        observedNonTargetBlocks.append(
            mtt.extractBlockStr(f, lastLine).replace(' ', ''))
        lastLine = None
        expectedNonTargetBlocks[i] = expectedNonTargetBlocks[i].replace(
            ' ', '')
    if observedNonTargetBlocks != expectedNonTargetBlocks:
        f.close()
        print '\nnon-target block failure observed:'
        print ''.join(observedNonTargetBlocks)
        print '!= expected:'
        print ''.join(expectedNonTargetBlocks)
        return False
    sortedBlocks = []
    expectedTargetBlocks = list(g_targetBlocks)
    for i in xrange(0, len(expectedTargetBlocks)):
        sortedBlocks.append(mtt.extractBlockStr(f).replace(' ', ''))
        expectedTargetBlocks[i] = expectedTargetBlocks[i].replace(' ', '')
    for i in xrange(0, len(sortedBlocks)):
        if sortedBlocks[i] != expectedTargetBlocks[i]:
            f.close()
            print '\nsorted block failure'
            print sortedBlocks[i]
            print '!='
            print expectedTargetBlocks[i]
            print 'observed '
            print sortedBlocks
            print '!= expected '
            print expectedTargetBlocks
            return False
    f.close()
    return True