Package htsjdk.samtools
Class SRAIterator
java.lang.Object
htsjdk.samtools.SRAIterator
- All Implemented Interfaces:
SAMRecordIterator
,CloseableIterator<SAMRecord>
,Closeable
,AutoCloseable
,Iterator<SAMRecord>
SRA iterator which returns SAMRecords for requested list of chunks
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Describes record ranges info needed for emulating BAM index -
Constructor Summary
ConstructorsConstructorDescriptionSRAIterator
(SRAAccession accession, ngs.ReadCollection run, SAMFileHeader header, ReferenceCache cachedReferences, SRAIterator.RecordRangeInfo recordRangeInfo, List<Chunk> chunks) -
Method Summary
Modifier and TypeMethodDescriptionassertSorted
(SAMFileHeader.SortOrder sortOrder) Establishes that records returned by this iterator are expected to be in the specified sort order.void
close()
Should be implemented to close/release any underlying resources.static SRAIterator.RecordRangeInfo
getRecordsRangeInfo
(ngs.ReadCollection run) Loads record ranges needed for emulating BAM indexboolean
hasNext()
NGS iterators implement a single method "nextObject" which return true if the operation was successful or false if there are no more objects available.next()
Call hasNext to make sure that one of inner iterators points to the next record, the retrieve the record from one of them.void
remove()
void
setValidationStringency
(ValidationStringency validationStringency) 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
-
Constructor Details
-
SRAIterator
public SRAIterator(SRAAccession accession, ngs.ReadCollection run, SAMFileHeader header, ReferenceCache cachedReferences, SRAIterator.RecordRangeInfo recordRangeInfo, List<Chunk> chunks) - Parameters:
run
- opened read collectionheader
- sam headercachedReferences
- list of cached references shared among all iterators from a single SRAFileReaderrecordRangeInfo
- info about record ranges withing SRA archivechunks
- used to determine which records the iterator should return
-
-
Method Details
-
getRecordsRangeInfo
Loads record ranges needed for emulating BAM index- Parameters:
run
- read collection- Returns:
- record ranges
-
hasNext
public boolean hasNext()NGS iterators implement a single method "nextObject" which return true if the operation was successful or false if there are no more objects available. That means that there is no way to check "hasNext" without actually moving the iterator forward. Because of that all the logic of moving iterator forward is actually happens in "hasNext". Here is explanation of how it works: Iterator holds a list of chunks of requested records. Here we have chunksIterator that walks though that list. We walk though that list using chunksIterator. If current chunk can represent aligned fragments then we create SRAAlignmentIterator iterator, pass the chunk into it and ask if it can find any record. If record was found, we say that we have next; otherwise we check if the chunk can represent unaligned fragments and then create SRAUnalignmentIterator if so and do the same steps as with alignemnt iterator. If record was not found in both SRAAlignmentIterator and SRAUnalignmentIterator (it is possible that reference range has no alignments or that reads range has all aligned fragment), we try the next chunk. When there are no more chunks and both iterators have no more records we return false. -
next
Call hasNext to make sure that one of inner iterators points to the next record, the retrieve the record from one of them. -
remove
public void remove() -
close
public void close()Description copied from interface:CloseableIterator
Should be implemented to close/release any underlying resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseableIterator<SAMRecord>
-
assertSorted
Description copied from interface:SAMRecordIterator
Establishes that records returned by this iterator are expected to be in the specified sort order. If this method has been called, then implementers must throw an IllegalStateException from next() when a record is read that violates the sort order. This method may be called multiple times over the course of an iteration, changing the expected sort, if desired -- from the time it is called, it validates whatever sort is set, or stops validating if it is set to null or SAMFileHeader.SortOrder.unsorted. If this method is not called, then no validation of the iterated records is done.- Specified by:
assertSorted
in interfaceSAMRecordIterator
- Parameters:
sortOrder
- The order in which records are expected to be returned- Returns:
- This SAMRecordIterator
-
setValidationStringency
-