List<PeakRecord> records) throws IOException {
chrIndex.put(currentChr, peakWriter.getWrittenCount());
// Compress data for chromosome, then write it out.
BufferedByteWriter buffer = new BufferedByteWriter(100000);
buffer.putNullTerminatedString(currentChr);
buffer.putInt(records.size());
for (PeakRecord record : records) {
buffer.putInt(record.start);
buffer.putInt(record.end);
buffer.putFloat(record.score);
for (int i = 0; i < record.timeScores.length; i++) {
buffer.putFloat(record.timeScores[i]);
}
}
byte[] bytes = buffer.getBytes();
bytes = compressionUtils.compress(bytes);
peakWriter.writeInt(bytes.length);
peakWriter.write(bytes);
records.clear();