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
Fields Modifier and Type Field Description protected boolean
includeIndels
If true, include indels in the LocusInfo
-
Constructor Summary
Constructors Constructor Description AbstractLocusIterator(SamReader samReader, IntervalList intervalList, boolean useIndex)
Prepare to iterate through the given SAM records, skipping non-primary alignments
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes innerSamIterator>.
protected Interval
getCurrentInterval()
SAMFileHeader
getHeader()
protected List<Interval>
getIntervals()
int
getMappingQualityScoreCutoff()
int
getMaxReadsToAccumulatePerLocus()
int
getQualityScoreCutoff()
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
isEmitUncoveredLoci()
boolean
isIncludeIndels()
boolean
isIncludeNonPfReads()
Iterator<K>
iterator()
K
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 bases-
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.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
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 sortedintervalList
- Either the list of desired intervals, or null. Note that if an intervalList is passed in that is not coordinate sorted, it will eventually be coordinated sorted by this class.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 Detail
-
getHeader
public SAMFileHeader getHeader()
-
iterator
public Iterator<K> 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
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 interfaceIterator<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 interfaceIterator<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).
-
getCurrentInterval
protected Interval getCurrentInterval()
-
isIncludeIndels
public boolean isIncludeIndels()
-
setIncludeIndels
public void setIncludeIndels(boolean includeIndels)
-
-