From be551a1b3c324dc96750cf992b6a5784e2b92ec7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 25 Aug 2018 11:32:46 +0000 Subject: Number format checking in strict mode. Also fixes #149 --- src/gemma_io.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gemma_io.cpp') diff --git a/src/gemma_io.cpp b/src/gemma_io.cpp index fad3e47..4d8f6bc 100644 --- a/src/gemma_io.cpp +++ b/src/gemma_io.cpp @@ -1368,7 +1368,7 @@ bool BimbamKin(const string file_geno, const set ksnps, enforce_msg(infile, "error reading genotype file"); size_t n_miss; - double d, geno_mean, geno_var; + double geno_mean, geno_var; // setKSnp and/or LOCO support bool process_ksnps = ksnps.size(); @@ -1433,10 +1433,9 @@ bool BimbamKin(const string file_geno, const set ksnps, gsl_vector_set(geno_miss, i, 0); n_miss++; } else { - d = stod(field); - // make sure genotype field contains a number - if (field != "0" && field != "0.0") - enforce_str(d != 0.0f, field); + double d = stod(field); + if (is_strict_mode() && d == 0.0) + enforce_is_float(field); // rule out non NA and non-float fields gsl_vector_set(geno, i, d); gsl_vector_set(geno_miss, i, 1); geno_mean += d; @@ -1486,7 +1485,7 @@ bool BimbamKin(const string file_geno, const set ksnps, debug_msg("begin transpose"); for (size_t i = 0; i < ni_total; ++i) { for (size_t j = 0; j < i; ++j) { - d = gsl_matrix_get(matrix_kin, j, i); + double d = gsl_matrix_get(matrix_kin, j, i); gsl_matrix_set(matrix_kin, i, j, d); } } -- cgit v1.2.3