From 2e466787775ded77b65408bdeba2e8ea22320bd7 Mon Sep 17 00:00:00 2001 From: Niema Moshiri Date: Tue, 5 Mar 2024 20:57:11 -0800 Subject: [PATCH] Updated variable types for stability --- argparse.h | 2 +- count.cpp | 10 +++++----- primer.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/argparse.h b/argparse.h index ca04d18..9dc907c 100644 --- a/argparse.h +++ b/argparse.h @@ -12,7 +12,7 @@ struct args_t { //int16_t num_threads = DEFAULT_NUM_THREADS; // number of threads uint8_t min_qual = DEFAULT_MIN_QUAL; // minimum base quality to count base in counts COUNT_T min_depth = DEFAULT_MIN_DEPTH; // minimum depth to call base in consensus - double min_freq = DEFAULT_MIN_FREQ; // minimum frequency to call base in consensus + long double min_freq = DEFAULT_MIN_FREQ; // minimum frequency to call base in consensus char ambig = DEFAULT_AMBIG; // ambiguous symbol char* primer_bed_fn = nullptr; // primer bed filename int16_t primer_offset = DEFAULT_PRIMER_OFFSET; // number of bases after primer to also trim diff --git a/count.cpp b/count.cpp index 0522ccc..f17f40c 100644 --- a/count.cpp +++ b/count.cpp @@ -2,8 +2,8 @@ void write_pos_counts_tsv(std::vector> const & pos_counts, std::ostream & out_file, char delim) { out_file << "Pos" << delim << 'A' << delim << 'C' << delim << 'G' << delim << 'T' << delim << '-' << delim << "Total" << std::endl; - long unsigned int const pos_counts_size = pos_counts.size(); COUNT_T row_sum; - for(long unsigned int pos = 0; pos < pos_counts_size; ++pos) { + uint64_t const pos_counts_size = pos_counts.size(); COUNT_T row_sum; + for(uint64_t pos = 0; pos < pos_counts_size; ++pos) { out_file << pos; row_sum = 0; for(auto & val : pos_counts[pos]) { out_file << delim << val; row_sum += val; @@ -225,10 +225,10 @@ counts_t compute_counts(const char* const in_reads_fn, std::string const & ref, std::string compute_consensus(std::vector> const & pos_counts, std::unordered_map> & ins_counts, args_t const & user_args) { std::string out; out.reserve(FASTA_STRING_RESERVE); - long unsigned int const pos_counts_size = pos_counts.size(); + uint64_t const pos_counts_size = pos_counts.size(); std::unordered_map>::iterator ins_counts_it; - 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) { + char best_pos_base; std::string best_ins_seq = ""; uint64_t best_count; uint64_t tot_depth; + for(uint64_t 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()) { diff --git a/primer.cpp b/primer.cpp index 85553cd..413916c 100644 --- a/primer.cpp +++ b/primer.cpp @@ -34,9 +34,9 @@ std::vector> find_overlapping_primers(uint32_t con } min_max_primer_inds.resize(ref_len, std::make_pair((uint32_t)-1,(uint32_t)-1)); std::vector> primers = read_bed(primer_bed_fn); - unsigned long const NUM_PRIMERS = primers.size(); + uint64_t const NUM_PRIMERS = primers.size(); std::list*> curr_primers; - unsigned long primers_ind = 0; + uint64_t primers_ind = 0; for(uint32_t pos = 0; pos < ref_len; ++pos) { while(!curr_primers.empty() && pos >= curr_primers.front()->second + primer_offset) { curr_primers.pop_front();