Package htsjdk.samtools.util
Class BlockGunzipper
java.lang.Object
htsjdk.samtools.util.BlockGunzipper
Alternative to GZIPInputStream, for decompressing GZIP blocks that are already loaded into a byte[].
The main advantage is that this object can be used over and over again to decompress many blocks,
whereas a new GZIPInputStream and ByteArrayInputStream would otherwise need to be created for each
block to be decompressed.
This code requires that the GZIP header conform to the GZIP blocks written to BAM files, with
a specific subfield and no other optional stuff.
-
Method Summary
Modifier and TypeMethodDescriptionstatic InflaterFactory
void
setCheckCrcs
(boolean check) Allows the caller to decide whether or not to check CRCs on when uncompressing blocks.static void
setDefaultInflaterFactory
(InflaterFactory inflaterFactory) Sets the defaultInflaterFactory
that will be used for all instances unless specified otherwise in the constructor.int
unzipBlock
(byte[] uncompressedBlock, byte[] compressedBlock, int compressedLength) Decompress GZIP-compressed dataint
unzipBlock
(byte[] uncompressedBlock, int uncompressedBlockOffset, byte[] compressedBlock, int compressedBlockOffset, int compressedLength) Decompress GZIP-compressed data
-
Method Details
-
setDefaultInflaterFactory
Sets the defaultInflaterFactory
that will be used for all instances unless specified otherwise in the constructor. If this method is not called the default is a factory that will create the JDKInflater
.- Parameters:
inflaterFactory
- non-null default factory.
-
getDefaultInflaterFactory
-
setCheckCrcs
public void setCheckCrcs(boolean check) Allows the caller to decide whether or not to check CRCs on when uncompressing blocks. -
unzipBlock
public int unzipBlock(byte[] uncompressedBlock, byte[] compressedBlock, int compressedLength) Decompress GZIP-compressed data- Parameters:
uncompressedBlock
- must be big enough to hold decompressed output.compressedBlock
- compressed data starting at offset 0compressedLength
- size of compressed data, possibly less than the size of the buffer.- Returns:
- the uncompressed data size.
-
unzipBlock
public int unzipBlock(byte[] uncompressedBlock, int uncompressedBlockOffset, byte[] compressedBlock, int compressedBlockOffset, int compressedLength) Decompress GZIP-compressed data- Parameters:
uncompressedBlock
- must be big enough to hold decompressed output.uncompressedBlockOffset
- the offset into uncompressedBlock.compressedBlock
- compressed data starting at offset 0.compressedBlock
- the offset into the compressed data.compressedLength
- size of compressed data, possibly less than the size of the buffer.- Returns:
- the uncompressed data size.
-