コード例 #1
0
def test_interval_index_file():
    ix = Indexes()
    chrs = []
    for i in range( 5 ):
        intervals = []
        name = "seq%d" % i
        max = random.randint( 0, interval_index_file.MAX )
        # print name, "size", max
        for i in range( 500 ):
            start = random.randint( 0, max )
            end = random.randint( 0, max )
            if end < start:
                end, start = start, end
            ix.add( name, start, end, i, max=interval_index_file.MAX )
            intervals.append( ( start, end, i ) )
        chrs.append( intervals )
    fname = mktemp()
    f = open( fname, "w" )
    ix.write( f )
    f.close()
    del ix
    
    ix = Indexes( fname )
    for i in range( 5 ):
        intervals = chrs[i]
        name = "seq%d" % i
        for i in range( 100 ):
            start = random.randint( 0, max )
            end = random.randint( 0, max )
            if end < start:
                end, start = start, end
            query_intervals = set()
            for ( s, e, i ) in intervals:
                if e > start and s < end:
                    query_intervals.add( ( s, e, i ) )
            result = ix.find( name, start, end )
            for inter in result:
                assert inter in query_intervals
コード例 #2
0
def test_interval_index_file():
    ix = Indexes()
    chrs = []
    for i in range( 5 ):
        intervals = []
        name = "seq%d" % i
        max = random.randint( 0, interval_index_file.MAX )
        # print name, "size", max
        for i in range( 500 ):
            start = random.randint( 0, max )
            end = random.randint( 0, max )
            if end < start:
                end, start = start, end
            ix.add( name, start, end, i, max=interval_index_file.MAX )
            intervals.append( ( start, end, i ) )
        chrs.append( intervals )
    fname = mktemp()
    f = open( fname, "w" )
    ix.write( f )
    f.close()
    del ix
    
    ix = Indexes( fname )
    for i in range( 5 ):
        intervals = chrs[i]
        name = "seq%d" % i
        for i in range( 100 ):
            start = random.randint( 0, max )
            end = random.randint( 0, max )
            if end < start:
                end, start = start, end
            query_intervals = set()
            for ( s, e, i ) in intervals:
                if e > start and s < end:
                    query_intervals.add( ( s, e, i ) )
            result = ix.find( name, start, end )
            for inter in result:
                assert inter in query_intervals
コード例 #3
0
def test_zero():
    ix = Indexes()
    ix.add("t.idx", 0, 0, 1, 123)