Store refID/position, but does not store values < 0. More...
#include <PosList.h>
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 |
Store refID/position, but does not store values < 0.
Definition at line 24 of file PosList.h.
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.
00043 { 00044 // Check for negative numbers, if so, just return. 00045 if((refID < 0) || (refPosition < 0)) 00046 { 00047 return; 00048 } 00049 00050 // If the position list is smaller or equal to refID, it cannot handle an index, 00051 // so increase the size. 00052 if(myPosList.size() <= (unsigned int)refID) 00053 { 00054 // The position list does not currently have space for this reference id, 00055 // so add it. 00056 myPosList.resize(refID+1, std::vector<bool>(myNumPos, false)); 00057 myNumRefs = refID + 1; 00058 } 00059 00060 // The matrix is now sized for this reference id. 00061 // Check to see if this id holds this position. 00062 if((myPosList[refID]).size() <= (unsigned int)refPosition) 00063 { 00064 // The index for this position has not yet been created, 00065 // so increase the size for it. 00066 if(myNumPos <= refPosition) 00067 { 00068 // Our number of positions is smaller than 00069 // the current reference id, so reset 00070 // myNumPos for future use to be this position +1. 00071 myNumPos = refPosition + 1; 00072 } 00073 // Increase the size for this reference id to hold at least myNumPos. 00074 (myPosList[refID]).resize(myNumPos, false); 00075 } 00076 00077 // It now holds this position, so set it to true. 00078 myPosList[refID][refPosition] = true; 00079 }
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.
Referenced by Pileup< PILEUP_TYPE, FUNC_CLASS >::processAlignmentRegion().
00082 { 00083 // Check for negative numbers, if so, just return false, not found. 00084 if((refID < 0) || (refPosition < 0)) 00085 { 00086 return(false); 00087 } 00088 bool found = false; 00089 try 00090 { 00091 if((myPosList.at(refID)).at(refPosition)) 00092 { 00093 found = true; 00094 } 00095 } 00096 catch (std::out_of_range& oor) 00097 { 00098 // Nothing to do here, if it was out of range, then 00099 // the position was not found (already set to false). 00100 } 00101 return(found); 00102 }