Package htsjdk.samtools

# Class QueryInterval

java.lang.Object
htsjdk.samtools.QueryInterval

All Implemented Interfaces:
  `Comparable<QueryInterval>`

public class QueryInterval extends Object implements Comparable<QueryInterval>
Interval relative to a reference, for querying a BAM file.

## Field Summary

Fields
Modifier and Type
Field
Description
`final int`
`end`
1-based, inclusive.
`final int`
`referenceIndex`
Index of reference sequence, based on the sequence dictionary of the BAM file being queried.
`final int`
`start`
1-based, inclusive

## Constructor Summary

Constructors
Constructor
Description
`QueryInterval(int referenceIndex, int start, int end)`

## Method Summary

Modifier and Type
Method
Description
`static void`
`assertIntervalsOptimized(QueryInterval[] intervals)`
`int`
`compareTo(QueryInterval other)`
`boolean`
`endsAtStartOf(QueryInterval other)`
`boolean`
`equals(Object o)`
`int`
`hashCode()`
`static QueryInterval[]`
`optimizeIntervals(QueryInterval[] inputIntervals)`
`boolean`
`overlaps(QueryInterval other)`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### referenceIndex

public final int referenceIndex
Index of reference sequence, based on the sequence dictionary of the BAM file being queried.

### start

public final int start
1-based, inclusive

### end

public final int end
1-based, inclusive. If invalid input: '<'= 0, implies that the interval goes to the end of the reference sequence

## Constructor Details

### QueryInterval

public QueryInterval(int referenceIndex, int start, int end)

## Method Details

### compareTo

public int compareTo(QueryInterval other)

Specified by:
  `compareTo` in interface `Comparable<QueryInterval>`

### endsAtStartOf

public boolean endsAtStartOf(QueryInterval other)

Returns:
  true if both are on same reference, and other starts exactly before this ends.

### overlaps

public boolean overlaps(QueryInterval other)

Returns:
  true if both are on same reference, and the overlap.

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### optimizeIntervals

public static QueryInterval[] optimizeIntervals(QueryInterval[] inputIntervals)

Parameters:
  `inputIntervals` - WARNING: This list is modified (sorted) by this method.
Returns:
  Ordered list of intervals in which abutting and overlapping intervals are merged.

### assertIntervalsOptimized

public static void assertIntervalsOptimized(QueryInterval[] intervals)

Throws:
  `IllegalArgumentException` - if the intervals are not optimized
See Also:
  - `optimizeIntervals(QueryInterval[])`

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`