private boolean isFilePositionPastEndOfChunk(final long filePosition, final GATKChunk chunk) { return filePosition >= chunk.getChunkEnd(); } }
public long getBlockEnd() { return getChunkEnd() >>> 16; }
public int getBlockOffsetEnd() { return ((int)getChunkEnd() & 0xFFFF); }
/** * Computes an approximation of the uncompressed size of the * chunk, in bytes. Can be used to determine relative weights * of chunk size. * @return An approximation of the chunk size in bytes. */ public long size() { final long chunkSpan = Math.round(((getChunkEnd()>>16)-(getChunkStart()>>16))/AVERAGE_BAM_COMPRESSION_RATIO); final int offsetSpan = (int)((getChunkEnd()&0xFFFF)-(getChunkStart()&0xFFFF)); return chunkSpan + offsetSpan; }
/** * Merges two chunks together. The caller is responsible for testing whether the * chunks overlap/are adjacent before calling this method! * * @param other the chunk to merge with this chunk * @return a new chunk representing the union of the two chunks (provided the chunks were * overlapping/adjacent) */ public GATKChunk merge ( GATKChunk other ) { return new GATKChunk(Math.min(getChunkStart(), other.getChunkStart()), Math.max(getChunkEnd(), other.getChunkEnd())); } }
private List<GATKChunk> optimizeChunkList(final List<GATKChunk> chunks, final long minimumOffset) { GATKChunk lastChunk = null; Collections.sort(chunks); final List<GATKChunk> result = new ArrayList<GATKChunk>(); for (final GATKChunk chunk : chunks) { if (chunk.getChunkEnd() <= minimumOffset) { continue; // linear index optimization } if (result.isEmpty()) { result.add(chunk); lastChunk = chunk; continue; } // Coalesce chunks that are in adjacent file blocks. // This is a performance optimization. if (!lastChunk.overlaps(chunk) && !lastChunk.isAdjacentTo(chunk)) { result.add(chunk); lastChunk = chunk; } else { if (chunk.getChunkEnd() > lastChunk.getChunkEnd()) { lastChunk.setChunkEnd(chunk.getChunkEnd()); } } } return result; }
@Override public GATKChunk clone() { return new GATKChunk(getChunkStart(),getChunkEnd()); }
if(thisChunk.getChunkEnd() <= otherChunk.getChunkStart()) { thisChunk = thisIterator.hasNext() ? thisIterator.next() : null; continue; if(thisChunk.getChunkStart() >= otherChunk.getChunkEnd()) { otherChunk = otherIterator.hasNext() ? otherIterator.next() : null; continue; GATKChunk intersectedChunk = new GATKChunk(secondChunk.getChunkStart(),Math.min(firstChunk.getChunkEnd(),secondChunk.getChunkEnd())); intersected.add(intersectedChunk); if(thisChunk.getChunkEnd() > intersectedChunk.getChunkEnd()) thisChunk = new GATKChunk(intersectedChunk.getChunkEnd(),thisChunk.getChunkEnd()); else thisChunk = thisIterator.hasNext() ? thisIterator.next() : null; if(otherChunk.getChunkEnd() > intersectedChunk.getChunkEnd()) otherChunk = new GATKChunk(intersectedChunk.getChunkEnd(),otherChunk.getChunkEnd()); else otherChunk = otherIterator.hasNext() ? otherIterator.next() : null;
if(thisChunk.getChunkEnd() <= otherChunk.getChunkStart()) { subtracted.add(thisChunk); thisChunk = thisIterator.hasNext() ? thisIterator.next() : null; if(thisChunk.getChunkStart() >= otherChunk.getChunkEnd()) { otherChunk = otherIterator.hasNext() ? otherIterator.next() : null; continue; subtracted.add(new GATKChunk(thisChunk.getChunkStart(),otherChunk.getChunkStart())); if(thisChunk.getChunkEnd() > otherChunk.getChunkEnd()) thisChunk = new GATKChunk(otherChunk.getChunkEnd(),thisChunk.getChunkEnd()); else thisChunk = thisIterator.hasNext() ? thisIterator.next() : null;
blockPositions.add(spanOverlapping.getChunkEnd());
for(GATKChunk chunk: fileSpan.getGATKChunks()) { buffer.putLong(chunk.getChunkStart()); buffer.putLong(chunk.getChunkEnd());
if(newChunk.getChunkStart() <= newChunk.getChunkEnd()) spansOverlapping.add(new GATKChunk(blockAddress,blockOffsetStart,blockEnd,blockOffsetEnd));