From f08402b5886756609286b04faaf57696d9631eee Mon Sep 17 00:00:00 2001 From: Niema Moshiri Date: Tue, 5 Mar 2024 20:49:26 -0800 Subject: [PATCH] Fixed insertion issue --- count.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/count.cpp b/count.cpp index e74561f..0522ccc 100644 --- a/count.cpp +++ b/count.cpp @@ -227,20 +227,20 @@ std::string compute_consensus(std::vector> const & pos_co std::string out; out.reserve(FASTA_STRING_RESERVE); long unsigned int const pos_counts_size = pos_counts.size(); std::unordered_map>::iterator ins_counts_it; - char best_pos_base; const std::string* best_ins_seq; long unsigned int best_count; long unsigned int tot_depth; + char best_pos_base; std::string best_ins_seq = ""; long unsigned int best_count; long unsigned int tot_depth; for(long unsigned int pos = 0; pos <= pos_counts_size; ++pos) { // handle insertions before pos ins_counts_it = ins_counts.find(pos); if(ins_counts_it != ins_counts.end()) { - best_count = 0; tot_depth = 0; + best_count = 0; tot_depth = 0; best_ins_seq = ""; for(auto curr_ins : ins_counts_it->second) { tot_depth += curr_ins.second; if(curr_ins.second > best_count) { - best_count = curr_ins.second; best_ins_seq = &(curr_ins.first); + best_count = curr_ins.second; best_ins_seq = curr_ins.first; } } - if(tot_depth >= user_args.min_depth && (best_count/tot_depth) > user_args.min_freq) { - out += (*best_ins_seq); + if(tot_depth >= user_args.min_depth && best_count > tot_depth * user_args.min_freq) { + out += best_ins_seq; } }