Class SamReader.PrimitiveSamReaderToSamReaderAdapter

    • Method Detail

      • queryOverlapping

        public SAMRecordIterator queryOverlapping​(String sequence,
                                                  int start,
                                                  int end)
        Description copied from interface: SamReader
        Iterate over records that overlap the given interval. Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        queryOverlapping in interface SamReader
        Parameters:
        sequence - Reference sequence of interest.
        start - 1-based, inclusive start of interval of interest. Zero implies start of the reference sequence.
        end - 1-based, inclusive end of interval of interest. Zero implies end of the reference sequence.
        Returns:
        Iterator over the SAMRecords overlapping the interval.
      • queryOverlapping

        public SAMRecordIterator queryOverlapping​(QueryInterval[] intervals)
        Description copied from interface: SamReader
        Iterate over records that overlap any of the given intervals. This may be more efficient than querying each interval separately, because multiple reads of the same SAMRecords is avoided.

        Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        queryOverlapping in interface SamReader
        Parameters:
        intervals - Intervals to be queried. The intervals must be optimized, i.e. in order, with overlapping and abutting intervals merged. This can be done with QueryInterval.optimizeIntervals(htsjdk.samtools.QueryInterval[])
      • queryContained

        public SAMRecordIterator queryContained​(String sequence,
                                                int start,
                                                int end)
        Description copied from interface: SamReader
        Iterate over records that are contained in the given interval. Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        queryContained in interface SamReader
        Parameters:
        sequence - Reference sequence of interest.
        start - 1-based, inclusive start of interval of interest. Zero implies start of the reference sequence.
        end - 1-based, inclusive end of interval of interest. Zero implies end of the reference sequence.
        Returns:
        Iterator over the SAMRecords contained in the interval.
      • queryContained

        public SAMRecordIterator queryContained​(QueryInterval[] intervals)
        Description copied from interface: SamReader
        Iterate over records that are contained in the given interval. This may be more efficient than querying each interval separately, because multiple reads of the same SAMRecords is avoided.

        Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        queryContained in interface SamReader
        Parameters:
        intervals - Intervals to be queried. The intervals must be optimized, i.e. in order, with overlapping and abutting intervals merged. This can be done with QueryInterval.optimizeIntervals(htsjdk.samtools.QueryInterval[])
        Returns:
        Iterator over the SAMRecords contained in any of the intervals.
      • queryMate

        public SAMRecord queryMate​(SAMRecord rec)
        Wraps the boilerplate code for querying a record's mate, which is common across many implementations.
        Specified by:
        queryMate in interface SamReader
        Parameters:
        rec - Record for which mate is sought. Must be a paired read.
        Returns:
      • hasBrowseableIndex

        public boolean hasBrowseableIndex()
        Description copied from interface: SamReader.Indexing
        Returns true if the supported index is browseable, meaning the bins in it can be traversed and chunk data inspected and retrieved.
        Specified by:
        hasBrowseableIndex in interface SamReader.Indexing
        Returns:
        True if the index supports the BrowseableBAMIndex interface. False otherwise.
      • getBrowseableIndex

        public BrowseableBAMIndex getBrowseableIndex()
        Description copied from interface: SamReader.Indexing
        Gets an index tagged with the BrowseableBAMIndex interface. Throws an exception if no such index is available.
        Specified by:
        getBrowseableIndex in interface SamReader.Indexing
        Returns:
        An index with a browseable interface, if possible.
      • iterator

        public SAMRecordIterator iterator()
        Description copied from interface: SamReader
        Iterate through file in order. For a SamReader constructed from an InputStream, and for any SAM file, a 2nd iteration starts where the 1st one left off. For a BAM constructed from a SeekableStream or File, each new iteration starts at the first record.

        Only a single open iterator on a SAM or BAM file may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Specified by:
        iterator in interface Iterable<SAMRecord>
        Specified by:
        iterator in interface SamReader
      • getResourceDescription

        public String getResourceDescription()
        Specified by:
        getResourceDescription in interface SamReader
        Returns:
        a human readable description of the resource backing this sam reader
      • isQueryable

        public boolean isQueryable()
        Specified by:
        isQueryable in interface SamReader
        Returns:
        true if this source can be queried by interval, regardless of whether it has an index
      • hasIndex

        public boolean hasIndex()
        Specified by:
        hasIndex in interface SamReader
        Returns:
        true if ths is a BAM file, and has an index
      • getIndex

        public BAMIndex getIndex()
        Description copied from interface: SamReader.Indexing
        Retrieves the index for the given file type. Ensure that the index is of the specified type.
        Specified by:
        getIndex in interface SamReader.Indexing
        Returns:
        An index of the given type.
      • query

        public SAMRecordIterator query​(QueryInterval[] intervals,
                                       boolean contained)
        Description copied from interface: SamReader
        Iterate over records that match one of the given intervals. This may be more efficient than querying each interval separately, because multiple reads of the same SAMRecords is avoided.

        Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first. You can use a second SamReader to iterate in parallel over the same underlying file.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match an interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        query in interface SamReader
        Parameters:
        intervals - Intervals to be queried. The intervals must be optimized, i.e. in order, with overlapping and abutting intervals merged. This can be done with QueryInterval.optimizeIntervals(htsjdk.samtools.QueryInterval[])
        contained - If true, each SAMRecord returned is will have its alignment completely contained in one of the intervals of interest. If false, the alignment of the returned SAMRecords need only overlap one of the intervals of interest.
        Returns:
        Iterator over the SAMRecords matching the interval.
      • query

        public SAMRecordIterator query​(String sequence,
                                       int start,
                                       int end,
                                       boolean contained)
        Description copied from interface: SamReader
        Iterate over records that match the given interval. Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first. You can use a second SamReader to iterate in parallel over the same underlying file.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that is in the query region.

        Specified by:
        query in interface SamReader
        Parameters:
        sequence - Reference sequence of interest.
        start - 1-based, inclusive start of interval of interest. Zero implies start of the reference sequence.
        end - 1-based, inclusive end of interval of interest. Zero implies end of the reference sequence.
        contained - If true, each SAMRecord returned will have its alignment completely contained in the interval of interest. If false, the alignment of the returned SAMRecords need only overlap the interval of interest.
        Returns:
        Iterator over the SAMRecords matching the interval.
      • queryAlignmentStart

        public SAMRecordIterator queryAlignmentStart​(String sequence,
                                                     int start)
        Description copied from interface: SamReader
        Iterate over records that map to the given sequence and start at the given position. Only valid to call this if hasIndex() == true.

        Only a single open iterator on a given SamReader may be extant at any one time. If you want to start a second iteration, the first one must be closed first.

        Note that indexed lookup is not perfectly efficient in terms of disk I/O. I.e. some SAMRecords may be read and then discarded because they do not match the interval of interest.

        Note that an unmapped read will be returned by this call if it has a coordinate for the purpose of sorting that matches the arguments.

        Specified by:
        queryAlignmentStart in interface SamReader
        Parameters:
        sequence - Reference sequence of interest.
        start - Alignment start of interest.
        Returns:
        Iterator over the SAMRecords with the given alignment start.