/** * @return a virtual file pointer for the underlying compressed stream. * @see BlockCompressedInputStream#getFilePointer() */ public long getVirtualFilePointer() { return mCompressedInputStream.getFilePointer(); }
/** * @return a virtual file pointer for the underlying compressed stream. * @see BlockCompressedInputStream#getFilePointer() */ public long getVirtualFilePointer() { return mCompressedInputStream.getFilePointer(); }
@Override public long getPosition() { return getFilePointer(); }
@Override public long getPosition() { return getFilePointer(); }
@Override public long getPosition() { return getFilePointer(); }
@Override public long getPosition() { return getFilePointer(); }
public long getFilePointer() { return fileInputStream.getFilePointer(); }
public long getLogicalFilePointer() { return mNextRecord == null ? mCompressedInputStream.getFilePointer() : mNextRecord.stop; }
/** * @return a virtual file pointer for the underlying compressed stream. * @see BlockCompressedInputStream#getFilePointer() */ public long getVirtualFilePointer() { if (mCurrentIterator instanceof BAMFileIterator) { return ((BAMFileIterator)mCurrentIterator).getLogicalFilePointer(); } return mCompressedInputStream.getFilePointer(); }
private static PtrSkipPair readAlignment(final ByteBuffer byteBuffer, final BlockCompressedInputStream in) throws IOException { final long ptr = in.getFilePointer(); final int read = readBytes(byteBuffer, in, 4); if (read != 4) { if (read == 0) return null; ioError( "Invalid alignment at virtual offset %#x: "+ "less than 4 bytes long", in.getFilePointer()); } return new PtrSkipPair(ptr, byteBuffer.getInt(0)); }
private static PtrSkipPair readAlignment(final ByteBuffer byteBuffer, final BlockCompressedInputStream in) throws IOException { final long ptr = in.getFilePointer(); final int read = readBytes(byteBuffer, in, 4); if (read != 4) { if (read == 0) return null; ioError( "Invalid alignment at virtual offset %#x: "+ "less than 4 bytes long", in.getFilePointer()); } return new PtrSkipPair(ptr, byteBuffer.getInt(0)); }
private static PtrSkipPair readAlignment(final ByteBuffer byteBuffer, final BlockCompressedInputStream in) throws IOException { final long ptr = in.getFilePointer(); final int read = readBytes(byteBuffer, in, 4); if (read != 4) { if (read == 0) return null; ioError( "Invalid alignment at virtual offset %#x: "+ "less than 4 bytes long", in.getFilePointer()); } return new PtrSkipPair(ptr, byteBuffer.getInt(0)); }
private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final File indexFile, final boolean eagerDecode, final String source, final ValidationStringency validationStringency, final SAMRecordFactory factory) throws IOException { mIndexFile = indexFile; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = factory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
@Override SAMRecord getNextRecord() throws IOException { // Advance to next file block if necessary while (mCompressedInputStream.getFilePointer() >= mFilePointerLimit) { if (mFilePointers == null || mFilePointerIndex >= mFilePointers.length) { return null; } final long startOffset = mFilePointers[mFilePointerIndex++]; final long endOffset = mFilePointers[mFilePointerIndex++]; mCompressedInputStream.seek(startOffset); mFilePointerLimit = endOffset; } // Pull next record from stream return super.getNextRecord(); } }
@Override protected int readFromPosition(final ByteBuffer buffer, final long position) throws IOException { // old position to get back final long oldPos = stream.getFilePointer(); try { final long virtualOffset = gzindex.getVirtualOffsetForSeek(position); stream.seek(virtualOffset); final byte[] array = new byte[buffer.remaining()]; final int read = stream.read(array); buffer.put(array); return read; } finally { stream.seek(oldPos); } }
@Override protected int readFromPosition(final ByteBuffer buffer, final long position) throws IOException { // old position to get back final long oldPos = stream.getFilePointer(); try { final long virtualOffset = gzindex.getVirtualOffsetForSeek(position); stream.seek(virtualOffset); final byte[] array = new byte[buffer.remaining()]; final int read = stream.read(array); buffer.put(array); return read; } finally { stream.seek(oldPos); } }
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }
@Test public void testFilePointer() throws Exception { BlockCompressedInputStream sync = new BlockCompressedInputStream(BAM_FILE); Assert.assertEquals(sync.getFilePointer(), 0); sync.close(); } }
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }