diff options
author | Pjotr Prins | 2017-11-09 11:43:53 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-11-09 11:43:53 +0000 |
commit | dbce439e7196ab6882634b270f2675b3ebcb33cd (patch) | |
tree | 4c593fa5594d1482ccbb57bf4d799e9d0529aebe /src | |
parent | 4c158a9bb45e0dec14436a8a19707f485015bf2e (diff) | |
download | pangemma-dbce439e7196ab6882634b270f2675b3ebcb33cd.tar.gz |
Adding tests for bslmm
Diffstat (limited to 'src')
-rw-r--r-- | src/debug.h | 22 | ||||
-rw-r--r-- | src/io.cpp | 6 | ||||
-rw-r--r-- | src/param.cpp | 57 | ||||
-rw-r--r-- | src/param.h | 6 |
4 files changed, 27 insertions, 64 deletions
diff --git a/src/debug.h b/src/debug.h index 29f6c69..6b82b3b 100644 --- a/src/debug.h +++ b/src/debug.h @@ -70,18 +70,18 @@ inline void fail_msg(std::string msg) { #if defined NDEBUG -#define warning_msg(msg) cerr << "**** WARNING: " << msg << endl; -#define debug_msg(msg) -#define assert_issue(is_issue, expr) + #define warning_msg(msg) cerr << "**** WARNING: " << msg << endl; + #define debug_msg(msg) + #define assert_issue(is_issue, expr) #else // DEBUG -#define warning_msg(msg) cerr << "**** WARNING: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl; -#define debug_msg(msg) (is_debug_mode() && cerr << "**** DEBUG: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl); -#define assert_issue(is_issue, expr) \ - ((is_issue) ? enforce_msg(expr,"FAIL: ISSUE assert") : __ASSERT_VOID_CAST(0)) + #define warning_msg(msg) cerr << "**** WARNING: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl; + #define debug_msg(msg) (is_debug_mode() && cerr << "**** DEBUG: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __FUNCTION__ << endl); + #define assert_issue(is_issue, expr) \ + ((is_issue) ? enforce_msg(expr,"FAIL: ISSUE assert") : __ASSERT_VOID_CAST(0)) -#endif +#endif // NDEBUG // enforce works like assert but also when NDEBUG is set (i.e., it // always works). enforce_msg prints message instead of expr @@ -122,4 +122,10 @@ inline void __enforce_fail(const char *__assertion, const char *__file, : __enforce_fail(gsl_strerror(COMBINE(res, __LINE__)), __FILE__, \ __LINE__, __ASSERT_FUNCTION)) +#define enforce_fexists(fn, msg) \ + if (!fn.empty()) \ + enforce_msg(stat(fn.c_str(), &fileInfo) == 0, \ + ((std::string(__STRING(fn)) + " " + fn + ": " + msg).c_str())); + + #endif @@ -2133,19 +2133,23 @@ bool ReadFile_est(const string &file_est, const vector<size_t> &est_column, gamma = 1.0; for (size_t i = 0; i < n + 1; ++i) { if (i == est_column[0] - 1) { + enforce(ch_ptr); rs = ch_ptr; } if (i == est_column[1] - 1) { + enforce(ch_ptr); alpha = atof(ch_ptr); } if (i == est_column[2] - 1) { + enforce(ch_ptr); beta = atof(ch_ptr); } if (i == est_column[3] - 1) { + enforce(ch_ptr); gamma = atof(ch_ptr); } if (i < n) { - ch_ptr = strtok_safe(NULL, " \t"); + ch_ptr = strtok(NULL, " \t"); } } diff --git a/src/param.cpp b/src/param.cpp index 1f583e2..1610615 100644 --- a/src/param.cpp +++ b/src/param.cpp @@ -894,7 +894,6 @@ void PARAM::CheckParam(void) { enforce_fexists(file_snps, "open file"); enforce_fexists(file_ksnps, "open file"); enforce_fexists(file_gwasnps, "open file"); - enforce_fexists(file_log, "open file"); enforce_fexists(file_anno, "open file"); if (!loco.empty()) { @@ -908,54 +907,14 @@ void PARAM::CheckParam(void) { enforce_msg(file_gwasnps.empty(), "LOCO does not allow -gwasnps switch"); } - str = file_kin; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open relatedness matrix file: " << str << endl; - error = true; - } - - str = file_mk; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open relatedness matrix file: " << str << endl; - error = true; - } - - str = file_cvt; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open covariates file: " << str << endl; - error = true; - } - - str = file_gxe; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open environmental covariate file: " << str << endl; - error = true; - } - - str = file_weight; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open the residual weight file: " << str << endl; - error = true; - } - - str = file_epm; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open estimated parameter file: " << str << endl; - error = true; - } - - str = file_ebv; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open estimated breeding value file: " << str - << endl; - error = true; - } - - str = file_read; - if (!str.empty() && stat(str.c_str(), &fileInfo) == -1) { - cout << "error! fail to open total read file: " << str << endl; - error = true; - } + enforce_fexists(file_kin, "open file"); + enforce_fexists(file_mk, "open file"); + enforce_fexists(file_cvt, "open file"); + enforce_fexists(file_gxe, "open file"); + enforce_fexists(file_weight, "open file"); + enforce_fexists(file_epm, "open file"); + enforce_fexists(file_ebv, "open file"); + enforce_fexists(file_read, "open file"); // Check if files are compatible with analysis mode. if (k_mode == 2 && !file_geno.empty()) { diff --git a/src/param.h b/src/param.h index c4316bb..0199d59 100644 --- a/src/param.h +++ b/src/param.h @@ -366,10 +366,4 @@ public: size_t GetabIndex(const size_t a, const size_t b, const size_t n_cvt); -// Helpers for checking parameters -#define enforce_fexists(fn, msg) \ - if (!fn.empty()) \ - enforce_msg(stat(fn.c_str(), &fileInfo) == 0, \ - ((std::string(__STRING(fn)) + ": " + msg).c_str())); - #endif |