Skip to content

Commit

Permalink
Fixed bug when handling insertions that are in minority count but hav…
Browse files Browse the repository at this point in the history
…e high enough count
  • Loading branch information
niemasd committed Jul 12, 2023
1 parent a8df409 commit 5a5ece2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
viral_consensus
viral_consensus_debug

# input files
*.sam
*.bam
*.cram

# output files
*.json
*.tsv
*.fa

# Prerequisites
*.d

Expand Down
2 changes: 1 addition & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <vector>

// global definitions/constants
#define VERSION "0.0.1"
#define VERSION "0.0.2"

// definitions/constants for argparsing
#define DEFAULT_NUM_THREADS 1
Expand Down
14 changes: 14 additions & 0 deletions count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,21 @@ counts_t compute_counts(const char* const in_reads_fn, std::string const & ref,
while(pos < tmp_uint32) {
curr_base_qual = qqual[qpos];
if(curr_base_qual >= min_qual && (!primer_trim || (!is_reverse && pos >= min_max_primer_inds[src->core.pos].second) || (is_reverse && pos < min_max_primer_inds[src->core.pos].first))) {
// increment the count of the base at this position
++counts.pos_counts[pos][BASE_TO_NUM[(int)qseq[qpos]]];

// increment the insertion count of "" (no insertion) after this position (except the last position)
if(pos < tmp_uint32) {
ins_counts_it = counts.ins_counts.find(pos);
if(ins_counts_it == counts.ins_counts.end()) {
ins_counts_it = counts.ins_counts.emplace(pos, std::unordered_map<std::string, COUNT_T>()).first;
}
ins_counts_pos_it = ins_counts_it->second.find("");
if(ins_counts_pos_it == ins_counts_it->second.end()) {
ins_counts_pos_it = ins_counts_it->second.emplace("", 0).first;
}
++(ins_counts_pos_it->second);
}
}
++qpos; ++pos;
}
Expand Down

0 comments on commit 5a5ece2

Please sign in to comment.