about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPjotr Prins2025-12-01 11:32:54 +0100
committerPjotr Prins2025-12-01 11:32:54 +0100
commit9091c780b9816fba987287ece703ec2317d3cc2f (patch)
treecffba4b1b4537bd25241731e3621f001e4257286 /src
parent32a5367f0a0a00bec7e610b74abc899521a75fa5 (diff)
downloadpangemma-9091c780b9816fba987287ece703ec2317d3cc2f.tar.gz
Refactoring
Diffstat (limited to 'src')
-rw-r--r--src/lmm.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/lmm.cpp b/src/lmm.cpp
index e58adc9..6d89f77 100644
--- a/src/lmm.cpp
+++ b/src/lmm.cpp
@@ -1665,13 +1665,9 @@ void LMM::Analyze(std::function< SnpNameValues(size_t) >& fetch_snp,
                   const set<string> gwasnps) {
   clock_t time_start = clock();
 
-  write(W, "W");
-  write(y, "y");
+  checkpoint_nofile("start-lmm-analyze");
   // Subset/LOCO support
   bool process_gwasnps = gwasnps.size();
-  if (process_gwasnps)
-    debug_msg("Analyze subset of SNPs (LOCO)");
-  checkpoint_nofile("start-lmm-analyze");
 
   // Calculate basic quantities.
   size_t n_index = (n_cvt + 2 + 1) * (n_cvt + 2) / 2;
@@ -1875,11 +1871,11 @@ void LMM::mdb_calc_gwa(const gsl_matrix *U, const gsl_vector *eval,
                           const gsl_matrix *W, const gsl_vector *y,
                           const set<string> gwasnps) {
   debug_msg(file_geno);
-  auto infilen = file_geno.c_str();
-  checkpoint("start-read-geno-file",file_geno);
+  auto genofilen = file_geno.c_str();
+  checkpoint("mdb-calc-gwa",file_geno);
 
-  igzstream infile(infilen, igzstream::in);
-  enforce_msg(infile, "error reading genotype file");
+  igzstream genofile(genofilen, igzstream::in);
+  enforce_msg(genofile, "error reading genotype file");
   size_t prev_line = 0;
 
   std::vector <double> gs;
@@ -1890,20 +1886,20 @@ void LMM::mdb_calc_gwa(const gsl_matrix *U, const gsl_vector *eval,
     string line;
     while (prev_line <= num) {
       // also read SNPs that were skipped
-      safeGetline(infile, line);
+      safeGetline(genofile, line);
       prev_line++;
     }
-    char *ch_ptr = strtok_safe2((char *)line.c_str(), " , \t",infilen);
+    char *ch_ptr = strtok_safe2((char *)line.c_str(), " , \t",genofilen);
     // enforce_msg(ch_ptr, "Parsing BIMBAM genofile"); // ch_ptr should not be NULL
 
     auto snp = string(ch_ptr);
-    ch_ptr = strtok_safe2(NULL, " , \t",infilen); // skip column
-    ch_ptr = strtok_safe2(NULL, " , \t",infilen); // skip column
+    ch_ptr = strtok_safe2(NULL, " , \t",genofilen); // skip column
+    ch_ptr = strtok_safe2(NULL, " , \t",genofilen); // skip column
 
     gs.assign (ni_total,nan("")); // wipe values
 
     for (size_t i = 0; i < ni_total; ++i) {
-      ch_ptr = strtok_safe2(NULL, " , \t",infilen);
+      ch_ptr = strtok_safe2(NULL, " , \t",genofilen);
       if (strcmp(ch_ptr, "NA") != 0) {
         gs[i] = atof(ch_ptr);
         if (is_strict_mode() && gs[i] == 0.0)
@@ -1915,8 +1911,8 @@ void LMM::mdb_calc_gwa(const gsl_matrix *U, const gsl_vector *eval,
 
   LMM::Analyze(fetch_snp,U,eval,UtW,Uty,W,y,gwasnps);
 
-  infile.close();
-  infile.clear();
+  genofile.close();
+  genofile.clear();
 }