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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 28 00:17:30 CEST 2014


Author: lckarssen
Date: 2014-04-28 00:17:28 +0200 (Mon, 28 Apr 2014)
New Revision: 1704

Modified:
   pkg/ProbABEL/src/gendata.cpp
   pkg/ProbABEL/src/gendata.h
   pkg/ProbABEL/src/regdata.cpp
   pkg/ProbABEL/src/regdata.h
Log:
Now that several of member functions of the eigen_mematrix class have been declared const (r1703), several other (member) functions of classed can be declared const as well. For example:
- gendata::getvar(const var, *data) is now a const member function (as it doesn't change the gendata object but it does change the (non-member) variable *data).
- the regdata(phedata&, gendata&, ...) constructor now has const references to the phedata and gendata objects (because, e.g., the eigen_mematrix::put function has been declared a const member function in r1703)


This change only added const keywords to the gendata and regdata classes. Others are still to be done.


Modified: pkg/ProbABEL/src/gendata.cpp
===================================================================
--- pkg/ProbABEL/src/gendata.cpp	2014-04-27 21:47:25 UTC (rev 1703)
+++ pkg/ProbABEL/src/gendata.cpp	2014-04-27 22:17:28 UTC (rev 1704)
@@ -36,8 +36,9 @@
 #include "utilities.h"
 
 
-void gendata::mldose_line_to_matrix(int k, const char *all_numbers,
-                                    int amount_of_numbers){
+void gendata::mldose_line_to_matrix(const int k,
+                                    const char *all_numbers,
+                                    const int amount_of_numbers){
     int j = 0;
     // Check if not a null pointer
     if (!*all_numbers){
@@ -102,7 +103,7 @@
 }
 
 
-void gendata::get_var(int var, double * data)
+void gendata::get_var(const int var, double * data) const
 {
     // Read the genetic data for SNP 'var' and store in the array 'data'
 
@@ -168,11 +169,13 @@
 }
 
 
-void gendata::re_gendata(string filename, unsigned int insnps,
-                         unsigned int ingpreds, unsigned int npeople,
-                         unsigned int nmeasured,
-                         unsigned short int * allmeasured,
-                         std::string * idnames)
+void gendata::re_gendata(const string filename,
+                         const unsigned int insnps,
+                         const unsigned int ingpreds,
+                         const unsigned int npeople,
+                         const unsigned int nmeasured,
+                         const unsigned short int * allmeasured,
+                         const std::string * idnames)
 {
     nsnps = insnps;
     ngpreds = ingpreds;
@@ -224,11 +227,14 @@
 }
 
 
-void gendata::re_gendata(char * fname, unsigned int insnps,
-                         unsigned int ingpreds, unsigned int npeople,
-                         unsigned int nmeasured,
-                         unsigned short int * allmeasured, int skipd,
-                         std::string * idnames)
+void gendata::re_gendata(const char * fname,
+                         const unsigned int insnps,
+                         const unsigned int ingpreds,
+                         const unsigned int npeople,
+                         const unsigned int nmeasured,
+                         const unsigned short int * allmeasured,
+                         const int skipd,
+                         const std::string * idnames)
 {
     nids    = nmeasured;
     nsnps   = insnps;

Modified: pkg/ProbABEL/src/gendata.h
===================================================================
--- pkg/ProbABEL/src/gendata.h	2014-04-27 21:47:25 UTC (rev 1703)
+++ pkg/ProbABEL/src/gendata.h	2014-04-27 22:17:28 UTC (rev 1704)
@@ -41,18 +41,27 @@
     unsigned int nids;
     unsigned int ngpreds;
     gendata();
-    void mldose_line_to_matrix(int k, const char *all_numbers,
-                               int amount_of_numbers);
+    void mldose_line_to_matrix(const int k,
+                               const char *all_numbers,
+                               const int amount_of_numbers);
 
-    void re_gendata(char * fname, unsigned int insnps, unsigned int ingpreds,
-            unsigned int npeople, unsigned int nmeasured,
-            unsigned short int * allmeasured, int skipd, std::string * idnames);
+    void re_gendata(const char * fname,
+                    const unsigned int insnps,
+                    const unsigned int ingpreds,
+                    const unsigned int npeople,
+                    const unsigned int nmeasured,
+                    const unsigned short int * allmeasured,
+                    const int skipd,
+                    const std::string * idnames);
 
-    void re_gendata(string filename, unsigned int insnps, unsigned int ingpreds,
-            unsigned int npeople, unsigned int nmeasured,
-            unsigned short int * allmeasured, std::string * idnames);
+    void re_gendata(const string filename, const unsigned int insnps,
+                    const unsigned int ingpreds,
+                    const unsigned int npeople,
+                    const unsigned int nmeasured,
+                    const unsigned short int * allmeasured,
+                    const std::string * idnames);
 
-    void get_var(int var, double * data);
+    void get_var(const int var, double * data) const;
 
     ~gendata();
 

Modified: pkg/ProbABEL/src/regdata.cpp
===================================================================
--- pkg/ProbABEL/src/regdata.cpp	2014-04-27 21:47:25 UTC (rev 1703)
+++ pkg/ProbABEL/src/regdata.cpp	2014-04-27 22:17:28 UTC (rev 1704)
@@ -96,7 +96,7 @@
  * \param ext_is_interaction_excluded Boolean that shows whether
  * interactions are excluded.
  */
-regdata::regdata(phedata &phed, gendata &gend, const int snpnum,
+regdata::regdata(const phedata &phed, const gendata &gend, const int snpnum,
                  const bool ext_is_interaction_excluded)
 {
     freq        = 0;
@@ -163,7 +163,7 @@
  * @param snpnum Number of the SNP for which the dosage/probability
  * data will be extracted from the gend object.
  */
-void regdata::update_snp(gendata *gend, const int snpnum)
+void regdata::update_snp(const gendata *gend, const int snpnum)
 {
     // Reset counter for frequency since it is a new SNP
     gcount = 0;

Modified: pkg/ProbABEL/src/regdata.h
===================================================================
--- pkg/ProbABEL/src/regdata.h	2014-04-27 21:47:25 UTC (rev 1703)
+++ pkg/ProbABEL/src/regdata.h	2014-04-27 22:17:28 UTC (rev 1704)
@@ -124,13 +124,13 @@
     // Constructors and destructors
     regdata();
     regdata(const regdata &obj);
-    regdata(phedata &phed, gendata &gend, const int snpnum,
+    regdata(const phedata &phed, const gendata &gend, const int snpnum,
             const bool ext_is_interaction_excluded);
     //~regdata();
 
 
     // Member functions.
-    void update_snp(gendata *gend, const int snpnum);
+    void update_snp(const gendata *gend, const int snpnum);
     void remove_snp_from_X();
     regdata get_unmasked_data();
     mematrix<double> extract_genotypes();



More information about the Genabel-commits mailing list