Class AbstractLocusIterator<T extends AbstractRecordAndOffset,K extends AbstractLocusInfo<T>>

java.lang.Object
htsjdk.samtools.util.AbstractLocusIterator<T,K>
All Implemented Interfaces:
CloseableIterator<K>, Closeable, AutoCloseable, Iterable<K>, Iterator<K>
Direct Known Subclasses:
EdgeReadIterator, SamLocusIterator

public abstract class AbstractLocusIterator<T extends AbstractRecordAndOffset,K extends AbstractLocusInfo<T>> extends Object implements Iterable<K>, CloseableIterator<K>
Iterator that traverses a SAM File, accumulating information on a per-locus basis. Optionally takes a target interval list, in which case the loci returned are the ones covered by the interval list. If no target interval list, whatever loci are covered by the input reads are returned. By default duplicate reads and non-primary alignments are filtered out. Filtering may be changed via setSamFilters().
  • Field Details

    • includeIndels

      protected boolean includeIndels
      If true, include indels in the LocusInfo
  • Constructor Details

    • AbstractLocusIterator

      public AbstractLocusIterator(SamReader samReader, IntervalList intervalList, boolean useIndex)
      Prepare to iterate through the given SAM records, skipping non-primary alignments
      Parameters:
      samReader - must be coordinate sorted
      intervalList - Either the list of desired intervals, or null.
      useIndex - If true, do indexed lookup to improve performance. Not relevant if intervalList == null. It is no longer the case the useIndex==true can make performance worse. It should always perform at least as well as useIndex==false, and generally will be much faster.
  • Method Details

    • getHeader

      public SAMFileHeader getHeader()
    • iterator

      public Iterator<K> iterator()
      Specified by:
      iterator in interface Iterable<T extends AbstractRecordAndOffset>
      Returns:
      iterator over all/all covered locus position in reference according to emitUncoveredLoci value.
    • close

      public void close()
      Closes inner SamIterator</>.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CloseableIterator<T extends AbstractRecordAndOffset>
    • hasNext

      public boolean hasNext()
      Returns true if there are more AbstractLocusInfo objects that can be returned, due to any of the following reasons: 1) there are more aligned reads in the SAM file 2) there are AbstractLocusInfos in some stage of accumulation 3) there are loci in the target mask that have yet to be accumulated (even if there are no reads covering them)
      Specified by:
      hasNext in interface Iterator<T extends AbstractRecordAndOffset>
    • next

      public K next()
      hasNext() has been fixed so that if it returns true, next() is now guaranteed not to return null.
      Specified by:
      next in interface Iterator<T extends AbstractRecordAndOffset>
      Returns:
      information about next locus position in reference sequence
    • getReferenceSequence

      protected SAMSequenceRecord getReferenceSequence(int referenceSequenceIndex)
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T extends AbstractRecordAndOffset>
    • startWithInsertion

      protected static boolean startWithInsertion(Cigar cigar)
      Check if cigar start with an insertion, ignoring other operators that do not consume references bases
      Parameters:
      cigar - the cigar
      Returns:
      true if the first operator to consume reference bases or be an insertion, is an insertion; false otherwise
    • setSamFilters

      public void setSamFilters(List<SamRecordFilter> samFilters)
      Controls which, if any, SAMRecords are filtered. By default duplicate reads and non-primary alignments are filtered out. The list of filters passed here replaces any existing filters.
      Parameters:
      samFilters - list of filters, or null if no filtering is desired.
    • getQualityScoreCutoff

      public int getQualityScoreCutoff()
    • setQualityScoreCutoff

      public void setQualityScoreCutoff(int qualityScoreCutoff)
    • getMappingQualityScoreCutoff

      public int getMappingQualityScoreCutoff()
    • setMappingQualityScoreCutoff

      public void setMappingQualityScoreCutoff(int mappingQualityScoreCutoff)
    • isIncludeNonPfReads

      public boolean isIncludeNonPfReads()
    • setIncludeNonPfReads

      public void setIncludeNonPfReads(boolean includeNonPfReads)
    • isEmitUncoveredLoci

      public boolean isEmitUncoveredLoci()
    • setEmitUncoveredLoci

      public void setEmitUncoveredLoci(boolean emitUncoveredLoci)
    • getMaxReadsToAccumulatePerLocus

      public int getMaxReadsToAccumulatePerLocus()
    • setMaxReadsToAccumulatePerLocus

      public void setMaxReadsToAccumulatePerLocus(int maxReadsToAccumulatePerLocus)
      If set, this will cap the number of reads we accumulate for any given position. As is pointed out above, setting this could cause major bias because of the non-random nature with which the cap is applied (the first maxReadsToAccumulatePerLocus reads are kept and all subsequent ones are dropped).
    • getIntervals

      protected List<Interval> getIntervals()
    • isIncludeIndels

      public boolean isIncludeIndels()
    • setIncludeIndels

      public void setIncludeIndels(boolean includeIndels)