IndexBase Class Referenceabstract
Inheritance diagram for IndexBase:
[legend]
Collaboration diagram for IndexBase:
[legend]

## Classes

class | Bin
class | Reference

## Public Member Functions

virtual void | resetIndex ()
| Reset the member data for a new index file. More...
virtual StatGenStatus::Status | readIndex (const char *filename)=0
int32_t | getNumRefs () const
| Get the number of references in this index. More...
bool | getMinOffsetFromLinearIndex (int32_t refID, uint32_t position, uint64_t &minOffset) const

## Static Protected Member Functions

static void | getBinsForRegion (uint32_t start, uint32_t end, bool binMap[MAX_NUM_BINS+1])

## Protected Attributes

int32_t | n_ref
std::vector< Reference > | myRefs

## Static Protected Attributes

static const uint32_t | MAX_NUM_BINS = 37450
static const uint32_t | MAX_POSITION = 536870911
static const uint32_t | LINEAR_INDEX_SHIFT = 14

## Detailed Description

Definition at line 62 of file IndexBase.h.

## Constructor & Destructor Documentation

## IndexBase()

IndexBase::IndexBase | ( |  | ) |

Definition at line 116 of file IndexBase.cpp.

: n_ref(0)
{
myRefs.clear();
}

## ~IndexBase()

IndexBase::~IndexBase | ( |  | ) |

virtual

Definition at line 124 of file IndexBase.cpp.

{
}

## Member Function Documentation

## getBinsForRegion()

void IndexBase::getBinsForRegion | ( | uint32_t | start,
|  | uint32_t | end,
|  | bool | binMap[MAX_NUM_BINS+1]
| ) |  |

static protected

Definition at line 148 of file IndexBase.cpp.

{
for(uint32_t index = 0; index < MAX_NUM_BINS+1; index++)
{
binMap[index] = false;
}
uint32_t binNum = 0;
--end;
// Check if beg/end go too high, set to max position.
if(start > MAX_POSITION)
{
start = MAX_POSITION;
}
if(end > MAX_POSITION)
{
end = MAX_POSITION;
}
// Turn on bins.
binMap[binNum] = true;
for (binNum = 1 + (start>>26); binNum <= 1 + (end>>26); ++binNum)
binMap[binNum] = true;
for (binNum = 9 + (start>>23); binNum <= 9 + (end>>23); ++binNum)
binMap[binNum] = true;
for (binNum = 73 + (start>>20); binNum <= 73 + (end>>20); ++binNum)
binMap[binNum] = true;
for (binNum = 585 + (start>>17); binNum <= 585 + (end>>17); ++binNum)
binMap[binNum] = true;
for (binNum = 4681 + (start>>14); binNum <= 4681 + (end>>14); ++binNum)
binMap[binNum] = true;
}

## getMinOffsetFromLinearIndex()

bool IndexBase::getMinOffsetFromLinearIndex | ( | int32_t | refID,
|  | uint32_t | position,
|  | uint64_t & | minOffset
| ) |  | const

Definition at line 185 of file IndexBase.cpp.

{
int32_t linearIndex = position >> LINEAR_INDEX_SHIFT;
minOffset = 0;
if(refID > n_ref)
{
// out of range of the references, return false.
return(false);
}
// Check to see if the position is out of range of the linear index.
int32_t linearOffsetSize = myRefs[refID].n_intv;
// If there are no entries in the linear index, return false.
// Or if the linear index is not large enough to include
// the start block, then there can be no records that cross
// our region, so return false.
if((linearOffsetSize == 0) || (linearIndex >= linearOffsetSize))
{
return(false);
}
// The linear index is specified for this block, so return that value.
minOffset = myRefs[refID].ioffsets[linearIndex];
// If the offset is 0, go to the previous block that has an offset.
// This is due to a couple of bugs in older sam tools indexes.
// 1) they add one to the index location (so when reading those, you
// may be starting earlier than necessary)
// 2) (the bigger issue) They did not include bins 4681-37449 in
// the linear index.
while((minOffset == 0) && (--linearIndex >= 0))
{
minOffset = myRefs[refID].ioffsets[linearIndex];
}
// If the minOffset is still 0 when moving forward,
// check later indices to find a non-zero since we don't want to return
// an offset of 0 since the record can't start at 0 we want to at least
// return the first record position for this reference.
linearIndex = 0;
while((minOffset == 0) && (linearIndex < linearOffsetSize))
{
minOffset = myRefs[refID].ioffsets[linearIndex];
linearIndex++;
}
if(minOffset == 0)
{
// Could not find a valid start position for this reference.
return(false);
}
return(true);
}

## getNumRefs()

int32_t IndexBase::getNumRefs | ( |  | ) | const

Get the number of references in this index.

Returns
  number of references

Definition at line 139 of file IndexBase.cpp.

{
// Return the number of references.
return(myRefs.size());
}

## readIndex()

virtual StatGenStatus::Status IndexBase::readIndex | ( | const char * | filename | ) |

pure virtual

Parameters

  filename | the bam index file to be read.

Returns
  the status of the read.

Implemented in BamIndex, and Tabix.

## resetIndex()

void IndexBase::resetIndex | ( |  | ) |

virtual

Reset the member data for a new index file.

Reimplemented in BamIndex, and Tabix.

Definition at line 130 of file IndexBase.cpp.

{
n_ref = 0;
// Clear the references.
myRefs.clear();
}

Referenced by BamIndex::resetIndex(), and Tabix::resetIndex().

## Member Data Documentation

## LINEAR_INDEX_SHIFT

const uint32_t IndexBase::LINEAR_INDEX_SHIFT = 14

static protected

Definition at line 95 of file IndexBase.h.

## MAX_NUM_BINS

const uint32_t IndexBase::MAX_NUM_BINS = 37450

static protected

Definition at line 87 of file IndexBase.h.

## MAX_POSITION

const uint32_t IndexBase::MAX_POSITION = 536870911

static protected

Definition at line 91 of file IndexBase.h.

## myRefs

std::vector<Reference> IndexBase::myRefs

protected

Definition at line 161 of file IndexBase.h.

## n_ref

int32_t IndexBase::n_ref

protected

Definition at line 158 of file IndexBase.h.

The documentation for this class was generated from the following files:

- general/IndexBase.h
- general/IndexBase.cpp