libStatGen Software 1
Loading...
Searching...
No Matches
PosList Class Reference

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

#include <PosList.h>

Inheritance diagram for PosList:
Collaboration diagram for PosList:

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.

22 : myNumRefs(24),
23 myNumPos(100)
24{
25 initVars();
26}

◆ 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.

30 : myNumRefs(numRefs),
31 myNumPos(numPositions)
32{
33 initVars();
34}

◆ ~PosList()

PosList::~PosList ( )
virtual

Destructor.

Definition at line 36 of file PosList.cpp.

37{
38 myPosList.clear();
39}

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.

43{
44 // Check for negative numbers, if so, just return.
45 if((refID < 0) || (refPosition < 0))
46 {
47 return;
48 }
49
50 // If the position list is smaller or equal to refID, it cannot handle an index,
51 // so increase the size.
52 if(myPosList.size() <= (unsigned int)refID)
53 {
54 // The position list does not currently have space for this reference id,
55 // so add it.
56 myPosList.resize(refID+1, std::vector<bool>(myNumPos, false));
57 myNumRefs = refID + 1;
58 }
59
60 // The matrix is now sized for this reference id.
61 // Check to see if this id holds this position.
62 if((myPosList[refID]).size() <= (unsigned int)refPosition)
63 {
64 // The index for this position has not yet been created,
65 // so increase the size for it.
66 if(myNumPos <= refPosition)
67 {
68 // Our number of positions is smaller than
69 // the current reference id, so reset
70 // myNumPos for future use to be this position +1.
71 myNumPos = refPosition + 1;
72 }
73 // Increase the size for this reference id to hold at least myNumPos.
74 (myPosList[refID]).resize(myNumPos, false);
75 }
76
77 // It now holds this position, so set it to true.
78 myPosList[refID][refPosition] = true;
79}

◆ 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.

82{
83 // Check for negative numbers, if so, just return false, not found.
84 if((refID < 0) || (refPosition < 0))
85 {
86 return(false);
87 }
88 bool found = false;
89 try
90 {
91 if((myPosList.at(refID)).at(refPosition))
92 {
93 found = true;
94 }
95 }
96 catch (std::out_of_range& oor)
97 {
98 // Nothing to do here, if it was out of range, then
99 // the position was not found (already set to false).
100 }
101 return(found);
102}

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

◆ initVars()

void PosList::initVars ( )
protected

Definition at line 105 of file PosList.cpp.

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

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: