libStatGen Software  1
BaseCount.h
1 /*
2  * Copyright (C) 2010 Regents of the University of Michigan
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __BASE_COUNT_H__
19 #define __BASE_COUNT_H__
20 
21 
22 /// This class is a wrapper around an array that has one index per base and an
23 /// extra index for a total count of all bases. This class is used to keep
24 /// a count of the number of times each index has occurred.
25 /// It can print a percentage of the occurrence of each base against the total
26 /// number of bases.
27 class BaseCount
28 {
29 public:
30  /// Constructor, initializes the array to be all 0s.
31  BaseCount();
32 
33  /// Update the count for the specified index as well as the overall count
34  /// (The last index).
35  /// \return false if the specified index is < 0 or >= myBaseSize-1, otherwise
36  /// returns true. The reason it returns false if it is equal to the size-1
37  /// is because the last index is used to track an overall count.
38  bool incrementCount(int baseIndex);
39 
40  // Print the percentage for each index, 0 to myBaseSize-2, also print
41  // the total number of entries (index myBaseSize-1).
42  void printPercent();
43 
44  private:
45  // Constant to size the array and implement the logic for loops as well
46  // as tracking the last index for keeping an overall count.
47  static const int myBaseSize = 6;
48 
49  // Array used to track the occurences of each index. The last index
50  // tracks the total number of occurrences of all the other indexes.
51  int myBaseCount[myBaseSize];
52 };
53 #endif
BaseCount()
Constructor, initializes the array to be all 0s.
Definition: BaseCount.cpp:23
This class is a wrapper around an array that has one index per base and an extra index for a total co...
Definition: BaseCount.h:27
bool incrementCount(int baseIndex)
Update the count for the specified index as well as the overall count (The last index).
Definition: BaseCount.cpp:38