* Read a BWT from the input stream.
* @return The BWT stored in the input stream.
*/
public BWT read() {
UnsignedIntPackedInputStream uintPackedInputStream = new UnsignedIntPackedInputStream(inputStream, ByteOrder.LITTLE_ENDIAN);
BasePackedInputStream basePackedInputStream = new BasePackedInputStream<Integer>(Integer.class, inputStream, ByteOrder.LITTLE_ENDIAN);
long inverseSA0;
long[] count;
SequenceBlock[] sequenceBlocks;
try {
inverseSA0 = uintPackedInputStream.read();
count = new long[PackUtils.ALPHABET_SIZE];
uintPackedInputStream.read(count);
long bwtSize = count[PackUtils.ALPHABET_SIZE-1];
sequenceBlocks = new SequenceBlock[PackUtils.numberOfPartitions(bwtSize,BWT.SEQUENCE_BLOCK_SIZE)];
for( int block = 0; block < sequenceBlocks.length; block++ ) {
int sequenceStart = block* BWT.SEQUENCE_BLOCK_SIZE;
int sequenceLength = (int)Math.min(BWT.SEQUENCE_BLOCK_SIZE,bwtSize-sequenceStart);
long[] occurrences = new long[PackUtils.ALPHABET_SIZE];
byte[] bwt = new byte[sequenceLength];
uintPackedInputStream.read(occurrences);
basePackedInputStream.read(bwt);
sequenceBlocks[block] = new SequenceBlock(sequenceStart,sequenceLength,new Counts(occurrences,false),bwt);
}
}
catch( IOException ex ) {