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 Block
buildNewCore(byte[] rawContent)
Create a new core block with the given uncompressed content.static Block
buildNewFileHeaderBlock(byte[] rawContent)
Create a new core block with the given uncompressed content.static Block
buildNewSliceHeaderBlock(byte[] rawContent)
Create a new slice header block with the given uncompressed content.int
getCompressedContentSize()
int
getContentId()
BlockContentType
getContentType()
byte[]
getRawContent()
int
getRawContentSize()
static Block
readFromInputStream(int major, InputStream inputStream)
Deserialize the block from theInputStream
.void
setContent(byte[] raw, byte[] compressed)
void
setContentId(int contentId)
void
setContentType(BlockContentType contentType)
void
setMethod(BlockCompressionMethod method)
void
setRawContent(byte[] raw)
String
toString()
void
write(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
Block
object 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
Block
object
-
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
Block
object
-
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
Block
object
-
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 IOException
Write 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()
-
-