Package htsjdk.samtools.cram.structure
Class SliceBlocks
java.lang.Object
htsjdk.samtools.cram.structure.SliceBlocks
Manage the (logical) set of blocks that constitute a
Slice
, not including the Slice header block,
which is managed by Slice
.
Prevents duplicate blocks (blocks with non-unique content ID) or illogical blocks (i.e., setting
a core block that is not of type core block, or an external block that is not an external block) from
being added.-
Constructor Summary
ConstructorsConstructorDescriptionSliceBlocks
(CRAMVersion cramVersion, int numberOfBlocks, InputStream inputStream) Read the set of blocks that make up a slice from a CRAM stream.SliceBlocks
(Block coreBlock, List<Block> externalBlocks) Create a new SliceBlocks object from a core block and one or more external blocks. -
Method Summary
Modifier and TypeMethodDescriptionReturn the core block for this Slice.getExternalBlock
(Integer contentID) Get the external block corresponding to a contentID.Return a list of external content IDs.int
Number of external locks present in this SliceBlocks object (does not include the core block).void
writeBlocks
(CRAMVersion cramVersion, OutputStream outputStream) Write the coreBlock and each external block out to a CRAM stream.
-
Constructor Details
-
SliceBlocks
Create a new SliceBlocks object from a core block and one or more external blocks.- Parameters:
coreBlock
- the core block for the Slice, may not be nullexternalBlocks
- the external blocks for this Slice, may not be null and must contain a least one block
-
SliceBlocks
Read the set of blocks that make up a slice from a CRAM stream.- Parameters:
cramVersion
- CRAM version being readnumberOfBlocks
- number of blocks to consume from the streaminputStream
- stream to consume
-
-
Method Details
-
getCoreBlock
Return the core block for this Slice. May be null. -
getExternalBlock
Get the external block corresponding to a contentID.- Parameters:
contentID
- contentID identifying the external block- Returns:
- external block for the contentID. May be null.
-
getExternalContentIDs
Return a list of external content IDs. May be empty. For each content ID returned, the corresponding external block can be obtained usinggetExternalBlock(java.lang.Integer)
.- Returns:
- list of external content IDs
-
getNumberOfExternalBlocks
public int getNumberOfExternalBlocks()Number of external locks present in this SliceBlocks object (does not include the core block).- Returns:
- number of external blocks, including any embedded reference block, but excluding the core block
-
writeBlocks
Write the coreBlock and each external block out to a CRAM stream. There is no predefined order that must be honored, since each block is identified by a unique contentID.- Parameters:
cramVersion
- CRAM major version being writtenoutputStream
- stream to write blocks to
-