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 void
close()
Does nothing.long
getAcceptedCount()
Returns the number of records returned since creation of the last call to resetStatistics.double
getAcceptedFraction()
Gets the fraction of records accepted since creation or the last call to resetStatistics().long
getDiscardedCount()
Returns the number of records discarded since creation of the last call to resetStatistics.double
getDiscardedFraction()
Gets the fraction of records discarded since creation or the last call to resetStatistics().long
getSeenCount()
Returns the number of records seen, including accepted and discarded, since creation of the last call to resetStatistics.double
getTargetProportion()
Gets the target proportion of records that should be retained during downsampling.boolean
isHigherAccuracy()
Indicates whether or not the strategy implemented by this DownsamplingIterator makes any effort to increase accuracy beyond random sampling (i.e.protected void
recordAcceptedRecord()
Method for subclasses to record a specific record as being accepted.protected void
recordAcceptedRecords(long n)
Record one or more records as having been discarded.protected void
recordDiscardedRecord()
Method for subclasses to record a record as being discarded.protected void
recordDiscardRecords(long n)
Record one or more records as having been discarded.void
remove()
Not supported.void
resetStatistics()
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in 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).
-
-