diff options
author | Pjotr Prins | 2018-08-25 11:32:46 +0000 |
---|---|---|
committer | Pjotr Prins | 2018-08-25 11:32:46 +0000 |
commit | be551a1b3c324dc96750cf992b6a5784e2b92ec7 (patch) | |
tree | 01830a02558f85b33fcb6ce7d54d1daab28ca669 /src/gemma_io.cpp | |
parent | a24297bb1cb686d3630db3a0da8fa8a2079ad178 (diff) | |
download | pangemma-be551a1b3c324dc96750cf992b6a5784e2b92ec7.tar.gz |
Number format checking in strict mode. Also fixes #149
Diffstat (limited to 'src/gemma_io.cpp')
-rw-r--r-- | src/gemma_io.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
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<string> 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<string> 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<string> 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); } } |