refBAOS.write(line.getBytes(), 0, line.length());
}
byte[] ref = refBAOS.toByteArray();
refBAOS.close();
CramHeader cramHeader = ReadWrite.readCramHeader(stream);
assertNotNull(cramHeader);
assertNotNull(cramHeader.samFileHeader);
assertEquals(2, cramHeader.majorVersion);
assertEquals(0, cramHeader.minorVersion);
Container container = new Container();
ContainerHeaderIO chio = new ContainerHeaderIO();
chio.readContainerHeader(container, stream);
assertNotNull(container);
System.out.println(container);
CompressionHeaderBLock chb = new CompressionHeaderBLock(stream);
container.h = chb.getCompressionHeader();
assertNotNull(container.h);
System.out.println(container.h);
SliceIO sio = new SliceIO();
container.slices = new Slice[container.landmarks.length];
for (int s = 0; s < container.landmarks.length; s++) {
Slice slice = new Slice();
sio.read(slice, stream);
container.slices[s] = slice;
}
System.out.println(container);
ArrayList<CramRecord> records = new ArrayList<CramRecord>(
container.nofRecords);
BLOCK_PROTO.getRecords(container.h, container,
cramHeader.samFileHeader, records);
testALignmentSpan(container, cramHeader, records);
for (int i = 0; i < records.size(); i++) {
if (i < 10)
System.out.println(records.get(i).toString());
}
ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(
BYTES);
ReadWrite.writeCramHeader(cramHeader, baos);
byte[] b = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(b);
CramHeader cramHeader2 = ReadWrite.readCramHeader(bais);
assertEquals(toString(cramHeader.samFileHeader),
toString(cramHeader2.samFileHeader));
BLOCK_PROTO.recordsPerSlice = container.slices[0].nofRecords;