Class CRAMContainerStreamWriter


  • public class CRAMContainerStreamWriter
    extends Object
    Class for writing SAMRecords into a series of CRAM containers on an output stream, with an optional index.
    • Constructor Detail

      • CRAMContainerStreamWriter

        public CRAMContainerStreamWriter​(OutputStream recordOutputStream,
                                         OutputStream indexOutputStream,
                                         CRAMReferenceSource source,
                                         SAMFileHeader samFileHeader,
                                         String outputIdentifier)
        Create a CRAMContainerStreamWriter for writing SAM records into a series of CRAM containers on output stream, with an optional index.
        Parameters:
        recordOutputStream - where to write the CRAM stream.
        indexOutputStream - where to write the output index. Can be null if no index is required.
        source - reference cramReferenceSource
        samFileHeader - SAMFileHeader to be used. Sort order is determined by the sortOrder property of this arg.
        outputIdentifier - used for display in error message display
      • CRAMContainerStreamWriter

        public CRAMContainerStreamWriter​(OutputStream outputStream,
                                         CRAMReferenceSource source,
                                         SAMFileHeader samFileHeader,
                                         String outputIdentifier,
                                         CRAMIndexer indexer)
        Create a CRAMContainerStreamWriter for writing SAM records into a series of CRAM containers on output stream, with an optional index.
        Parameters:
        outputStream - where to write the CRAM stream.
        source - reference cramReferenceSource
        samFileHeader - SAMFileHeader to be used. Sort order is determined by the sortOrder property of this arg.
        outputIdentifier - used for display in error message display
        indexer - CRAM indexer. Can be null if no index is required.
      • CRAMContainerStreamWriter

        public CRAMContainerStreamWriter​(CRAMEncodingStrategy encodingStrategy,
                                         CRAMReferenceSource referenceSource,
                                         SAMFileHeader samFileHeader,
                                         OutputStream outputStream,
                                         CRAMIndexer indexer,
                                         String outputIdentifier)
        Create a CRAMContainerStreamWriter for writing SAM records into a series of CRAM containers on output stream, with an optional index.
        Parameters:
        encodingStrategy - encoding strategy values
        referenceSource - reference cramReferenceSource
        samFileHeader - SAMFileHeader to be used. Sort order is determined by the sortOrder property of this arg.
        outputStream - where to write the CRAM stream.
        indexer - CRAM indexer. Can be null if no index is required.
        outputIdentifier - informational string included in error reporting
    • Method Detail

      • writeAlignment

        public void writeAlignment​(SAMRecord alignment)
        Accumulate alignment records until we meet the threshold to flush a container.
        Parameters:
        alignment - must not be null
      • writeHeader

        public void writeHeader​(SAMFileHeader requestedSAMFileHeader)
        Write a CRAM file header and the previously provided SAM header to the stream.
      • writeHeader

        public void writeHeader()
        Write a CRAM file header and the previously provided SAM header to the stream.
      • finish

        public void finish​(boolean writeEOFContainer)
        Finish writing to the stream. Flushes the record cache and optionally emits an EOF container.
        Parameters:
        writeEOFContainer - true if an EOF container should be written. Only use false if writing a CRAM file fragment which will later be aggregated into a complete CRAM file.
      • writeContainer

        protected void writeContainer​(Container container)