Package htsjdk.samtools.util
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 Summary
Modifier and TypeFieldDescriptionprotected boolean
If true, include indels in the LocusInfo -
Constructor Summary
ConstructorDescriptionAbstractLocusIterator
(SamReader samReader, IntervalList intervalList, boolean useIndex) Prepare to iterate through the given SAM records, skipping non-primary alignments -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes innerSamIterator</>.
int
int
int
protected SAMSequenceRecord
getReferenceSequence
(int referenceSequenceIndex) boolean
hasNext()
Returns true if there are more AbstractLocusInfoobjects that can be returned, due to any of the following reasons: 1) there are more aligned reads in the SAM file 2) there are AbstractLocusInfo s 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) boolean
boolean
boolean
iterator()
next()
hasNext() has been fixed so that if it returns true, next() is now guaranteed not to return null.void
remove()
void
setEmitUncoveredLoci
(boolean emitUncoveredLoci) void
setIncludeIndels
(boolean includeIndels) void
setIncludeNonPfReads
(boolean includeNonPfReads) void
setMappingQualityScoreCutoff
(int mappingQualityScoreCutoff) void
setMaxReadsToAccumulatePerLocus
(int maxReadsToAccumulatePerLocus) If set, this will cap the number of reads we accumulate for any given position.void
setQualityScoreCutoff
(int qualityScoreCutoff) void
setSamFilters
(List<SamRecordFilter> samFilters) Controls which, if any, SAMRecords are filtered.protected static boolean
startWithInsertion
(Cigar cigar) Check if cigar start with an insertion, ignoring other operators that do not consume references basesMethods 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.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
includeIndels
protected boolean includeIndelsIf true, include indels in the LocusInfo
-
-
Constructor Details
-
AbstractLocusIterator
Prepare to iterate through the given SAM records, skipping non-primary alignments- Parameters:
samReader
- must be coordinate sortedintervalList
- 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
-
iterator
- Specified by:
iterator
in interfaceIterable<T extends AbstractRecordAndOffset>
- Returns:
- iterator over all/all covered locus position in reference according to
emitUncoveredLoci
value.
-
close
public void close()Closes innerSamIterator</>.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseableIterator<T extends AbstractRecordAndOffset>
-
hasNext
public boolean hasNext()Returns true if there are more AbstractLocusInfoobjects that can be returned, due to any of the following reasons: 1) there are more aligned reads in the SAM file 2) there are AbstractLocusInfo s 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 interfaceIterator<T extends AbstractRecordAndOffset>
-
next
hasNext() has been fixed so that if it returns true, next() is now guaranteed not to return null.- Specified by:
next
in interfaceIterator<T extends AbstractRecordAndOffset>
- Returns:
- information about next locus position in reference sequence
-
getReferenceSequence
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<T extends AbstractRecordAndOffset>
-
startWithInsertion
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
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
-
isIncludeIndels
public boolean isIncludeIndels() -
setIncludeIndels
public void setIncludeIndels(boolean includeIndels)
-