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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 28 00:14:45 CET 2013


Author: lckarssen
Date: 2013-11-28 00:14:44 +0100 (Thu, 28 Nov 2013)
New Revision: 1426

Modified:
   pkg/ProbABEL/src/phedata.cpp
Log:
A few small improvements to ProbABEL's phedata.cpp:
- Put phedata.h at the top of the #includes (cpplint error)
- Add doxygen documentation to the setphedata() function
- Instead of using a buffer size of 100 when reading the pheno data, use 1MB, like we do in data.cpp when reading the .mlinfo file. 
- Remove/fix TODO by removing unused, commented variable.


Modified: pkg/ProbABEL/src/phedata.cpp
===================================================================
--- pkg/ProbABEL/src/phedata.cpp	2013-11-27 18:37:19 UTC (rev 1425)
+++ pkg/ProbABEL/src/phedata.cpp	2013-11-27 23:14:44 UTC (rev 1426)
@@ -1,3 +1,4 @@
+#include <phedata.h>
 #include <string>
 #include <sstream>
 #include <fstream>
@@ -3,5 +4,4 @@
 #include <cstdarg>
 #include <cstdlib>
-#include <phedata.h>
 
 using std::cout;
@@ -21,13 +21,24 @@
     is_interaction_excluded = int_exl;
 }
 
+
+/**
+ * Read phenotype data from file.
+ *
+ * @param fname Name of the file containing phenotype data
+ * @param noutc Number of outcomes/phenotypes
+ * @param npeople Number of people
+ * @param interaction Column specifying which phenotype is selected to
+ * interact with the SNP (default: 0, i.e. no interaction)
+ * @param iscox Are we running a Cox PH regression?
+ */
 void phedata::setphedata(char * fname, int noutc, int npeople, int interaction,
                          bool iscox)
 {
-    static const unsigned int BFS = 1000;
+    static const unsigned int BFS = 1048576;
     std::ifstream myfile(fname);
-    char line[BFS];
-    char tmp[100];
+    char *line = new char[BFS];
+    char *tmp  = new char[BFS];
     noutcomes = noutc;
     is_interaction_excluded = false;
 
@@ -204,8 +215,6 @@
         infile >> tmp;
     }
 
-    //TODO: remove this unused variable if there is not a reason to keep it
-    //int k = 0;
     int m = 0;
     for (int i = 0; i < npeople; i++)
         if (allmeasured[i] == 1)
@@ -230,8 +239,12 @@
                 infile >> tmp;
         }
     infile.close();
+
+    delete[] line;
+    delete[] tmp;
 }
 
+
 phedata::~phedata()
 {
     // delete X;



More information about the Genabel-commits mailing list