/** * Resets the SAM reader position to its original state. */ private void initialize() { this.positionIterator = new PeekableIterator<GATKChunk>(positions.iterator()); if(positionIterator.hasNext()) nextBlockAddress = positionIterator.peek().getBlockStart(); else nextBlockAddress = -1; }
/** * Retrieves the first offset of interest in the block returned by getBlockAddress(). * @return First block of interest in this segment. */ public int getFirstOffsetInBlock() { return (nextBlockAddress == positionIterator.peek().getBlockStart()) ? positionIterator.peek().getBlockOffsetStart() : 0; }
incomingBuffer.limit((spanOverlapping.getBlockEnd() > spanOverlapping.getBlockStart()) ? bytesInIncomingBuffer : spanOverlapping.getBlockOffsetEnd()); incomingBuffer.position(spanOverlapping.getBlockOffsetStart()); buffer.put(incomingBuffer);
List<GATKChunk> spansOverlapping = new LinkedList<GATKChunk>(); while(positionIterator.hasNext() && positionIterator.peek().getBlockStart() <= blockAddress) { int blockOffsetStart = (blockAddress == positionIterator.peek().getBlockStart()) ? positionIterator.peek().getBlockOffsetStart() : 0;
/** * Advances the current position to the next block to read, given the current position in the file. * @param filePosition The current position within the file. */ void advancePosition(final long filePosition) { nextBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(filePosition); // Check the current file position against the iterator; if the iterator is before the current file position, // draw the iterator forward. Remember when performing the check that coordinates are half-open! while(positionIterator.hasNext() && isFilePositionPastEndOfChunk(filePosition,positionIterator.peek())) positionIterator.next(); // If the block iterator has shot past the file pointer, bring the file pointer flush with the start of the current block. if(positionIterator.hasNext() && filePosition < positionIterator.peek().getChunkStart()) nextBlockAddress = positionIterator.peek().getBlockStart(); // If we've shot off the end of the block pointer, notify consumers that iteration is complete. if(!positionIterator.hasNext()) nextBlockAddress = -1; }