@Override public SAMRecordIterator iterator(final SAMFileSpan fileSpan) { // get the file coordinates for the span: final long[] coordinateArray = ((BAMFileSpan) fileSpan).toCoordinateArray(); if (coordinateArray == null || coordinateArray.length == 0) return emptyIterator; try { // create an input stream that reads the source cram stream only within the coordinate pairs: final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); return new CRAMIterator(seekableStream, referenceSource, coordinateArray, validationStringency); } catch (final IOException e) { throw new RuntimeException(e); } }
@Override public SAMRecordIterator iterator(final SAMFileSpan fileSpan) { // get the file coordinates for the span: final long[] coordinateArray = ((BAMFileSpan) fileSpan).toCoordinateArray(); if (coordinateArray == null || coordinateArray.length == 0) return emptyIterator; // create an input stream that reads the source cram stream only within the coordinate pairs: final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); return new CRAMIterator(seekableStream, referenceSource, coordinateArray, validationStringency); }
@Override public CloseableIterator<SAMRecord> queryUnmapped() { final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); final CRAMIterator newIterator; try { seekableStream.seek(0); newIterator = new CRAMIterator(seekableStream, referenceSource, validationStringency); seekableStream.seek(startOfLastLinearBin >>> 16); final Container container = ContainerIO.readContainerHeader(newIterator.getCramHeader().getVersion().major, seekableStream); seekableStream.seek(seekableStream.position() + container.containerByteSize); iterator = newIterator; boolean atAlignments; do { atAlignments = iterator.advanceToAlignmentInContainer(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX, SAMRecord.NO_ALIGNMENT_START); } while (!atAlignments && iterator.hasNext()); } catch (final IOException e) { throw new RuntimeEOFException(e); } return iterator; }
@Override public CloseableIterator<SAMRecord> queryUnmapped() { final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); final CRAMIterator newIterator; try { seekableStream.seek(0); newIterator = new CRAMIterator(seekableStream, referenceSource, validationStringency); seekableStream.seek(startOfLastLinearBin >>> 16); final Container container = ContainerIO.readContainerHeader(newIterator.getCramHeader().getVersion().major, seekableStream); seekableStream.seek(seekableStream.position() + container.containerByteSize); iterator = newIterator; boolean atAlignments; do { atAlignments = iterator.advanceToAlignmentInContainer(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX, SAMRecord.NO_ALIGNMENT_START); } while (!atAlignments && iterator.hasNext()); } catch (final IOException e) { throw new RuntimeEOFException(e); } return iterator; }