File: test_repack.py

package info (click to toggle)
libvbz-hdf-plugin 1.0.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,384 kB
  • sloc: cpp: 28,289; python: 392; ansic: 40; sh: 21; makefile: 19; xml: 16
file content (40 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
import os
import sys

import unittest

TEST_DATA = os.path.join(os.path.dirname(__file__), "..", "..", "test_data")


class TestHDFRepack(unittest.TestCase):

    def test_simple_range(self):
        source_file = os.path.join(TEST_DATA, "multi_fast5_zip.fast5")
        dest_file_vbz = os.path.join(TEST_DATA, "multi_fast5_zip.fast5.repacked_vbz")
        dest_file_none = os.path.join(TEST_DATA, "multi_fast5_zip.fast5.repacked_none")

        result = subprocess.run([ 'h5repack', '-f', 'NONE', source_file, dest_file_none ],
            stdout=sys.stdout,
            stderr=sys.stderr
        )
        self.assertEqual(result.returncode, 0)

        result = subprocess.run([ 'h5repack', '-f', 'UD=32020,5,0,0,2,1,1', source_file, dest_file_vbz ],
            stdout=sys.stdout,
            stderr=sys.stderr
        )
        self.assertEqual(result.returncode, 0)

        uncompressed_bytes = os.stat(dest_file_none).st_size
        source_bytes = os.stat(source_file).st_size
        vbz_bytes = os.stat(dest_file_vbz).st_size
        print("Uncompressed file is %s bytes" 
            % uncompressed_bytes)
        print("Source file is %s bytes (%.0f%% of uncompressed)" 
            % (source_bytes, (source_bytes/uncompressed_bytes*100)))
        print("vbz file is %s bytes (%.0f%% of uncompressed, %.0f%% of source)" 
            % (vbz_bytes, (vbz_bytes/uncompressed_bytes*100), (vbz_bytes/source_bytes*100)))

if __name__ == '__main__':
    unittest.main()