libStatGen Software  1
BaseCount.h
00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __BASE_COUNT_H__
00019 #define __BASE_COUNT_H__
00020 
00021 
00022 /// This class is a wrapper around an array that has one index per base and an
00023 /// extra index for a total count of all bases.  This class is used to keep
00024 /// a count of the number of times each index has occurred.
00025 /// It can print a percentage of the occurrence of each base against the total 
00026 /// number of bases.
00027 class BaseCount
00028 {
00029 public:
00030     /// Constructor, initializes the array to be all 0s.
00031     BaseCount();
00032 
00033     /// Update the count for the specified index as well as the overall count 
00034     /// (The last index).
00035     /// \return false if the specified index is < 0 or >= myBaseSize-1, otherwise
00036     /// returns true.  The reason it returns false if it is equal to the size-1
00037     /// is because the last index is used to track an overall count.
00038     bool incrementCount(int baseIndex);
00039 
00040     // Print the percentage for each index, 0 to myBaseSize-2, also print
00041     // the total number of entries (index myBaseSize-1).
00042     void printPercent();
00043 
00044  private:
00045     // Constant to size the array and implement the logic for loops as well
00046     // as tracking the last index for keeping an overall count.
00047     static const int myBaseSize = 6;
00048 
00049     // Array used to track the occurences of each index.  The last index
00050     // tracks the total number of occurrences of all the other indexes.
00051     int myBaseCount[myBaseSize];
00052 };
00053 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends