Skip to content

Commit 8814ef8

Browse files
committed
Fix bug in tile cache initialization that resulted in out-of-memory warnings
1 parent 83446ce commit 8814ef8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/org/broad/igv/data/AbstractDataSource.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,25 @@ private List<SummaryTile> getSummaryTilesForRange(String chr, int startLocation,
139139
}
140140
endLocation = Math.min(endLocation, chrLength);
141141

142-
// By definition there are 2^z tiles per chromosome, and 700 bins per tile, where z is the zoom level.
143-
//int maxZoom = (int) (Math.log(chrLength/700) / Globals.log2) + 1;
144-
//int z = Math.min(zReq, maxZoom);
145-
int z = zReq;
146-
int nTiles = (int) Math.pow(2, z);
147-
//double binSize = Math.max(1, (((double) chrLength) / nTiles) / 700);
148-
149142

150143
int adjustedStart = Math.max(0, startLocation);
151144
int adjustedEnd = Math.min(chrLength, endLocation);
152145

153146

154147
if (cacheSummaryTiles && !FrameManager.isGeneListMode() && !FrameManager.isExomeMode()) {
155-
double tileWidth = ((double) chrLength) / nTiles;
148+
149+
// By definition there are 2^z tiles per chromosome, and 700 bins per tile, where z is the zoom level.
150+
//int maxZoom = (int) (Math.log(chrLength/700) / Globals.log2) + 1;
151+
//int z = Math.min(zReq, maxZoom);
152+
int z = zReq;
153+
int virtualTileCount = (int) Math.pow(2, z);
154+
155+
double tileWidth = ((double) chrLength) / virtualTileCount;
156156
int startTile = (int) (adjustedStart / tileWidth);
157157
int endTile = (int) (Math.min(chrLength, adjustedEnd) / tileWidth) + 1;
158-
List<SummaryTile> tiles = new ArrayList(nTiles);
158+
List<SummaryTile> tiles = null;
159+
160+
tiles = new ArrayList(endTile - startTile + 1);
159161
for (int t = startTile; t <= endTile; t++) {
160162
int tileStart = (int) (t * tileWidth);
161163
int tileEnd = Math.min(chrLength, (int) ((t + 1) * tileWidth));
@@ -310,11 +312,11 @@ SummaryTile computeSummaryTile(String chr, int tileNumber, int startLocation, in
310312
private LocusScore getCompositeScore(Accumulator accumulator, int accumulatedStart, int accumulatedEnd) {
311313
LocusScore ls;
312314
if (accumulator.getNpts() == 1) {
313-
ls = new NamedScore(accumulatedStart, accumulatedEnd, accumulator.getData()[0], accumulator.getNames()[0]);
315+
ls = new NamedScore(accumulatedStart, accumulatedEnd, accumulator.getRepData()[0], accumulator.getRepProbes()[0]);
314316
} else {
315317
float value = accumulator.getValue();
316-
ls = new CompositeScore(accumulatedStart, accumulatedEnd, value, accumulator.getData(),
317-
accumulator.getNames(), windowFunction);
318+
ls = new CompositeScore(accumulatedStart, accumulatedEnd, value, accumulator.getRepData(),
319+
accumulator.getRepProbes(), windowFunction);
318320
}
319321
return ls;
320322

0 commit comments

Comments
 (0)