[Genabel-commits] r1662 - branches/ProbABEL-0.50/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Mar 27 21:43:26 CET 2014
Author: maartenk
Date: 2014-03-27 21:43:25 +0100 (Thu, 27 Mar 2014)
New Revision: 1662
Modified:
branches/ProbABEL-0.50/src/gendata.cpp
branches/ProbABEL-0.50/src/gendata.h
Log:
while reading dosages in mldose file the results were saved as strings. These were resized and converted to a pointer. I repaced this sting for a fixed size char array which results in a 20% faster loading time for a mldose file.
Modified: branches/ProbABEL-0.50/src/gendata.cpp
===================================================================
--- branches/ProbABEL-0.50/src/gendata.cpp 2014-03-27 09:40:53 UTC (rev 1661)
+++ branches/ProbABEL-0.50/src/gendata.cpp 2014-03-27 20:43:25 UTC (rev 1662)
@@ -220,9 +220,7 @@
G.reinit(nids, (nsnps * ngpreds));
-
std::ifstream infile;
-
infile.open(fname);
if (!infile)
{
@@ -230,6 +228,7 @@
}
std::string tmpid, tmpstr;
+ char inStr[8];
int k = 0;
for (unsigned int i = 0; i < npeople; i++)
@@ -270,7 +269,7 @@
{
if (infile.good())
{
- infile >> tmpstr;
+ infile >> inStr;
// tmpstr contains the dosage/probability in
// string form. Convert it to double (if tmpstr is
// NaN it will be set to nan).
@@ -279,7 +278,7 @@
errno = 0; // To distinguish success/failure
// after strtod()
- dosage = mldose_strtod(tmpstr.c_str());
+ dosage = mldose_strtod(inStr);
//dosage = strtod(tmpstr.c_str(), &endptr);
// if ((errno == ERANGE &&
// (dosage == HUGE_VALF || dosage == HUGE_VALL))
Modified: branches/ProbABEL-0.50/src/gendata.h
===================================================================
--- branches/ProbABEL-0.50/src/gendata.h 2014-03-27 09:40:53 UTC (rev 1661)
+++ branches/ProbABEL-0.50/src/gendata.h 2014-03-27 20:43:25 UTC (rev 1662)
@@ -44,6 +44,7 @@
unsigned int nids;
unsigned int ngpreds;
gendata();
+ double convert( char* source, char** endPtr );
void re_gendata(char * fname, unsigned int insnps, unsigned int ingpreds,
unsigned int npeople, unsigned int nmeasured,
More information about the Genabel-commits
mailing list