aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPjotr Prins2017-11-30 10:35:54 +0000
committerPjotr Prins2017-11-30 10:36:00 +0000
commit4aa3540f0be29f7db73d2c18dd1f91e514ead490 (patch)
tree3b179b3fb1bb7fda00298815f8313473f9a809b7 /src
parentfacf87d38e47287f80a0c8c091918b32e07600ad (diff)
downloadpangemma-4aa3540f0be29f7db73d2c18dd1f91e514ead490.tar.gz
Fixed never-ending run when analyzing only a single SNP, ref
https://groups.google.com/forum/#!topic/gemma-discussion/a-ommTiucC8
Diffstat (limited to 'src')
-rw-r--r--src/io.cpp11
-rw-r--r--src/lmm.cpp5
2 files changed, 14 insertions, 2 deletions
diff --git a/src/io.cpp b/src/io.cpp
index fb0f0e7..7e682b3 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -52,10 +52,17 @@ using namespace std;
// Print progress bar.
void ProgressBar(string str, double p, double total, double ratio) {
assert(p<=total);
+ assert(p>=0);
+ if (total <= 0.0) return;
const double progress = (100.0 * p / total);
const uint barsize = (int)(progress / 2.0); // characters
- cout << str << " ";
- cout << std::string(barsize,'=');
+ // cout << barsize << endl;
+ // cout << str << " ";
+ // cout << p << "/" << total << endl;
+ assert(barsize < 101); // corrupted data somehow
+ if (barsize > 0) {
+ cout << std::string(barsize,'=');
+ }
cout << std::string(50-barsize,' ');
cout << setprecision(0) << fixed << " " << progress << "%";
if (ratio != -1.0)
diff --git a/src/lmm.cpp b/src/lmm.cpp
index 99a8436..0102ac0 100644
--- a/src/lmm.cpp
+++ b/src/lmm.cpp
@@ -1365,6 +1365,11 @@ void LMM::Analyze(std::function< SnpNameValues(size_t) >& fetch_snp,
};
const auto num_snps = indicator_snp.size();
+ enforce_msg(num_snps > 0,"Zero SNPs to process - data corrupt?");
+ if (num_snps < 50) {
+ cerr << num_snps << " SNPs" << endl;
+ warning_msg("very few SNPs processed");
+ }
const size_t progress_step = (num_snps/50>d_pace ? num_snps/50 : d_pace);
for (size_t t = 0; t < num_snps; ++t) {