Package htsjdk.samtools.cram.structure
Class Block
- java.lang.Object
-
- htsjdk.samtools.cram.structure.Block
-
public class Block extends Object
Class representing CRAM block concept and some methods to operate with block content. CRAM block is used to hold some (usually homogeneous) binary data. An external compression can be applied to the content of a block. The class provides some instantiation static methods, for example to read a block from an input stream. Blocks can be written out to an output stream, this may be considered as a way to serialize/deserialize blocks.
-
-
Constructor Summary
Constructors Constructor Description Block()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BlockbuildNewCore(byte[] rawContent)Create a new core block with the given uncompressed content.static BlockbuildNewFileHeaderBlock(byte[] rawContent)Create a new core block with the given uncompressed content.static BlockbuildNewSliceHeaderBlock(byte[] rawContent)Create a new slice header block with the given uncompressed content.intgetCompressedContentSize()intgetContentId()BlockContentTypegetContentType()byte[]getRawContent()intgetRawContentSize()static BlockreadFromInputStream(int major, InputStream inputStream)Deserialize the block from theInputStream.voidsetContent(byte[] raw, byte[] compressed)voidsetContentId(int contentId)voidsetContentType(BlockContentType contentType)voidsetMethod(BlockCompressionMethod method)voidsetRawContent(byte[] raw)StringtoString()voidwrite(int major, OutputStream outputStream)Write the block out to the the specifiedOutputStream.
-
-
-
Method Detail
-
readFromInputStream
public static Block readFromInputStream(int major, InputStream inputStream) throws IOException
Deserialize the block from theInputStream. The reading is parametrized by the major CRAM version number.- Parameters:
major- CRAM version major numberinputStream- input stream to read the block from- Returns:
- a new
Blockobject with fields and content from the input stream - Throws:
IOException- as per java IO contract
-
buildNewSliceHeaderBlock
public static Block buildNewSliceHeaderBlock(byte[] rawContent)
Create a new slice header block with the given uncompressed content. The block wil have RAW (no compression) and MAPPED_SLICE content type.- Parameters:
rawContent- the content of the block- Returns:
- a new mapped slice
Blockobject
-
buildNewCore
public static Block buildNewCore(byte[] rawContent)
Create a new core block with the given uncompressed content. The block wil have RAW (no compression) and CORE content type.- Parameters:
rawContent- the content of the block- Returns:
- a new core
Blockobject
-
buildNewFileHeaderBlock
public static Block buildNewFileHeaderBlock(byte[] rawContent)
Create a new core block with the given uncompressed content. The block wil have RAW (no compression) and CORE content type.- Parameters:
rawContent- the content of the block- Returns:
- a new core
Blockobject
-
setRawContent
public void setRawContent(byte[] raw)
-
getRawContent
public byte[] getRawContent()
-
getRawContentSize
public int getRawContentSize()
-
setContent
public void setContent(byte[] raw, byte[] compressed)
-
write
public void write(int major, OutputStream outputStream) throws IOExceptionWrite the block out to the the specifiedOutputStream. The method is parametrized with CRAM major version number.- Parameters:
major- CRAM version major numberoutputStream- output stream to write to- Throws:
IOException- as per java IO contract
-
setMethod
public void setMethod(BlockCompressionMethod method)
-
getContentType
public BlockContentType getContentType()
-
setContentType
public void setContentType(BlockContentType contentType)
-
getContentId
public int getContentId()
-
setContentId
public void setContentId(int contentId)
-
getCompressedContentSize
public int getCompressedContentSize()
-
-