/* * 2012.6.14 a faster version of vervet/src/mapper/CalculateMedianModeFromSAMtoolsDepthOutput.py * */ #include #include #include //sqrt #include #include #include #include //for hash_map #include //for program options #include #include #include "armadillo" //for mean/median calculation #include #include #include #include #include #include //#include #include #include #include #include // This is a typedef for a random number generator. // Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand typedef boost::mt19937 base_generator_type; using namespace arma; using namespace std; using namespace boost; namespace ba = boost::accumulators; namespace po = boost::program_options; class CalculateMedianMeanOfInputColumn{ string inputFname; std::ifstream inputFile; boost::iostreams::filtering_streambuf input; string outputFname; std::ofstream outputFile; int alignmentID; float fractionToSample; int noOfLinesInHeader; int whichColumn; int maxNumberOfSamplings; arma::mat statList; //armadillo matrix storing all the sampled stats __gnu_cxx::hash_map stat2Occurrence; int modeStat; // Define an accumulator set for calculating the mean and the median ba::accumulator_set > acc; public: CalculateMedianMeanOfInputColumn(string _inputFname, string _outputFname, int _alignmentID, float _fractionToSample, int _noOfLinesInHeader, int _whichColumn, int _maxNumberOfSamplings); ~CalculateMedianMeanOfInputColumn(); void run(); };