[Genabel-commits] r1027 - branches/ProbABEL-refactoring/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 20 22:57:24 CET 2012
Author: lckarssen
Date: 2012-11-20 22:57:23 +0100 (Tue, 20 Nov 2012)
New Revision: 1027
Modified:
branches/ProbABEL-refactoring/ProbABEL/src/command_line_settings.cpp
branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp
branches/ProbABEL-refactoring/ProbABEL/src/data.cpp
branches/ProbABEL-refactoring/ProbABEL/src/eigen_mematrix.cpp
branches/ProbABEL-refactoring/ProbABEL/src/gendata.cpp
branches/ProbABEL-refactoring/ProbABEL/src/main.cpp
branches/ProbABEL-refactoring/ProbABEL/src/maskedmatrix.cpp
branches/ProbABEL-refactoring/ProbABEL/src/phedata.cpp
branches/ProbABEL-refactoring/ProbABEL/src/reg1.cpp
branches/ProbABEL-refactoring/ProbABEL/src/regdata.cpp
branches/ProbABEL-refactoring/ProbABEL/src/usage.cpp
branches/ProbABEL-refactoring/ProbABEL/src/utilities.cpp
Log:
In ProbABEL-refactoring: Replace fprintf() and printf() with std::cout and std::cerr. This is a rather useless change, only aimed at harmonisation of the code.
Fixed a few small typos in some print statements.
This changes should not give functional changes.
Modified: branches/ProbABEL-refactoring/ProbABEL/src/command_line_settings.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/command_line_settings.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/command_line_settings.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -158,79 +158,79 @@
do
{
- next_option = getopt_long(argc, argv, short_options, long_options,
- NULL);
+ next_option = getopt_long(argc, argv, short_options, long_options,
+ NULL);
- switch (next_option)
- {
- case 'h':
- print_help(program_name, 0);
- case 'p':
- phefilename = optarg;
- neco[0] = 1;
- fprintf(stdout, "phenoint\n");
- break;
- case 'i':
- mlinfofilename = optarg;
- neco[1] = 1;
- break;
- case 'd':
- genfilename = optarg;
- neco[2] = 1;
- break;
- case 'm':
- mapfilename = optarg;
- break;
- case 'n':
- npeople = atoi(optarg);
- break;
- case 'c':
- chrom = optarg;
- break;
- case 'o':
- outfilename = optarg;
- break;
- case 's':
- skipd = atoi(optarg);
- break;
- case 't':
- noutcomes = atoi(optarg);
- break;
- case 'g':
- ngpreds = atoi(optarg);
- break;
- case 'a':
- sep = optarg;
- break;
- case 'e':
- nohead = 1;
- break;
- case 'r':
- score = 1;
- break;
- case 'l':
- allcov = 1;
- break;
- case 'b':
- interaction = atoi(optarg);
- break;
- case 'k':
- interaction_excluded = atoi(optarg);
- break;
- case 'v':
- inverse_filename = optarg;
- break;
- case 'u':
- robust = 1;
- break;
+ switch (next_option)
+ {
+ case 'h':
+ print_help(program_name, 0);
+ case 'p':
+ phefilename = optarg;
+ neco[0] = 1;
+ cout << "phenoint" << endl;
+ break;
+ case 'i':
+ mlinfofilename = optarg;
+ neco[1] = 1;
+ break;
+ case 'd':
+ genfilename = optarg;
+ neco[2] = 1;
+ break;
+ case 'm':
+ mapfilename = optarg;
+ break;
+ case 'n':
+ npeople = atoi(optarg);
+ break;
+ case 'c':
+ chrom = optarg;
+ break;
+ case 'o':
+ outfilename = optarg;
+ break;
+ case 's':
+ skipd = atoi(optarg);
+ break;
+ case 't':
+ noutcomes = atoi(optarg);
+ break;
+ case 'g':
+ ngpreds = atoi(optarg);
+ break;
+ case 'a':
+ sep = optarg;
+ break;
+ case 'e':
+ nohead = 1;
+ break;
+ case 'r':
+ score = 1;
+ break;
+ case 'l':
+ allcov = 1;
+ break;
+ case 'b':
+ interaction = atoi(optarg);
+ break;
+ case 'k':
+ interaction_excluded = atoi(optarg);
+ break;
+ case 'v':
+ inverse_filename = optarg;
+ break;
+ case 'u':
+ robust = 1;
+ break;
- case '?':
- print_usage(program_name, 1);
- case -1:
- break;
- default:
- abort();
- } // end of switch
+ case '?':
+ print_usage(program_name, 1);
+ case -1:
+ break;
+ default:
+ abort();
+ } // end of switch
} while (next_option != -1);
} // end of function
@@ -241,114 +241,116 @@
void cmdvars::printinfo()
{
- fprintf(stdout,
- "%s v. %s (C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, EMCR\n\n",
- PACKAGE, PACKAGE_VERSION);
+ cout << PACKAGE
+ << " v. " << PACKAGE_VERSION
+ << "(C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, EMCR\n\n";
#if EIGEN
- fprintf(stdout, "Using EIGEN for matrix operations\n");
+ cout << "Using EIGEN for matrix operations\n";
#endif
if (neco[0] != 1 || neco[1] != 1 || neco[2] != 1)
{
- print_usage(program_name, 1);
+ print_usage(program_name, 1);
}
if (score)
{
- cout << "option --score suppressed from v 0.1-6\n";
- exit(1);
+ cout << "option --score suppressed from v 0.1-6\n";
+ exit(1);
}
str_genfilename = genfilename;
if (str_genfilename.find(FILEVECTOR_INDEX_FILE_SUFFIX) != string::npos
- || str_genfilename.find(FILEVECTOR_DATA_FILE_SUFFIX)
- != string::npos)
- isFVF = 1;
+ || str_genfilename.find(FILEVECTOR_DATA_FILE_SUFFIX)
+ != string::npos)
+ isFVF = 1;
- fprintf(stdout, "Options in effect:\n");
- fprintf(stdout, "\t --pheno = %s\n", phefilename);
- fprintf(stdout, "\t --info = %s\n", mlinfofilename);
- fprintf(stdout, "\t --dose = %s\n", genfilename);
+ cout << "Options in effect:\n";
+ cout << "\t --pheno = " << phefilename << endl;
+ cout << "\t --info = " << mlinfofilename << endl;
+ cout << "\t --dose = " << genfilename << endl;
if (isFVF)
- fprintf(stdout, "\t (using FVF data)\n");
- fprintf(stdout, "\t --ntraits = %d\n", noutcomes);
- fprintf(stdout, "\t --ngpreds = %d\n", ngpreds);
- fprintf(stdout, "\t --interaction = %d\n", interaction);
- fprintf(stdout, "\t --interaction_only = %d\n", interaction_excluded);
+ cout << "\t (using FVF data)" << endl;
+ cout << "\t --ntraits = " << noutcomes << endl;
+ cout << "\t --ngpreds = " << ngpreds << endl;
+ cout << "\t --interaction = " << interaction << endl;
+ cout << "\t --interaction_only = " << interaction_excluded << endl;
if (inverse_filename != NULL)
- fprintf(stdout, "\t --mmscore = %s\n", inverse_filename);
+ cout << "\t --mmscore = " << inverse_filename << endl;
else
- fprintf(stdout, "\t --mmscore = not in output\n");
-// fprintf(stdout,"\t --mmscore = %s\n",inverse_filename);
+ cout << "\t --mmscore = not in output" << endl;
if (mapfilename != NULL)
- fprintf(stdout, "\t --map = %s\n", mapfilename);
+ cout << "\t --map = " << mapfilename << endl;
else
- fprintf(stdout, "\t --map = not in output\n");
+ cout << "\t --map = not in output" << endl;
if (npeople > 0)
- fprintf(stdout, "\t --nids = %d\n", npeople);
+ cout << "\t --nids = " << npeople << endl;
else
- fprintf(stdout, "\t --nids = estimated from data\n");
+ cout << "\t --nids = estimated from data" << endl;
if (chrom != "-1")
- cout << "\t --chrom = " << chrom << "\n";
+ cout << "\t --chrom = " << chrom << endl;
else
- cout << "\t --chrom = not in output\n";
+ cout << "\t --chrom = not in output\n";
if (outfilename != NULL)
- fprintf(stdout, "\t --out = %s\n", outfilename);
+ cout << "\t --out = " << outfilename << endl;
else
- fprintf(stdout, "\t --out = regression.out.txt\n");
- fprintf(stdout, "\t --skipd = %d\n", skipd);
- cout << "\t --separat = \"" << sep << "\"\n";
+ cout << "\t --out = " << "regression.out.txt" << endl;
+ cout << "\t --skipd = " << skipd << endl;
+ cout << "\t --separat = \"" << sep << "\"" << endl;
if (score)
- fprintf(stdout, "\t --score = ON\n");
+ cout << "\t --score = ON" << endl;
else
- fprintf(stdout, "\t --score = OFF\n");
+ cout << "\t --score = OFF" << endl;
if (nohead)
- fprintf(stdout, "\t --nohead = ON\n");
+ cout << "\t --nohead = ON" << endl;
else
- fprintf(stdout, "\t --nohead = OFF\n");
+ cout << "\t --nohead = OFF" << endl;
if (allcov)
- fprintf(stdout, "\t --allcov = ON\n");
+ cout << "\t --allcov = ON" << endl;
else
- fprintf(stdout, "\t --allcov = OFF\n");
+ cout << "\t --allcov = OFF" << endl;
if (robust)
- fprintf(stdout, "\t --robust = ON\n");
+ cout << "\t --robust = ON" << endl;
else
- fprintf(stdout, "\t --robust = OFF\n");
+ cout << "\t --robust = OFF" << endl;
if (ngpreds != 1 && ngpreds != 2)
{
- fprintf(stderr,
- "\n\n--ngpreds should be 1 for MLDOSE or 2 for MLPROB\n");
- exit(1);
+ cerr << "\n\n--ngpreds should be 1 for MLDOSE or 2 for MLPROB"
+ << endl;
+ exit(1);
}
if (interaction_excluded != 0)
{
- interaction = interaction_excluded; //ups
- is_interaction_excluded = true;
+ interaction = interaction_excluded; //ups
+ is_interaction_excluded = true;
}
if (outfilename == NULL)
{
- outfilename = (char *) string("regression").c_str();
+ outfilename = (char *) string("regression").c_str();
}
#if COXPH
if (score)
{
- fprintf(stderr, "\n\nOption --score is implemented for linear and logistic models only\n");
- exit(1);
+ cerr << "\n\nOption --score is implemented for linear and logistic models only\n"
+ << endl;
+ exit(1);
}
if (inverse_filename != NULL)
{
- std::cerr << "ERROR: mmscore is forbidden for cox regression\n";
- exit(1);
+ cerr << "ERROR: mmscore is forbidden for cox regression"
+ << endl;
+ exit(1);
}
if (robust)
{
- std::cerr << "ERROR: robust standard errors not implemented for Cox regression\n";
- exit(1);
+ cerr << "ERROR: robust standard errors not implemented for Cox regression"
+ << endl;
+ exit(1);
}
#endif
}
Modified: branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -5,6 +5,7 @@
* Author: mkooyman
*/
#include "coxph_data.h"
+#include <iostream>
#include <cmath>
extern "C" {
#include "survproto.h"
@@ -72,9 +73,8 @@
ncov = phed.ncov;
if (phed.noutcomes != 2)
{
- fprintf(stderr,
- "coxph_data: number of outcomes should be 2 (now: %d)\n",
- phed.noutcomes);
+ std::cerr << "coxph_data: number of outcomes should be 2 (now: "
+ << phed.noutcomes ")\n";
exit(1);
}
// X.reinit(nids,(ncov+1));
@@ -92,8 +92,8 @@
sstat[i] = int((phed.Y).get(i, 1));
if (sstat[i] != 1 && sstat[i] != 0)
{
- std::cerr << "coxph_data: status not 0/1 (correct order: id, fuptime, status ...)"
- << endl;
+ std::cerr << "coxph_data: status not 0/1 (correct order: id, fuptime, status ...)"
+ << endl;
exit(1);
}
}
@@ -144,7 +144,7 @@
}
if (passed != 1)
{
- fprintf(stderr, "cannot recover element %d\n", i);
+ std::cerr << "cannot recover element " << i << "\n";
exit(1);
}
}
@@ -258,7 +258,8 @@
to.masked_data = new unsigned short int[to.nids];
for (int i = 0; i < to.nids; i++)
to.masked_data[i] = 0;
- //fprintf(stdout,"get_unmasked: %i %i %i\n",to.nids,dim2X,dim2Y);
+ // std::cout << "get_unmasked: " << to.nids << " "
+ // << dim2X << " " << dim2Y << "\n";
return (to);
}
@@ -310,4 +311,3 @@
loglik = loglik_int[1];
niter = maxiter;
}
-
Modified: branches/ProbABEL-refactoring/ProbABEL/src/data.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/data.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/data.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -23,6 +23,7 @@
#include "mematri1.h"
#endif
#include "utilities.h"
+
using namespace std;
unsigned int Nmeasured(char * fname, int nphenocols, int npeople)
@@ -206,9 +207,9 @@
if (col != npeople)
{
- fprintf(stderr,
- "error: inv file: Number of columns in row %d equals to %d but people amount is %d\n",
- row, col, npeople);
+ std::cerr << "error: inv file: Number of columns in row "
+ << row << " equals to " << col
+ << " but number of people is " << npeople << "\n";
myfile.close();
exit(1);
}
@@ -218,7 +219,8 @@
myfile.close();
} else
{
- fprintf(stderr, "error: inv file: cannot open file '%s'\n", filename_);
+ std::cerr << "error: inv file: cannot open file '"
+ << filename_ << "'\n";
}
delete[] line;
Modified: branches/ProbABEL-refactoring/ProbABEL/src/eigen_mematrix.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/eigen_mematrix.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/eigen_mematrix.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -3,6 +3,7 @@
#include "eigen_mematrix.h"
#include <Eigen/Dense>
#include <Eigen/LU>
+#include <iostream>
#include <string>
#include <cstdarg>
#include <cstdio>
@@ -18,12 +19,12 @@
{
if (nr <= 0)
{
- fprintf(stderr, "mematrix(): nr <= 0\n");
+ std::cerr << "mematrix(): nr <= 0\n";
exit(1);
}
if (nc <= 0)
{
- fprintf(stderr, "mematrix(): nc <= 0\n");
+ std::cerr << "mematrix(): nc <= 0\n";
exit(1);
}
this->nrow = nr;
@@ -60,8 +61,8 @@
{
if (i < 0 || i >= (ncol * nrow))
{
- fprintf(stderr, "mematrix[]: %d out of bounds (0,%d)\n", i,
- nrow * ncol - 1);
+ std::cerr << "mematrix[]: " << i << " out of bounds (0,"
+ << nrow * ncol - 1 << ")\n";
exit(1);
}
int column = i % ncol;
@@ -83,9 +84,9 @@
{
if (ncol != M.ncol || nrow != M.nrow)
{
- fprintf(stderr,
- "mematrix+: matrices not equal in size (%d,%d) and (%d,%d)",
- nrow, ncol, M.nrow, M.ncol);
+ std::cerr << "mematrix+: matrices not equal in size ("
+ << nrow << "," << ncol << ") and ("
+ << M.nrow << "," << M.ncol << ")\n";
exit(1);
}
mematrix<DT> temp;
@@ -109,9 +110,9 @@
{
if (ncol != M.ncol || nrow != M.nrow)
{
- fprintf(stderr,
- "mematrix-: matrices not equal in size (%d,%d) and (%d,%d)",
- nrow, ncol, M.nrow, M.ncol);
+ std::cerr << "mematrix-: matrices not equal in size ("
+ << nrow << "," << ncol << ") and ("
+ << M.nrow << "," << M.ncol << ")\n";
exit(1);
}
mematrix<DT> temp;
@@ -136,8 +137,8 @@
{
if (ncol != M.nrow)
{
- fprintf(stderr, "mematrix*: ncol != nrow (%d,%d) and (%d,%d)", nrow,
- ncol, M.nrow, M.ncol);
+ std::cerr << "mematrix*: ncol != nrow (" << nrow << ","
+ << ncol << ") and (" << M.nrow << "," << M.ncol << ")\n";
}
mematrix<DT> temp;
@@ -145,9 +146,10 @@
temp.ncol = temp.data.cols();
temp.nrow = temp.data.rows();
temp.nelements = temp.nrow * temp.ncol;
-// fprintf(stderr, "mematrix*: (%d,%d) and (%d,%d):result%d\n", nrow,
-// ncol, M.nrow, M.ncol,temp.nrow * temp.ncol);
-// std::cout.flush();
+ // std::cerr << "mematrix*: (" << nrow << "," << ncol << ") and ("
+ // << M.nrow << "," << M.ncol << "): result"
+ // << temp.nrow * temp.ncol << "\n";
+ // std::cout.flush();
return temp;
}
@@ -157,15 +159,15 @@
{
if (ncol != M->nrow)
{
- fprintf(stderr, "mematrix*: ncol != nrow (%d,%d) and (%d,%d)", nrow,
- ncol, M->nrow, M->ncol);
+ std::cerr << "mematrix*: ncol != nrow (" << nrow << "," << ncol
+ << ") and (" << M->nrow << "," << M->ncol <<")\n";
}
mematrix<DT> temp;
temp.data = data * M->data;
temp.ncol = temp.data.cols();
temp.nrow = temp.data.rows();
temp.nelements = temp.nrow * temp.ncol;
-// fprintf(stderr, "mematrix*: (%d,%d) and (%d,%d):result%d\n", nrow,
+// std::cerr << "mematrix*: (%d,%d) and (%d,%d):result%d\n", nrow,
// ncol, M->nrow, M->ncol,temp.nrow * temp.ncol);
return temp;
@@ -181,12 +183,12 @@
// delete[] data;
if (nr <= 0)
{
- fprintf(stderr, "mematrix(): number of rows smaller then 1\n");
+ std::cerr << "mematrix(): number of rows smaller then 1\n";
exit(1);
}
if (nc <= 0)
{
- fprintf(stderr, "mematrix(): number of columns smaller then 1\n");
+ std::cerr << "mematrix(): number of columns smaller then 1\n";
exit(1);
}
nrow = nr;
@@ -203,14 +205,14 @@
#if !NDEBUG
if (nc < 0 || nc > ncol)
{
- fprintf(stderr,
- "mematrix::get: column out of range: %d not in (0,%d)\n", nc,
- ncol);
+ std::cerr << "mematrix::get: column out of range: " << nc
+ << " not in (0," << ncol << ")\n";
exit(1);
}
if (nr < 0 || nr > nrow)
{
- printf("mematrix::get: row out of range: %d not in (0,%d)\n", nr, nrow);
+ std::cerr << "mematrix::get: row out of range: " << nr
+ << " not in (0," << nrow << ")\n";
exit(1);
}
#endif
@@ -223,14 +225,14 @@
#if !NDEBUG
if (nc < 0 || nc > ncol)
{
- fprintf(stderr,
- "mematrix::put: column out of range: %d not in (0,%d)\n", nc,
- ncol);
+ std::cerr << "mematrix::put: column out of range: " << nc
+ << " not in (0," << ncol << ")\n";
exit(1);
}
if (nr < 0 || nr > nrow)
{
- printf("mematrix::put: row out of range: %d not in (0,%d)\n", nr, nrow);
+ std::cerr << "mematrix::put: row out of range: " << nr
+ << " not in (0," << nrow << ")\n";
exit(1);
}
#endif
@@ -242,7 +244,7 @@
{
if (nc >= ncol || nc < 0)
{
- fprintf(stderr, "colmM bad column\n");
+ std::cerr << "colmM bad column\n";
exit(1);
}
@@ -260,14 +262,14 @@
template<class DT>
void mematrix<DT>::print(void)
{
- cout << "nrow=" << nrow << "; ncol=" << ncol << "; nelements=" << nelements
- << "\n";
+ std::cout << "nrow=" << nrow << "; ncol=" << ncol
+ << "; nelements=" << nelements << "\n";
for (int i = 0; i < nrow; i++)
{
- cout << "nr=" << i << ":\t";
+ std:: cout << "nr=" << i << ":\t";
for (int j = 0; j < ncol; j++)
cout << data.data()[i * ncol + j] << "\t";
- cout << "\n";
+ std::cout << "\n";
}
}
// other functions
@@ -276,14 +278,16 @@
template<class DT>
mematrix<DT> transpose(const mematrix<DT> &M)
{
-//cout << "[DEBUG TRANSPOSE PRE]nrow=" << M.nrow << "; ncol=" << M.ncol << "; nelements=" << M.nelements;
+ // cout << "[DEBUG TRANSPOSE PRE]nrow=" << M.nrow << "; ncol="
+ // << M.ncol << "; nelements=" << M.nelements;
mematrix<DT> temp;
temp.data = M.data.transpose();
temp.ncol = M.nrow;
temp.nrow = M.ncol;
temp.nelements = M.nelements;
-//cout << "[DEBUG TRANSPOSE post]nrow=" << temp.nrow << "; ncol=" << temp.ncol << "; nelements=" << temp.nelements;
+ // cout << "[DEBUG TRANSPOSE post]nrow=" << temp.nrow << "; ncol="
+ // << temp.ncol << "; nelements=" << temp.nelements;
return temp;
}
@@ -293,7 +297,7 @@
{
if (M.nrow != order.nrow)
{
- fprintf(stderr, "reorder: M & order have different # of rows\n");
+ std::cerr << "reorder: M & order have different # of rows\n";
exit(1);
}
mematrix<DT> temp(M.nrow, M.ncol);
@@ -324,7 +328,7 @@
{
if (M.ncol != M.nrow)
{
- fprintf(stderr, "invert: only square matrices possible\n");
+ std::cerr << "invert: only square matrices possible\n";
exit(1);
}
@@ -340,7 +344,7 @@
//multiply all rows of M by value of first row of D
if (M.ncol != D.nrow)
{
- fprintf(stderr, "productMatrDiag: wrong dimenstions");
+ std::cerr << "productMatrDiag: wrong dimensions";
exit(1);
}
mematrix<DT> temp = M;
Modified: branches/ProbABEL-refactoring/ProbABEL/src/gendata.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/gendata.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/gendata.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -29,7 +29,8 @@
for (unsigned int i = 0; i < DAG->getNumObservations(); i++)
if (!DAGmask[i])
data[j++] = tmpdata[i];
- //fprintf(stdout,"%i %i %i\n",j,DAG->get_nobservations(),nids);
+ // std::cout << j << " " << DAG->get_nobservations() << " "
+ // << nids << "\n";
} else
report_error("cannot get gendata");
}
@@ -79,7 +80,7 @@
}
nids = j + 1;
- //fprintf(stdout,"in INI: %i %i\n",nids,npeople);
+ // std::cout << "in INI: " << nids << " " << npeople << "\n";
if (nids != nmeasured)
report_error("nids != mneasured (%i != %i)\n", nids, nmeasured);
@@ -128,7 +129,8 @@
} else
{
tmpid = tmpstr;
- //fprintf(stdout,"%s;%s;%s;%s;%s\n",tmp,ttt,tmpn,tmpid.c_str(),idnames[k].c_str());
+ // std::cout << tmp << ";" << ttt << ";" << tmpn
+ // << tmpid.c_str() << ";" << idnames[k].c_str() << "\n";
}
if (tmpid != idnames[k])
{
Modified: branches/ProbABEL-refactoring/ProbABEL/src/main.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/main.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/main.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -1,15 +1,11 @@
//=============================================================================
-//
// Filename: src/main.cpp
//
// Description: ProbABEL head file.
//
-// Version: 0.1-3
-// Created: ---
-// Revision: none
-//
// Author: Yurii S. Aulchenko (cox, log, lin regressions)
-// Modified by: L.C. Karssen,
+// Modified by: M. Kooyman,
+// L.C. Karssen,
// Maksim V. Struchalin
//
// modified 14-May-2009 by MVS: interaction with SNP, interaction with SNP
@@ -23,7 +19,6 @@
// of beta(interaction) based on src/main.cpp version 0.1-0 as of Oct 19, 2009
//
// Company: Department of Epidemiology, ErasmusMC Rotterdam, The Netherlands.
-// Email: i.aoultchenko at erasmusmc.nl, m.struchalin at erasmusmc.nl
//
//=============================================================================
#include <stdio.h>
@@ -57,18 +52,22 @@
void update_progress_to_cmd_line(int csnp, int nsnps)
{
+ std::cout << setprecision(2) << fixed;
+
if (csnp % 1000 == 0)
{
if (csnp == 0)
{
- fprintf(stdout, "Analysis: %6.2f ...",
- 100. * static_cast<double>(csnp)
- / static_cast<double>(nsnps));
+ std::cout << "Analysis: "
+ << setw (5) << 100. * static_cast<double>(csnp)
+ / static_cast<double>(nsnps)
+ << "%...";
} else
{
- fprintf(stdout, "\b\b\b\b\b\b\b\b\b\b%6.2f ...",
- 100. * static_cast<double>(csnp)
- / static_cast<double>(nsnps));
+ std::cout << "\b\b\b\b\b\b\b\b\b"
+ << setw (5) << 100. * static_cast<double>(csnp)
+ / static_cast<double>(nsnps)
+ << "%...";
}
std::cout.flush();
}
@@ -90,7 +89,7 @@
outfile[i]->open((filenames[i]).c_str());
if (!outfile[i]->is_open())
{
- std::cerr << "Can not open file for writing: " << filenames[i]
+ std::cerr << "Cannot open file for writing: " << filenames[i]
<< "\n";
exit(1);
}
@@ -253,7 +252,7 @@
input_var.printinfo();
// if (allcov && ngpreds>1)
// {
- // fprintf(stdout,"\n\nWARNING: --allcov allowed only for 1 predictor (MLDOSE)\n");
+ // std::cout << "\n\nWARNING: --allcov allowed only for 1 predictor (MLDOSE)\n";
// allcov = 0;
// }
mlinfo mli(input_var.getMlinfofilename(), input_var.getMapfilename());
@@ -363,7 +362,7 @@
if (!outfile[0]->is_open())
{
- std::cerr << "Can not open file for writing: " << outfilename_str
+ std::cerr << "Cannot open file for writing: " << outfilename_str
<< "\n";
exit(1);
}
@@ -901,10 +900,9 @@
update_progress_to_cmd_line(csnp, nsnps);
}
- fprintf(stdout, "\b\b\b\b\b\b\b\b\b\b%6.2f", 100.);
+ std::cout << "\b\b\b\b\b\b\b\b\b" << 100.;
+ std::cout << "%... done\n";
- fprintf(stdout, " ... done\n");
-
//________________________________________________________________
//Maksim, 9 Jan, 2009
Modified: branches/ProbABEL-refactoring/ProbABEL/src/maskedmatrix.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/maskedmatrix.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/maskedmatrix.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -108,6 +108,7 @@
for (int j = 0; j < length_of_mask; j++)
if (mask_of_old[j] == 0)
{
+ //std::cout << "val" << i1 << " " << j1 << "\n";
matrix_masked_data.put(matrix_original.get(i, j), i1, j1);
j1++;
}
Modified: branches/ProbABEL-refactoring/ProbABEL/src/phedata.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/phedata.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/phedata.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -171,7 +171,9 @@
nids++;
}
infile.close();
- // printf("npeople = %d, no. all measured = %d\n",nids_all,nids);
+ // std::cout << "npeople = " << nids_all
+ // << ", no. all measured = " << nids << "\n";
+
// allocate objects
int ntmpcov = 1;
if (ncov > 0)
@@ -223,4 +225,3 @@
// delete Y;
// delete [] allmeasured;
}
-
Modified: branches/ProbABEL-refactoring/ProbABEL/src/reg1.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/reg1.cpp 2012-11-20 21:54:21 UTC (rev 1026)
+++ branches/ProbABEL-refactoring/ProbABEL/src/reg1.cpp 2012-11-20 21:57:23 UTC (rev 1027)
@@ -204,7 +204,8 @@
linear_reg::linear_reg(regdata& rdatain)
{
regdata rdata = rdatain.get_unmasked_data();
- //fprintf(stdout,"linear_reg: %i %i %i\n",rdata.nids,(rdata.X).ncol,(rdata.Y).ncol);
+ // std::cout << "linear_reg: " << rdata.nids << " " << (rdata.X).ncol
+ // << " " << (rdata.Y).ncol << "\n";
int length_beta = (rdata.X).ncol;
beta.reinit(length_beta, 1);
sebeta.reinit(length_beta, 1);
@@ -280,16 +281,16 @@
{
cout << rdata.is_interaction_excluded
<< " <-irdata.is_interaction_excluded\n";
- printf("invvarmatrix:\n");
+ std::cout << "invvarmatrix:\n";
invvarmatrixin.masked_data->print();
- printf("rdata.X:\n");
+ std::cout << "rdata.X:\n";
rdata.X.print();
}
mematrix<double> X = apply_model(rdata.X, model, interaction, ngpreds,
rdata.is_interaction_excluded, false, nullmodel);
if (verbose)
{
- printf("X:\n");
+ std::cout << "X:\n";
X.print();
}
int length_beta = X.ncol;
@@ -330,17 +331,17 @@
beta = tXX_i * tXY;
if (verbose)
{
- printf("tX:\n");
+ std::cout << "tX:\n";
tX.print();
- printf("tXX:\n");
+ std::cout << "tXX:\n";
tXX.print();
- printf("chole tXX:\n");
+ std::cout << "chole tXX:\n";
tXX_i.print();
- printf("tXX-1:\n");
+ std::cout << "tXX-1:\n";
tXX_i.print();
- printf("tXY:\n");
+ std::cout << "tXY:\n";
tXY.print();
- printf("beta:\n");
+ std::cout << "beta:\n";
(beta).print();
}
// now compute residual variance
@@ -348,22 +349,22 @@
mematrix<double> ttX = transpose(tX);
mematrix<double> sigma2_matrix = rdata.Y;
mematrix<double> sigma2_matrix1 = ttX * beta;
- // printf("sigma2_matrix");
+ // std::cout << "sigma2_matrix\n";
// sigma2_matrix.print();
//
- // printf("sigma2_matrix1");
+ // std::cout << "sigma2_matrix1\n";
// sigma2_matrix1.print();
sigma2_matrix = sigma2_matrix - sigma2_matrix1;
- // printf("sigma2_matrix");
+ // std::cout << "sigma2_matrix\n";
// sigma2_matrix.print();
static double val;
// std::cout<<"sigma2_matrix.nrow="<<sigma2_matrix.nrow<<"sigma2_matrix.ncol"<<sigma2_matrix.ncol<<"\n";
for (int i = 0; i < sigma2_matrix.nrow; i++)
{
val = sigma2_matrix.get(i, 0);
- // printf("val = %f\n", val);
+ // std::cout << "val = " << val << "\n";
sigma2 += val * val;
- // printf("sigma2+= = %f\n", sigma2);
+ // std::cout << "sigma2+= " << sigma2 << "\n";
}
double sigma2_internal = sigma2 / (N - static_cast<double>(length_beta));
// now compute residual variance
@@ -379,12 +380,12 @@
// std::cout<<"sigma2_internal="<<sigma2_internal<<"\n";
// replaced for ML
// sigma2_internal = sigma2/(N - double(length_beta) - 1);
- // printf("sigma2/=N = %f\n", sigma2);
+ // std::cout << "sigma2/=N = "<< sigma2 << "\n";
sigma2 /= N;
// std::cout<<"N="<<N<<", length_beta="<<length_beta<<"\n";
if (verbose)
{
- printf("sigma2 = %f\n", sigma2);
+ std::cout << "sigma2 = " << sigma2 << "\n";
}
/*
loglik = 0.;
@@ -489,7 +490,7 @@
//cout << "estimate E\n";
if (verbose)
{
- printf("sebeta (%d):\n", sebeta.nrow);
+ std::cout << "sebeta (" << sebeta.nrow << "):\n";
sebeta.print();
}
}
@@ -563,7 +564,7 @@
double prev = (rdata.Y).column_mean(0);
if (prev >= 1. || prev <= 0.)
{
- fprintf(stderr, "prevalence not within (0,1)\n");
+ std::cerr << "prevalence not within (0,1)\n";
exit(1);
}
for (int i = 0; i < length_beta; i++)
@@ -576,14 +577,19 @@
tX = tX * invvarmatrix;
}
/*
- fprintf(stdout,"\n");
- fprintf(stdout,"X %f %f %f\n",X.get(0,0),X.get(0,1),X.get(0,2));
- if (X.ncol==4) fprintf(stdout,"X[4] %f\n",X.get(0,3));
- fprintf(stdout,"Inv %f %f %f\n",invvarmatrix.get(0,0),invvarmatrix.get(0,1),invvarmatrix.get(0,2));
- if (X.ncol==4) fprintf(stdout,"X[4] %f\n",invvarmatrix.get(0,3));
- fprintf(stdout,"tXInv %f %f %f\n",tX.get(0,0),tX.get(1,0),tX.get(2,0));
- if (X.ncol==4) fprintf(stdout,"X[4] %f\n",tX.get(3,0));
- */
+ std::cout << "\n";
+ std::cout << "X " << X.get(0,0) << " " << X.get(0,1) << " "
+ << X.get(0,2) << "\n";
+ if (X.ncol==4) std::cout << "X[4] " << X.get(0,3) << "\n";
+ std::cout << "Inv " << invvarmatrix.get(0,0) << " "
+ << invvarmatrix.get(0,1) << " "
+ << invvarmatrix.get(0,2) << "\n";
+
+ if (X.ncol==4) std::cout << ,"X[4] " << invvarmatrix.get(0,3) << "\n";
+ std::cout << "tXInv " << tX.get(0,0) << " " << tX.get(1,0) << " "
+ << tX.get(2,0) << "%f\n";
+ if (X.ncol==4) std::cout << "X[4] " << tX.get(3,0) << "\n";
+ */
niter = 0;
double delta = 1.;
double prevlik = 0.;
@@ -608,51 +614,52 @@
mematrix<double> tmp = productMatrDiag(tX, W);
if (verbose)
{
- printf("tXW:\n");
+ std::cout << "tXW:\n";
tmp.print();
}
mematrix<double> tXWX = tmp * (X);
//N = tXWX.get(0, 0);
if (verbose)
{
- printf("tXWX:\n");
+ std::cout << "tXWX:\n";
tXWX.print();
}
- //printf("tXWX:\n");tXWX.print();
+ // std::cout << "tXWX:\n";tXWX.print();
//
// use cholesky to invert
//
tXWX_i = tXWX;
//cholesky2_mm(tXWX_i,tol_chol);
- //if (verbose) {printf("chole tXWX:\n");tXWX_i.print();}
- //printf("chole tXWX:\n");tXWX_i.print();
+ //if (verbose) {std::cout << "chole tXWX:\n"; tXWX_i.print();}
+ //std::cout << "chole tXWX:\n"; tXWX_i.print();
//chinv2_mm(tXWX_i);
// was before
tXWX_i = invert(tXWX);
if (verbose)
{
- printf("tXWX-1:\n");
+ std::cout << "tXWX-1:\n";
tXWX_i.print();
}
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/genabel -r 1027
More information about the Genabel-commits
mailing list