aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/debug.h22
-rw-r--r--src/io.cpp6
-rw-r--r--src/param.cpp57
-rw-r--r--src/param.h6
-rwxr-xr-xtest/test_suite.sh23
5 files changed, 50 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
diff --git a/src/io.cpp b/src/io.cpp
index 35a59ee..ef6c26a 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -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
diff --git a/test/test_suite.sh b/test/test_suite.sh
index 0d56e31..58e5574 100755
--- a/test/test_suite.sh
+++ b/test/test_suite.sh
@@ -16,6 +16,29 @@ testBslmm() {
assertEquals "4043967139.42" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn2`
}
+testBslmm2() {
+ $gemma -g ../example/mouse_hs1940.geno.txt.gz \
+ -p ../example/mouse_hs1940.pheno.txt \
+ -n 2 -debug \
+ -a ../example/mouse_hs1940.anno.txt \
+ -gk 1 -o mouse_hs1940_CD8_train
+ assertEquals 0 $?
+ $gemma -g ../example/mouse_hs1940.geno.txt.gz \
+ -p ../example/mouse_hs1940.pheno.txt \
+ -n 2 -debug \
+ -epm ./output/mouse_hs1940_CD8_bslmm.param.txt \
+ -emu ./output/mouse_hs1940_CD8_bslmm.log.txt \
+ -ebv ./output/mouse_hs1940_CD8_bslmm.bv.txt \
+ -k ./output/mouse_hs1940_CD8_train.cXX.txt \
+ -predict \
+ -o mouse_hs1940_CD8_prdt_k
+ assertEquals 0 $?
+ outfn=output/$outn.hyp.txt
+ assertEquals "45181.93" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
+ ../bin/gemma -g mouse_hs1940.geno.txt.gz -p mouse_hs1940.pheno.txt -n 4 -epm ./output/mouse_hs1940_CD8_bslmm_cc1.param.txt -emu ./output/mouse_hs1940_CD8_bslmm_cc1.log.txt -predict -o mouse_hs1940_CD8_prdt_cc1
+ exit 1
+}
+
testCenteredRelatednessMatrixKFullLOCO1() {
outn=mouse_hs1940_full_LOCO1
$gemma -g ../example/mouse_hs1940.geno.txt.gz \