Class SliceBlocks

java.lang.Object
htsjdk.samtools.cram.structure.SliceBlocks

public class SliceBlocks extends Object
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 Details

    • 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 null
      externalBlocks - 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 read
      numberOfBlocks - number of blocks to consume from the stream
      inputStream - stream to consume
  • Method Details

    • 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 using getExternalBlock(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 written
      outputStream - stream to write blocks to