/*****************************************************************************/ // 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). /*****************************************************************************/ #include #include #include "statistics/Pattern_Info.h" /*****************************************************************************/ Pattern_Info::Pattern_Info() : my_num_patterns(0) { } /*****************************************************************************/ Pattern_Info::~Pattern_Info() { } /*****************************************************************************/ Pattern_Info& Pattern_Info::add_pattern(const std::string& pattern_str) { if (my_num_patterns == MAX_NUM_PATTERNS_TO_LIST_PER_RANK) { my_str_junk_map.clear(); } ++my_num_patterns; if (my_num_patterns <= MAX_NUM_PATTERNS_TO_LIST_PER_RANK) { my_str_junk_map[pattern_str] = 'x'; } return *this; } /*****************************************************************************/ class Str_Separation { public: Str_Separation(const std::string& separ_str, bool separate_first=false) : my_separ_str(separ_str), my_curr_separ_str(separate_first ? separ_str : std::string()) { } const std::string operator()(Pattern_Info::Str_Junk_Map_Ele str_junk_ele) { const std::string ret_str(my_curr_separ_str + str_junk_ele.first); my_curr_separ_str = my_separ_str; return ret_str; } private: std::string my_separ_str; std::string my_curr_separ_str; }; /*****************************************************************************/ std::ostream& operator<<(std::ostream& ostrm, const Pattern_Info& pattern_info) { if (pattern_info.my_num_patterns > Pattern_Info::MAX_NUM_PATTERNS_TO_LIST_PER_RANK) { ostrm << pattern_info.my_num_patterns << " sequences"; } else { Str_Separation str_separation(" "); std::transform(pattern_info.my_str_junk_map.begin(), pattern_info.my_str_junk_map.end(), std::ostream_iterator(ostrm), str_separation); // For exact match to legacy behaviour. ostrm << ' '; } return ostrm; } /*****************************************************************************/