private boolean samHasMore() { return !finishedAlignedReads && (samIterator.peek() != null); }
private boolean samHasMore() { return !finishedAlignedReads && (samIterator.peek() != null); }
private boolean samHasMore() { return !finishedAlignedReads && (samIterator.peek() != null); }
/** * 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; }
/** * Adds all intervals that overlap the current reference locus to the intervalMap * * @param refLocus the current reference locus */ private void addNewOverlappingIntervals(final GenomeLoc refLocus) { GenomeLoc interval = intervalListIterator.peek(); while (interval != null && !interval.isPast(refLocus)) { intervalMap.put(interval, createIntervalStatistic(interval)); intervalListIterator.next(); interval = intervalListIterator.peek(); } }
/** * Advance the iterator until at or ahead of locus. if there's a variant at the locus return true, otherwise false. * <p> * HAS SIDE EFFECTS!!! draws from vcfIterator!!! * * @param vcfIterator a {@link VariantContext} iterator to advance (assumed sorted) * @param locus a {@link Locus} at which to examine the variants * @param sequenceDictionary a dictionary with which to compare the Locatable to the Locus... * @return true if there's a variant over the locus, false otherwise. */ private static boolean advanceIteratorAndCheckLocus(final PeekableIterator<VariantContext> vcfIterator, final Locus locus, final SAMSequenceDictionary sequenceDictionary) { while (vcfIterator.hasNext() && (vcfIterator.peek().isFiltered() || CompareVariantContextToLocus(sequenceDictionary, vcfIterator.peek(), locus) < 0)) { vcfIterator.next(); } return vcfIterator.hasNext() && CompareVariantContextToLocus(sequenceDictionary, vcfIterator.peek(), locus) == 0; }
/** * Process all remaining intervals * * @param result number of loci processed by the walker */ @Override public void onTraversalDone(final Long result) { for (GenomeLoc interval : intervalMap.keySet()) outputStatsToVCF(intervalMap.get(interval), UNCOVERED_ALLELE); GenomeLoc interval = intervalListIterator.peek(); while (interval != null) { outputStatsToVCF(createIntervalStatistic(interval), UNCOVERED_ALLELE); intervalListIterator.next(); interval = intervalListIterator.peek(); } if (thresholds.missingTargets != null) { thresholds.missingTargets.close(); } }
/** * Pulls out of the iterator the next group of reads that can be compared to each other to * identify duplicates. */ List<PairedReadSequence> getNextGroup(final PeekableIterator<PairedReadSequence> iterator) { final List<PairedReadSequence> group = new ArrayList<PairedReadSequence>(); final PairedReadSequence first = iterator.next(); group.add(first); outer: while (iterator.hasNext()) { final PairedReadSequence next = iterator.peek(); for (int i = 0; i < MIN_IDENTICAL_BASES; ++i) { if (first.read1[i] != next.read1[i] || first.read2[i] != next.read2[i]) break outer; } group.add(iterator.next()); } return group; }
/** * 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; }
/** * Pulls out of the iterator the next group of reads that can be compared to each other to * identify duplicates. */ List<PairedReadSequence> getNextGroup(final PeekableIterator<PairedReadSequence> iterator) { final List<PairedReadSequence> group = new ArrayList<PairedReadSequence>(); final PairedReadSequence first = iterator.next(); group.add(first); outer: while (iterator.hasNext()) { final PairedReadSequence next = iterator.peek(); for (int i = 0; i < MIN_IDENTICAL_BASES; ++i) { if (first.read1[i] != next.read1[i] || first.read2[i] != next.read2[i]) break outer; } group.add(iterator.next()); } return group; }
/** * Advance the iterator until at or ahead of locus. if there's a variant at the locus return true, otherwise false. * <p> * HAS SIDE EFFECTS!!! draws from vcfIterator!!! * * @param vcfIterator a {@link VariantContext} iterator to advance (assumed sorted) * @param locus a {@link Locus} at which to examine the variants * @param sequenceDictionary a dictionary with which to compare the Locatable to the Locus... * @return true if there's a variant over the locus, false otherwise. */ private static boolean advanceIteratorAndCheckLocus(final PeekableIterator<VariantContext> vcfIterator, final Locus locus, final SAMSequenceDictionary sequenceDictionary) { while (vcfIterator.hasNext() && (vcfIterator.peek().isFiltered() || CompareVariantContextToLocus(sequenceDictionary, vcfIterator.peek(), locus) < 0)) { vcfIterator.next(); } return vcfIterator.hasNext() && CompareVariantContextToLocus(sequenceDictionary, vcfIterator.peek(), locus) == 0; }
/** * Accumulate shards where there's no additional cost to processing the next shard in the sequence. * @return The next file pointer to process. */ public FilePointer next() { FilePointer current = wrappedIterator.next(); while ( wrappedIterator.hasNext() && current.isRegionUnmapped == wrappedIterator.peek().isRegionUnmapped && (current.getContigIndex() == wrappedIterator.peek().getContigIndex() || current.isRegionUnmapped) && current.minus(wrappedIterator.peek()) == 0 ) { current = current.combine(parser,wrappedIterator.next()); } return current; }
/** * Combine all of the file pointers in the filePointers iterator into a single combined * FilePointer that spans all of the file pointers on a single contig * @return a non-null FilePointer */ private FilePointer getCombinedFilePointersOnSingleContig() { FilePointer current = filePointers.next(); final List<FilePointer> toCombine = new LinkedList<>(); toCombine.add(current); while ( filePointers.hasNext() && current.isRegionUnmapped == filePointers.peek().isRegionUnmapped && (current.getContigIndex() == filePointers.peek().getContigIndex() || current.isRegionUnmapped) ) { toCombine.add(filePointers.next()); } return FilePointer.union(toCombine, parser); } }
/** * Generates a list by consuming from the iterator in order starting with the first available * read and continuing while subsequent reads share the same read name. If there are no reads * remaining returns an empty list. */ private List<SAMRecord> fetchByReadName(final PeekableIterator<SAMRecord> iterator) { final List<SAMRecord> out = new ArrayList<>(); if (iterator.hasNext()) { final SAMRecord first = iterator.next(); out.add(first); while (iterator.hasNext() && iterator.peek().getReadName().equals(first.getReadName())) { out.add(iterator.next()); } } return out; }
/** * Generates a list by consuming from the iterator in order starting with the first available * read and continuing while subsequent reads share the same read name. If there are no reads * remaining returns an empty list. */ private List<SAMRecord> fetchByReadName(final PeekableIterator<SAMRecord> iterator) { final List<SAMRecord> out = new ArrayList<>(); if (iterator.hasNext()) { final SAMRecord first = iterator.next(); out.add(first); while (iterator.hasNext() && iterator.peek().getReadName().equals(first.getReadName())) { out.add(iterator.next()); } } return out; }
/** * 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; }
public SAMRecord next() { if (read1Iterator.hasNext()) { if (read2Iterator.hasNext()) { return (read1Iterator.peek().getReadName().compareTo(read2Iterator.peek().getReadName()) <= 0) ? setPairFlags(read1Iterator.next(), true) : setPairFlags(read2Iterator.next(), false); } else { return setPairFlags(read1Iterator.next(), true); } } else { return setPairFlags(read2Iterator.next(), false); } }
public SAMRecord next() { if (read1Iterator.hasNext()) { if (read2Iterator.hasNext()) { return (read1Iterator.peek().getReadName().compareTo(read2Iterator.peek().getReadName()) <= 0) ? setPairFlags(read1Iterator.next(), true) : setPairFlags(read2Iterator.next(), false); } else { return setPairFlags(read1Iterator.next(), true); } } else { return setPairFlags(read2Iterator.next(), false); } }
/** * Advances the underlying, peekable, iterator until the next records is one that is to be emitted. * @return true if there is at least one emittable record ready for emission, false otherwise */ private boolean advanceToNextAcceptedRead() { while (this.underlyingIterator.hasNext() && this.hasher.hashUnencodedChars(this.underlyingIterator.peek().getReadName()) > this.maxHashValue) { this.underlyingIterator.next(); recordDiscardedRecord(); } return this.underlyingIterator.hasNext(); }
/** * Advances the underlying, peekable, iterator until the next records is one that is to be emitted. * @return true if there is at least one emittable record ready for emission, false otherwise */ private boolean advanceToNextAcceptedRead() { while (this.underlyingIterator.hasNext() && this.hasher.hashUnencodedChars(this.underlyingIterator.peek().getReadName()) > this.maxHashValue) { this.underlyingIterator.next(); recordDiscardedRecord(); } return this.underlyingIterator.hasNext(); }