File: seeklzop_tests.py

package info (click to toggle)
python-bx 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,000 kB
  • sloc: python: 17,136; ansic: 2,326; makefile: 24; sh: 8
file content (25 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
T="/Users/james/cache/hg18/align/multiz28way/chr10.maf"
C="/Users/james/cache/hg18/align/multiz28way/chr10.maf.lzo"

def test():
    f = seeklzop.SeekableLzopFile( C, C + "t", block_cache_size=20 )
    for line in f:
        pass

def test_random_seeking():
    s = os.stat( T ).st_size
    raw = open( T )
    f = seeklzop.SeekableLzopFile( C, C + "t", block_cache_size=20 )
    for i in range( 1000 ):
        seek_to = random.randrange( s )

        f.seek( seek_to )
        raw.seek( seek_to )

        l1 = f.readline()
        l2 = raw.readline()

        assert l1 == l2, "%r != %r" % ( l1, l2 )
        assert raw.tell() == f.tell(), "tells not equal"
"""