Package htsjdk.samtools
Class DownsamplingIterator
- java.lang.Object
-
- htsjdk.samtools.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 Summary
Constructors Constructor Description DownsamplingIterator(double targetProportion)Constructs a downsampling iterator that aims to retain the targetProportion of reads.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Does nothing.longgetAcceptedCount()Returns the number of records returned since creation of the last call to resetStatistics.doublegetAcceptedFraction()Gets the fraction of records accepted since creation or the last call to resetStatistics().longgetDiscardedCount()Returns the number of records discarded since creation of the last call to resetStatistics.doublegetDiscardedFraction()Gets the fraction of records discarded since creation or the last call to resetStatistics().longgetSeenCount()Returns the number of records seen, including accepted and discarded, since creation of the last call to resetStatistics.doublegetTargetProportion()Gets the target proportion of records that should be retained during downsampling.booleanisHigherAccuracy()Indicates whether or not the strategy implemented by this DownsamplingIterator makes any effort to increase accuracy beyond random sampling (i.e.protected voidrecordAcceptedRecord()Method for subclasses to record a specific record as being accepted.protected voidrecordAcceptedRecords(long n)Record one or more records as having been discarded.protected voidrecordDiscardedRecord()Method for subclasses to record a record as being discarded.protected voidrecordDiscardRecords(long n)Record one or more records as having been discarded.voidremove()Not supported.voidresetStatistics()Resets the statistics for records seen/accepted/discarded.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.samtools.util.CloseableIterator
stream, toList
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
-
-
-
Method Detail
-
close
public void close()
Does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<SAMRecord>
-
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).
-
-