Loading...
Searching...
No Matches
PosList Class Reference

Store refID/position, but does not store values < 0. More...

`#include <PosList.h>`

Inheritance diagram for PosList:
[legend]
Collaboration diagram for PosList:
[legend]

## Public Member Functions

| PosList ()
| Constructor.
| PosList (int numRefs, int numPositions)
| Reserves space for numRefs reference ids and numPositions for each id.
virtual | ~PosList ()
| Destructor.
void | addPosition (int refID, int refPosition)
| Add the specified reference id/position (negative values will not be added).
bool | hasPosition (int refID, int refPosition)
| Return whether or not this list contains the specified reference ID and position (negative values will automatically return false).

## Protected Member Functions

| PosList (const PosList &p)
void | initVars ()

## Protected Attributes

std::vector< std::vector< bool > > | myPosList
int | myNumRefs
int | myNumPos

## Detailed Description

Store refID/position, but does not store values < 0.

Definition at line 24 of file PosList.h.

## Constructor & Destructor Documentation

## PosList() [1/2]

PosList::PosList | ( |  | ) |

Constructor.

Definition at line 21 of file PosList.cpp.

: myNumRefs(24),
myNumPos(100)
{
initVars();
}

## PosList() [2/2]

PosList::PosList | ( | int | numRefs,
|  | int | numPositions
| ) |  |

Reserves space for numRefs reference ids and numPositions for each id.

Definition at line 29 of file PosList.cpp.

: myNumRefs(numRefs),
myNumPos(numPositions)
{
initVars();
}

## ~PosList()

PosList::~PosList | ( |  | ) |

virtual

Destructor.

Definition at line 36 of file PosList.cpp.

{
myPosList.clear();
}

## Member Function Documentation

## addPosition()

void PosList::addPosition | ( | int | refID,
|  | int | refPosition
| ) |  |

Add the specified reference id/position (negative values will not be added).

Definition at line 42 of file PosList.cpp.

{
// Check for negative numbers, if so, just return.
if((refID < 0) || (refPosition < 0))
{
return;
}
// If the position list is smaller or equal to refID, it cannot handle an index,
// so increase the size.
if(myPosList.size() <= (unsigned int)refID)
{
// The position list does not currently have space for this reference id,
// so add it.
myPosList.resize(refID+1, std::vector<bool>(myNumPos, false));
myNumRefs = refID + 1;
}
// The matrix is now sized for this reference id.
// Check to see if this id holds this position.
if((myPosList[refID]).size() <= (unsigned int)refPosition)
{
// The index for this position has not yet been created,
// so increase the size for it.
if(myNumPos <= refPosition)
{
// Our number of positions is smaller than
// the current reference id, so reset
// myNumPos for future use to be this position +1.
myNumPos = refPosition + 1;
}
// Increase the size for this reference id to hold at least myNumPos.
(myPosList[refID]).resize(myNumPos, false);
}
// It now holds this position, so set it to true.
myPosList[refID][refPosition] = true;
}

## hasPosition()

bool PosList::hasPosition | ( | int | refID,
|  | int | refPosition
| ) |  |

Return whether or not this list contains the specified reference ID and position (negative values will automatically return false).

Definition at line 81 of file PosList.cpp.

{
// Check for negative numbers, if so, just return false, not found.
if((refID < 0) || (refPosition < 0))
{
return(false);
}
bool found = false;
try
{
if((myPosList.at(refID)).at(refPosition))
{
found = true;
}
}
catch (std::out_of_range& oor)
{
// Nothing to do here, if it was out of range, then
// the position was not found (already set to false).
}
return(found);
}

Referenced by Pileup< PILEUP_TYPE, FUNC_CLASS >::processAlignmentRegion().

## initVars()

void PosList::initVars | ( |  | ) |

protected

Definition at line 105 of file PosList.cpp.

{
myPosList.clear();
myPosList.resize(myNumRefs, std::vector<bool>(myNumPos, false));
}

## Member Data Documentation

## myNumPos

int PosList::myNumPos

protected

Definition at line 54 of file PosList.h.

## myNumRefs

int PosList::myNumRefs

protected

Definition at line 53 of file PosList.h.

## myPosList

std::vector< std::vector<bool> > PosList::myPosList

protected

Definition at line 51 of file PosList.h.

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

- bam/PosList.h
- bam/PosList.cpp