def test_one_gzip_block(self): with self._open_bgzf_block(self._file_name, bgzf_io.Block(9287, 18988)) as file_to_read: self._validate_first_line_is_complete(file_to_read.readline()) lines = self._read_all_lines(file_to_read) self.assertEqual(len(lines), 43) self._validate_last_line_is_complete(lines[-1])
def test_block_size_larger_than_gcs_buffer(self): with self._open_bgzf_block(self._file_name, bgzf_io.Block(9287, 949900), read_buffer_size=64 * 1024) as file_to_read: file_to_read._read_size = 64 * 1024 lines = self._read_all_lines(file_to_read) self.assertEqual(len(lines), 425) self._validate_last_line_is_complete(lines[-1])
def test_merge_chunks(self): blocks = [bgzf_io.Block(start=0, end=100), bgzf_io.Block(start=90, end=99), bgzf_io.Block(start=100, end=150), bgzf_io.Block(start=120, end=201), bgzf_io.Block(start=201, end=300)] merged_blocks = bgzf_io._merge_blocks(blocks, size_limit=200) self.assertEqual(merged_blocks, [bgzf_io.Block(start=0, end=150), bgzf_io.Block(start=150, end=300)])
def test_remove_invalid_blocks(self): blocks = [bgzf_io.Block(start=5, end=5), bgzf_io.Block(start=3, end=9)] valid_blocks = bgzf_io._remove_invalid_blocks(blocks) self.assertEqual(valid_blocks, [bgzf_io.Block(start=3, end=9)])
def test_multiple_gzip_block(self): with self._open_bgzf_block(self._file_name, bgzf_io.Block(9287, 37595)) as file_to_read: lines = self._read_all_lines(file_to_read) self.assertEqual(len(lines), 52) self._validate_last_line_is_complete(lines[-1])