gunz_cm.compressions.bsc_decoder#
Module contents#
BSC Decoder wrapper for GZCM v3 compression.
Uses BSC CLI subprocess with LD_LIBRARY_PATH for libomp.
Examples
- class gunz_cm.compressions.bsc_decoder.BscDecoder(tile_size: int = 512, resolution: int = 50000, dtype: ~numpy.dtype = <class 'numpy.uint32'>, bsc_bin: str | pathlib.Path | None = None, ld_library_path: str | pathlib.Path | None = None)[source]#
Bases:
objectBSC decoder for contact matrix tiles.
Uses bsc CLI subprocess for true BSC (Block Sorting Compression) decompression.
- Parameters:
tile_size (int, default=512) – Tile size for block processing.
resolution (int, default=50000) – Hi-C resolution in bp.
dtype (np.dtype, default=np.uint32) – Data type for decoded tiles.
bsc_bin (str or pathlib.Path, optional) – Explicit path to the bsc binary. If None, resolved via GUNZ_CM_BSC_BIN env var or system PATH.
ld_library_path (str or pathlib.Path, optional) – Explicit LD_LIBRARY_PATH for the bsc subprocess. If None, resolved via GUNZ_CM_BSC_LD_LIBRARY_PATH env var.
Examples
- decode_tile(payload: bytes, shape: tuple[int, int] | None = None) ndarray[source]#
Decode a single BSC-compressed tile.
- Parameters:
payload (bytes) – BSC-compressed bitstream. When
shapeis provided (v3 GZCM path), the first 8 bytes encode(rows, cols)asnp.int32and are stripped before decompression. WhenshapeisNonethe payload is treated as raw compressed bytes (legacy / codec tests).shape (tuple of (int, int), optional) – Actual tile shape
(rows, cols). Required for edge tiles whererows != self.tile_sizeorcols != self.tile_size. IfNone, falls back to(self.tile_size, self.tile_size)and assumes no 8-byte header is present.
- Returns:
Decoded contact matrix tile with the requested shape.
- Return type:
np.ndarray
Examples