1 | import seeklzop |
---|
2 | import os |
---|
3 | import random |
---|
4 | import sys |
---|
5 | |
---|
6 | """ |
---|
7 | T="/Users/james/cache/hg18/align/multiz28way/chr10.maf" |
---|
8 | C="/Users/james/cache/hg18/align/multiz28way/chr10.maf.lzo" |
---|
9 | |
---|
10 | def test(): |
---|
11 | f = seeklzop.SeekableLzopFile( C, C + "t", block_cache_size=20 ) |
---|
12 | for line in f: |
---|
13 | pass |
---|
14 | |
---|
15 | def test_random_seeking(): |
---|
16 | s = os.stat( T ).st_size |
---|
17 | raw = open( T ) |
---|
18 | f = seeklzop.SeekableLzopFile( C, C + "t", block_cache_size=20 ) |
---|
19 | for i in range( 1000 ): |
---|
20 | seek_to = random.randrange( s ) |
---|
21 | |
---|
22 | f.seek( seek_to ) |
---|
23 | raw.seek( seek_to ) |
---|
24 | |
---|
25 | l1 = f.readline() |
---|
26 | l2 = raw.readline() |
---|
27 | |
---|
28 | assert l1 == l2, "%r != %r" % ( l1, l2 ) |
---|
29 | assert raw.tell() == f.tell(), "tells not equal" |
---|
30 | """ |
---|