// -*- c++ -*- /*****************************************************************************/ // Copyright (c) Illumina 2008 // Author: Richard Shaw // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). /*****************************************************************************/ #ifndef NON_BLANK_FILTER_H #define NON_BLANK_FILTER_H /*****************************************************************************/ #include #include #include /*****************************************************************************/ const char the_blank_ch('N'); /*****************************************************************************/ class Non_Blank_Filter { public: Non_Blank_Filter(std::valarray& non_blank_mask, std::string& blank_pattern_str, unsigned int& num_blanks) : my_non_blank_mask(non_blank_mask), my_ele_ind(0), my_blank_pattern_str(blank_pattern_str), my_blank_pattern_ch_iter(my_blank_pattern_str.begin()), my_num_blanks(num_blanks) { } ~Non_Blank_Filter() { } void operator()(const char ch) { // assert(ch != '.'); const bool is_blank(ch == the_blank_ch); my_non_blank_mask[my_ele_ind++] = (is_blank ? 0 : 1); *my_blank_pattern_ch_iter++ = (is_blank ? '.' : 'N'); my_num_blanks += (is_blank ? 1 : 0); } void reset() { my_ele_ind = 0; my_blank_pattern_ch_iter = my_blank_pattern_str.begin(); my_num_blanks = 0; } private: std::valarray& my_non_blank_mask; size_t my_ele_ind; std::string& my_blank_pattern_str; std::string::iterator my_blank_pattern_ch_iter; unsigned int& my_num_blanks; }; /*****************************************************************************/ #endif // ! NON_BLANK_FILTER_H /*****************************************************************************/