[Genabel-commits] r1493 - pkg/ProbABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 20 00:14:56 CET 2013


Author: lckarssen
Date: 2013-12-20 00:14:55 +0100 (Fri, 20 Dec 2013)
New Revision: 1493

Modified:
   pkg/ProbABEL/src/coxph_data.cpp
   pkg/ProbABEL/src/coxph_data.h
   pkg/ProbABEL/src/main.cpp
   pkg/ProbABEL/src/regdata.cpp
   pkg/ProbABEL/src/regdata.h
Log:
- Set the snpnum argument of the regdata() function to const. Because it is constant.
- In the case of the update_snp() function, the snpnum is also const, but the gendata argument is not. Following the cpplint (Google C++ styleguide) warning, references (&) can be confusing when they/their members are changed. Therefore it is considered better to use pointers for 'output' (changing) arguments and (const) references for 'input' (unchanging) arguments. 
This cpplint warning occurs in a lot of places of our code...


Modified: pkg/ProbABEL/src/coxph_data.cpp
===================================================================
--- pkg/ProbABEL/src/coxph_data.cpp	2013-12-19 22:48:03 UTC (rev 1492)
+++ pkg/ProbABEL/src/coxph_data.cpp	2013-12-19 23:14:55 UTC (rev 1493)
@@ -196,7 +196,7 @@
     delete[] passed_sorted;
 }
 
-void coxph_data::update_snp(gendata &gend, const int snpnum) {
+void coxph_data::update_snp(gendata *gend, const int snpnum) {
     /**
      * This is the main part of the fix of bug #1846
      * (C) of the fix:
@@ -221,7 +221,7 @@
             masked_data[i] = 0;
         }
 
-        gend.get_var(snpnum * ngpreds + j, snpdata);
+        gend->get_var(snpnum * ngpreds + j, snpdata);
 
         for (int i = 0; i < nids; i++) {
             X.put(snpdata[i], (ncov - j - 1), order[i]);

Modified: pkg/ProbABEL/src/coxph_data.h
===================================================================
--- pkg/ProbABEL/src/coxph_data.h	2013-12-19 22:48:03 UTC (rev 1492)
+++ pkg/ProbABEL/src/coxph_data.h	2013-12-19 23:14:55 UTC (rev 1493)
@@ -37,7 +37,7 @@
 
     coxph_data(const coxph_data &obj);
     coxph_data(phedata &phed, gendata &gend, const int snpnum);
-    void update_snp(gendata &gend, const int snpnum);
+    void update_snp(gendata *gend, const int snpnum);
     void remove_snp_from_X();
     ~coxph_data();
 

Modified: pkg/ProbABEL/src/main.cpp
===================================================================
--- pkg/ProbABEL/src/main.cpp	2013-12-19 22:48:03 UTC (rev 1492)
+++ pkg/ProbABEL/src/main.cpp	2013-12-19 23:14:55 UTC (rev 1493)
@@ -230,7 +230,7 @@
     // Here we start the analysis for each SNP.
     for (int csnp = 0; csnp < nsnps; csnp++)
     {
-        rgd.update_snp(gtd, csnp);
+        rgd.update_snp(&gtd, csnp);
 
 
         int poly = 1;

Modified: pkg/ProbABEL/src/regdata.cpp
===================================================================
--- pkg/ProbABEL/src/regdata.cpp	2013-12-19 22:48:03 UTC (rev 1492)
+++ pkg/ProbABEL/src/regdata.cpp	2013-12-19 23:14:55 UTC (rev 1493)
@@ -48,8 +48,8 @@
 }
 
 
-regdata::regdata(phedata &phed, gendata &gend, int snpnum,
-                 bool ext_is_interaction_excluded)
+regdata::regdata(phedata &phed, gendata &gend, const int snpnum,
+                 const bool ext_is_interaction_excluded)
 {
     freq        = 0;
     gcount      = 0;
@@ -105,7 +105,7 @@
 }
 
 
-void regdata::update_snp(gendata &gend, int snpnum)
+void regdata::update_snp(gendata *gend, const int snpnum)
 {
     // Reset counter for frequency since it is a new SNP
     gcount = 0;
@@ -121,7 +121,7 @@
             masked_data[i] = 0;
         }
 
-        gend.get_var(snpnum * ngpreds + j, snpdata);
+        gend->get_var(snpnum * ngpreds + j, snpdata);
 
         for (int i = 0; i < nids; i++) {
             X.put(snpdata[i], i, (ncov - j));

Modified: pkg/ProbABEL/src/regdata.h
===================================================================
--- pkg/ProbABEL/src/regdata.h	2013-12-19 22:48:03 UTC (rev 1492)
+++ pkg/ProbABEL/src/regdata.h	2013-12-19 23:14:55 UTC (rev 1493)
@@ -32,10 +32,10 @@
     mematrix<double> Y;
     regdata();
     regdata(const regdata &obj);
-    regdata(phedata &phed, gendata &gend, int snpnum,
-            bool ext_is_interaction_excluded);
+    regdata(phedata &phed, gendata &gend, const int snpnum,
+            const bool ext_is_interaction_excluded);
     mematrix<double> extract_genotypes();
-    void update_snp(gendata &gend, int snpnum);
+    void update_snp(gendata *gend, const int snpnum);
     void remove_snp_from_X();
     regdata get_unmasked_data();
     ~regdata();



More information about the Genabel-commits mailing list