Class DownsamplingIterator

  • All Implemented Interfaces:
    CloseableIterator<SAMRecord>, Closeable, AutoCloseable, Iterator<SAMRecord>

    public abstract class DownsamplingIterator
    extends Object
    implements CloseableIterator<SAMRecord>
    Abstract base class for all DownsamplingIterators that provides a uniform interface for recording and reporting statistics bout how many records have been kept and discarded. A DownsamplingIterator is an iterator that takes another iterator of SAMRecords and filters out a subset of those records in a random way, while ensuring that all records for a template (i.e. record name) are either retained or discarded. Strictly speaking the proportion parameter applies to templates, though in most instances it is safe to think about it being applied to records.
    • Constructor Detail

      • DownsamplingIterator

        public DownsamplingIterator​(double targetProportion)
        Constructs a downsampling iterator that aims to retain the targetProportion of reads.
    • Method Detail

      • getSeenCount

        public long getSeenCount()
        Returns the number of records seen, including accepted and discarded, since creation of the last call to resetStatistics.
      • getAcceptedCount

        public long getAcceptedCount()
        Returns the number of records returned since creation of the last call to resetStatistics.
      • getDiscardedCount

        public long getDiscardedCount()
        Returns the number of records discarded since creation of the last call to resetStatistics.
      • getDiscardedFraction

        public double getDiscardedFraction()
        Gets the fraction of records discarded since creation or the last call to resetStatistics().
      • getAcceptedFraction

        public double getAcceptedFraction()
        Gets the fraction of records accepted since creation or the last call to resetStatistics().
      • resetStatistics

        public void resetStatistics()
        Resets the statistics for records seen/accepted/discarded.
      • getTargetProportion

        public double getTargetProportion()
        Gets the target proportion of records that should be retained during downsampling.
      • recordDiscardedRecord

        protected final void recordDiscardedRecord()
        Method for subclasses to record a record as being discarded.
      • recordAcceptedRecord

        protected final void recordAcceptedRecord()
        Method for subclasses to record a specific record as being accepted. Null may be passed if a record was discarded but access to the object is no longer available.
      • recordDiscardRecords

        protected final void recordDiscardRecords​(long n)
        Record one or more records as having been discarded.
      • recordAcceptedRecords

        protected final void recordAcceptedRecords​(long n)
        Record one or more records as having been discarded.
      • isHigherAccuracy

        public boolean isHigherAccuracy()
        Indicates whether or not the strategy implemented by this DownsamplingIterator makes any effort to increase accuracy beyond random sampling (i.e. to reduce the delta between the requested proportion of reads and the actually emitted proportion of reads).