Class SRAIterator

    • Constructor Detail

      • SRAIterator

        public SRAIterator​(SRAAccession accession,
                           ngs.ReadCollection run,
                           SAMFileHeader header,
                           ReferenceCache cachedReferences,
                           SRAIterator.RecordRangeInfo recordRangeInfo,
                           List<Chunk> chunks)
        Parameters:
        run - opened read collection
        header - sam header
        cachedReferences - list of cached references shared among all iterators from a single SRAFileReader
        recordRangeInfo - info about record ranges withing SRA archive
        chunks - used to determine which records the iterator should return
    • Method Detail

      • getRecordsRangeInfo

        public static SRAIterator.RecordRangeInfo getRecordsRangeInfo​(ngs.ReadCollection run)
        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.
        Specified by:
        hasNext in interface Iterator<SAMRecord>
        Returns:
        true if there are more records available
      • next

        public SAMRecord next()
        Call hasNext to make sure that one of inner iterators points to the next record, the retrieve the record from one of them.
        Specified by:
        next in interface Iterator<SAMRecord>
        Returns:
        lazy SRA record
      • assertSorted

        public SAMRecordIterator assertSorted​(SAMFileHeader.SortOrder sortOrder)
        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 interface SAMRecordIterator
        Parameters:
        sortOrder - The order in which records are expected to be returned
        Returns:
        This SAMRecordIterator
      • setValidationStringency

        public void setValidationStringency​(ValidationStringency validationStringency)