Package htsjdk.samtools.cram.structure
Class SliceBlocks
- java.lang.Object
-
- htsjdk.samtools.cram.structure.SliceBlocks
-
public class SliceBlocks extends Object
Manage the (logical) set of blocks that constitute aSlice
, not including the Slice header block, which is managed bySlice
. 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
Constructors Constructor Description SliceBlocks(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Block
getCoreBlock()
Return the core block for this Slice.Block
getExternalBlock(Integer contentID)
Get the external block corresponding to a contentID.List<Integer>
getExternalContentIDs()
Return a list of external content IDs.int
getNumberOfExternalBlocks()
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 Detail
-
SliceBlocks
public SliceBlocks(Block coreBlock, List<Block> externalBlocks)
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
public SliceBlocks(CRAMVersion cramVersion, int numberOfBlocks, InputStream inputStream)
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 Detail
-
getCoreBlock
public Block getCoreBlock()
Return the core block for this Slice. May be null.
-
getExternalBlock
public Block getExternalBlock(Integer contentID)
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
public List<Integer> 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
public void writeBlocks(CRAMVersion cramVersion, OutputStream outputStream)
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
-
-