# Class GenomicIndexUtil

java.lang.Object
htsjdk.samtools.GenomicIndexUtil

public class GenomicIndexUtil extends Object
Constants and methods used by BAM and Tribble indices

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BIN_GENOMIC_SPAN`
Reports the total amount of genomic data that any bin can index.
`static final int[]`
`LEVEL_STARTS`
What is the starting bin for each level?
`static final int`
`MAX_BINS`
Reports the maximum number of bins that can appear in a binning index.
`static final int`
`MAX_LINEAR_INDEX_SIZE`
`static final int`
`UNSET_GENOMIC_LOCATION`
E.g.

## Constructor Summary

Constructors
Constructor
Description
`GenomicIndexUtil()`

## Method Summary

Modifier and Type
Method
Description
`static int`
`binTolevel(int bin)`
Return the binning index level for the given bin.
`static String`
`getBinSummaryString(int bin)`
Return a summary string describing the bin level, level size, and genomic territory covered by the bin.
`static int`
`levelToSize(int level)`
Return the binning index bin size for bins in the given bin.
`static int`
`regionToBin(int beg, int end)`
calculate the bin given an alignment in [beg,end) Described in "The Human Genome Browser at UCSC.
`static int`
`regionToBin(int beg, int end, int minShift, int binDepth)`
calculate the bin given an alignment in [beg,end) Described in "The Human Genome Browser at UCSC.
`static BitSet`
`regionToBins(int startPos, int endPos)`
Get candidate bins for the specified region
`static BitSet`
`regionToBins(int startPos, int endPos, int minShift, int binDepth)`
Get candidate bins for the specified region

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### BIN_GENOMIC_SPAN

public static final int BIN_GENOMIC_SPAN
Reports the total amount of genomic data that any bin can index.

See Also:
  - Constant Field Values

### LEVEL_STARTS

public static final int[] LEVEL_STARTS
What is the starting bin for each level?

### MAX_BINS

public static final int MAX_BINS
Reports the maximum number of bins that can appear in a binning index.

See Also:
  - Constant Field Values

### MAX_LINEAR_INDEX_SIZE

public static final int MAX_LINEAR_INDEX_SIZE

### UNSET_GENOMIC_LOCATION

public static final int UNSET_GENOMIC_LOCATION
E.g. for a SAMRecord with no genomic coordinate.

See Also:
  - Constant Field Values

## Constructor Details

### GenomicIndexUtil

public GenomicIndexUtil()

## Method Details

### binTolevel

public static int binTolevel(int bin)
Return the binning index level for the given bin. Assumes a .bai/.tbi binning scheme (not for use with .csi).

Parameters:
  `bin` - the bin to analyze
Returns:
  the binning index level for the given bin

### levelToSize

public static int levelToSize(int level)
Return the binning index bin size for bins in the given bin. Assumes a .bai/.tbi binning scheme (not for use with .csi).

Parameters:
  `level` - the level to analyze
Returns:
  the size for a bin at the given level

### getBinSummaryString

public static String getBinSummaryString(int bin)
Return a summary string describing the bin level, level size, and genomic territory covered by the bin. For use as debug output.

Parameters:
  `bin` - input bin
Returns:
  A summary string describing the bin. The intended use is for debug output - the string is not intended to be machine readable/parsed and is subject to change.

### regionToBin

public static int regionToBin(int beg, int end)
calculate the bin given an alignment in [beg,end) Described in "The Human Genome Browser at UCSC. Kent & al. doi: 10.1101/gr.229102 "

Parameters:
  `beg` - 0-based start of read (inclusive)
  `end` - 0-based end of read (exclusive)

### regionToBin

public static int regionToBin(int beg, int end, int minShift, int binDepth)
calculate the bin given an alignment in [beg,end) Described in "The Human Genome Browser at UCSC. Kent & al. doi: 10.1101/gr.229102 "

Parameters:
  `beg` - 0-based start of read (inclusive)
  `end` - 0-based end of read (exclusive)
  `minShift` - minimum bin width (2^minShift)
  `binDepth` - number of levels in the binning scheme (including bin 0)

### regionToBins

public static BitSet regionToBins(int startPos, int endPos)
Get candidate bins for the specified region

Parameters:
  `startPos` - 1-based start of target region, inclusive.
  `endPos` - 1-based end of target region, inclusive.
Returns:
  bit set for each bin that may contain SAMRecords in the target region.

### regionToBins

public static BitSet regionToBins(int startPos, int endPos, int minShift, int binDepth)
Get candidate bins for the specified region

Parameters:
  `startPos` - 1-based start of target region, inclusive.
  `endPos` - 1-based end of target region, inclusive.
  `minShift` - minimum bin width (2^minShift).
  `binDepth` - number of levels in the binning scheme (including bin 0).
Returns:
  bit set for each bin that may contain SAMRecords in the target region.