Package htsjdk.samtools

# Class BAMStreamWriter

java.lang.Object
htsjdk.samtools.BAMStreamWriter

public class BAMStreamWriter extends Object
Class for writing SAMRecords in BAM format to an output stream.

## Constructor Summary

Constructors
Constructor
Description
`BAMStreamWriter(OutputStream outputStream, OutputStream indexStream, OutputStream sbiStream, long sbiGranularity, SAMFileHeader header)`
Create a BAMStreamWriter for writing.

## Method Summary

Modifier and Type
Method
Description
`void`
`finish(boolean writeTerminatorBlock)`
Finish writing and close all the streams.
`void`
`writeAlignment(SAMRecord alignment)`
`void`
`writeHeader(SAMFileHeader header)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BAMStreamWriter

public BAMStreamWriter(OutputStream outputStream, OutputStream indexStream, OutputStream sbiStream, long sbiGranularity, SAMFileHeader header)
Create a BAMStreamWriter for writing. All output streams should be uncompressed streams, since this class performs the necessary compression. All output streams are closed by this class after `finish(boolean)` returns.

Parameters:
  `outputStream` - an output stream for the main BAM output
  `indexStream` - an output stream for the BAI index, or null if no index is required
  `sbiStream` - an output stream for the SBI index, or null if no index is required
  `sbiGranularity` - the granularity of the SBI index (reads per entry)
  `header` - the SAM header

## Method Details

### writeHeader

public void writeHeader(SAMFileHeader header)

### writeAlignment

public void writeAlignment(SAMRecord alignment)

### finish

public void finish(boolean writeTerminatorBlock)
Finish writing and close all the streams.

Parameters:
  `writeTerminatorBlock` - whether to write a BAM terminator block to the main output stream