*/
if (reader == null) {
return null;
}
updateNormalizationFactor();
CountBinningAdapterI binAdaptor = new CountBinningAdaptor(reader, binSize);
if (counts.hasIndex()) {
// we can only reposition if the countsreader has an index. Otherwise, we trust the
// caching counts archive to have created a new reader positioned at the start of the counts sequence.
binAdaptor.reposition(startLocation);
}
binAdaptor.skipTo(startLocation);
int position = binAdaptor.getPosition();
ObjectArrayList<LocusScore> result = new ObjectArrayList<LocusScore>();
result.add(new BasicScore(initialStartPosition, position, 0.0f));
while (binAdaptor.hasNextTransition() && position < endLocation) {
binAdaptor.nextTransition();
// position is the zero-based position before the count is changed by the transition
position = binAdaptor.getPosition();
// count is how many reads cover the length bases that follow position.
final double count = selectedWindowFunction == WindowFunction.mean ? binAdaptor.getAverage() : binAdaptor.getMax();
final double normalizedCount = count / normalizationFactor;
final int length = binAdaptor.getLength();
// System.out.printf("adding results %d-%d count=%g %n", position, position + length , normalizedCount);
BasicScore bs = new BasicScore(position, position + length, (float) normalizedCount);
result.add(bs);