/**
* Write a BWT to the output stream.
* @param bwt Transform to be written to the output stream.
*/
public void write( BWT bwt ) {
UnsignedIntPackedOutputStream intPackedOutputStream = new UnsignedIntPackedOutputStream(outputStream, ByteOrder.LITTLE_ENDIAN);
BasePackedOutputStream basePackedOutputStream = new BasePackedOutputStream<Integer>(Integer.class, outputStream, ByteOrder.LITTLE_ENDIAN);
try {
intPackedOutputStream.write(bwt.inverseSA0);
intPackedOutputStream.write(bwt.counts.toArray(true));
for( SequenceBlock block: bwt.sequenceBlocks ) {
intPackedOutputStream.write(block.occurrences.toArray(false));
basePackedOutputStream.write(block.sequence);
}
// The last block is the last set of counts in the structure.
intPackedOutputStream.write(bwt.counts.toArray(false));
}
catch( IOException ex ) {
throw new ReviewedGATKException("Unable to read BWT from input stream.", ex);
}
}