Skip to content

Commit 5cdcb79

Browse files
committed
removing more floats and excess code
1 parent 5089336 commit 5cdcb79

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

src/gmm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ std::vector<uint32_t> find_deletion_positions(std::string filename, uint32_t dep
813813
return(deletion_positions);
814814
}
815815

816-
void parse_internal_variants(std::string filename, std::vector<variant> &variants, uint32_t depth_cutoff, float lower_bound, float upper_bound, std::vector<uint32_t> deletion_positions, uint32_t round_val, double quality_threshold){
816+
void parse_internal_variants(std::string filename, std::vector<variant> &variants, uint32_t depth_cutoff, double lower_bound, double upper_bound, std::vector<uint32_t> deletion_positions, uint32_t round_val, double quality_threshold){
817817
/*
818818
* Parses the variants file produced internally by reading bam file line-by-line.
819819
*/
@@ -829,7 +829,7 @@ void parse_internal_variants(std::string filename, std::vector<variant> &variant
829829
std::vector<std::string> row_values;
830830
//split the line by delimiter
831831
uint32_t pos = 0, depth = 0;
832-
float freq = 0, gapped_freq=0, qual=0, std_dev=0;
832+
double freq = 0, gapped_freq=0, qual=0, std_dev=0;
833833
bool version_1_var = false;
834834
std::string flag = "";
835835
std::string amp_flag = "";
@@ -840,7 +840,7 @@ void parse_internal_variants(std::string filename, std::vector<variant> &variant
840840
depth = std::stoi(row_values[7]);
841841
freq = std::stof(row_values[10]);
842842

843-
float multiplier = pow(10, round_val);
843+
double multiplier = pow(10, round_val);
844844
freq = round(freq * multiplier) / multiplier;
845845
qual = std::stof(row_values[9]);
846846

@@ -898,7 +898,7 @@ void parse_internal_variants(std::string filename, std::vector<variant> &variant
898898
} else {
899899
tmp.outside_freq_range = false;
900900
}
901-
if((double)qual < quality_threshold){
901+
if(qual < quality_threshold){
902902
tmp.qual_flag = true;
903903
} else {
904904
tmp.qual_flag = false;

src/gmm.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ struct variant {
2626
uint32_t position;
2727
std::string nuc;
2828
uint32_t depth;
29-
float qual;
30-
float freq;
31-
float gapped_freq = 0;
29+
double qual;
30+
double freq;
31+
double gapped_freq = 0;
3232
int cluster_assigned = -1;
3333
bool version_1_var=false;
34-
float std_dev;
34+
double std_dev;
3535

3636
//for these true means flagged as problematic
3737
bool vague_assignment=false; //cannot be distinguished between two groups
@@ -51,16 +51,16 @@ struct variant {
5151
};
5252
void split(const std::string &s, char delim, std::vector<std::string> &elems);
5353
std::vector<variant> gmm_model(std::string prefix, std::string output_prefix);
54-
void parse_internal_variants(std::string filename, std::vector<variant> &base_variants, uint32_t depth_cutoff, float lower_bound, float upper_bound, std::vector<uint32_t> deletion_positions, uint32_t round_val, double quality_threshold);
55-
std::vector<uint32_t> find_deletion_positions(std::string filename, uint32_t depth_cutoff, float lower_bound, float upper_bound, uint32_t round_val);
56-
std::vector<uint32_t> find_low_quality_positions(std::string filename, uint32_t depth_cutoff, float lower_bound, float upper_bound, float quality_threshold, uint32_t round_val);
54+
void parse_internal_variants(std::string filename, std::vector<variant> &base_variants, uint32_t depth_cutoff, double lower_bound, double upper_bound, std::vector<uint32_t> deletion_positions, uint32_t round_val, double quality_threshold);
55+
std::vector<uint32_t> find_deletion_positions(std::string filename, uint32_t depth_cutoff, double lower_bound, double upper_bound, uint32_t round_val);
56+
std::vector<uint32_t> find_low_quality_positions(std::string filename, uint32_t depth_cutoff, double lower_bound, double upper_bound, double quality_threshold, uint32_t round_val);
5757
std::vector<std::vector<double>> solve_possible_solutions(std::vector<float> tmp_means, double error);
5858
uint32_t smallest_value_index(std::vector<double> values);
5959
std::vector<std::vector<double>> transpose_vector(const std::vector<std::vector<double>>& input_vector);
6060
void assign_variants_simple(std::vector<variant> &variants, std::vector<std::vector<double>> prob_matrix, uint32_t index, std::vector<double> means, uint32_t lower_n);
6161
gaussian_mixture_model retrain_model(uint32_t n, arma::mat data, std::vector<variant> variants, uint32_t lower_n, double var_floor);
6262
void assign_clusters(std::vector<variant> &variants, gaussian_mixture_model gmodel, uint32_t lower_n);
6363
double calculate_mean(const std::vector<double>& data);
64-
void calculate_reference_frequency(std::vector<variant> &variants, std::string filename, uint32_t depth_cutoff, float lower_bound, float upper_bound, std::vector<uint32_t> deletion_positions);
64+
void calculate_reference_frequency(std::vector<variant> &variants, std::string filename, uint32_t depth_cutoff, double lower_bound, double upper_bound, std::vector<uint32_t> deletion_positions);
6565
kmeans_model train_model(uint32_t n, arma::mat data);
6666
#endif

src/interval_tree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <iostream>
2-
32
#include "primer_bed.h"
43
using namespace std;
54

src/primer_bed.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class primer {
2323
std::vector<position> positions; //allele counts for this primer
2424

2525
public:
26-
uint32_t hardcoded_length=300; //CHANGE
2726
std::string get_name();
2827
std::string get_region();
2928
std::vector<position> get_positions();
@@ -64,7 +63,6 @@ primer get_max_end(std::vector<primer> primers);
6463
std::vector<uint32_t> get_nlengths();
6564
std::vector<uint32_t> get_start_positions();
6665
std::vector<bool> get_direction();
67-
std::vector<std::vector<std::string>> get_qnames();
6866
void set_positions(position pos);
6967
std::vector<position> get_positions();
7068
void populate_positions();

src/saga.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ int preprocess_reads(std::string bam, std::string bed, std::string bam_out, std:
631631
}
632632
}
633633
for(uint32_t j=0; j < variants[i].alleles.size(); j++){
634-
float freq = (float)variants[i].alleles[j].depth / ((float)variants[i].depth-del_depth);
635-
float gapped_freq = (float)variants[i].alleles[j].depth / (float)variants[i].depth;
636-
if((float)variants[i].alleles[j].depth == 0){
634+
double freq = (double)variants[i].alleles[j].depth / ((double)variants[i].depth-del_depth);
635+
double gapped_freq = (double)variants[i].alleles[j].depth / (double)variants[i].depth;
636+
if((double)variants[i].alleles[j].depth == 0){
637637
continue;
638638
}
639639
file << "NA\t"; //region

0 commit comments

Comments
 (0)