[Genabel-commits] r888 - branches/ProbABEL-refactoring/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Apr 8 16:37:34 CEST 2012
Author: maartenk
Date: 2012-04-08 16:37:34 +0200 (Sun, 08 Apr 2012)
New Revision: 888
Added:
branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.cpp
branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.h
Modified:
branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am
branches/ProbABEL-refactoring/ProbABEL/src/main.cpp
branches/ProbABEL-refactoring/ProbABEL/src/phedata.cpp
branches/ProbABEL-refactoring/ProbABEL/src/phedata.h
branches/ProbABEL-refactoring/ProbABEL/src/reg1.h
branches/ProbABEL-refactoring/ProbABEL/src/regdata.cpp
branches/ProbABEL-refactoring/ProbABEL/src/regdata.h
Log:
-spited variable parsing and checking from command line to separate class
- removed global variable called is_interaction_excluded and implemented it as function parameter
Modified: branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am 2012-04-03 11:25:44 UTC (rev 887)
+++ branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am 2012-04-08 14:37:34 UTC (rev 888)
@@ -3,7 +3,7 @@
## Using wildcards in these lists doesn't work. Also GNU make's ($wildcard,) doesn't
## work. It gives warning message about portability, but in the end doesn't work,
## I tried :-).
-REGFILES = data.h data.cpp gendata.h gendata.cpp mematrix.h mematri1.h reg1.h usage.h usage.cpp main.cpp utilities.h utilities.cpp phedata.h phedata.cpp cholesky.h cholesky.cpp regdata.h regdata.cpp coxph_data.h coxph_data.h
+REGFILES = data.h data.cpp gendata.h gendata.cpp mematrix.h mematri1.h comand_line_settings.h comand_line_settings.cpp reg1.h usage.h usage.cpp main.cpp utilities.h utilities.cpp phedata.h phedata.cpp cholesky.h cholesky.cpp regdata.h regdata.cpp coxph_data.h coxph_data.h
## Filevector files:
FVSRC = fvlib/AbstractMatrix.cpp fvlib/CastUtils.cpp \
Added: branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.cpp (rev 0)
+++ branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.cpp 2012-04-08 14:37:34 UTC (rev 888)
@@ -0,0 +1,337 @@
+/*
+ * comand_line_settings.cpp
+ *
+ * Created on: Apr 1, 2012
+ * Author: mkooyman
+ */
+
+#include <getopt.h>
+#include <string>
+#include <iostream>
+#include "usage.h"
+#include "comand_line_settings.h"
+
+// config.h and fvlib/FileVector.h are included for the upper case variables
+#include "config.h"
+#include "fvlib/FileVector.h"
+
+using namespace std;
+
+string cmdvars::getStrGenfilename() const
+{
+ return str_genfilename;
+}
+;
+
+int cmdvars::getAllcov() const
+{
+ return allcov;
+}
+
+string cmdvars::getChrom() const
+{
+ return chrom;
+}
+
+char* cmdvars::getGenfilename() const
+{
+ return genfilename;
+}
+
+int cmdvars::getInteraction() const
+{
+ return interaction;
+}
+
+char* cmdvars::getInverseFilename() const
+{
+ return inverse_filename;
+}
+
+bool cmdvars::isIscox() const
+{
+ return iscox;
+}
+
+int cmdvars::getIsFvf() const
+{
+ return isFVF;
+}
+
+char* cmdvars::getMapfilename() const
+{
+ return mapfilename;
+}
+
+char* cmdvars::getMlinfofilename() const
+{
+ return mlinfofilename;
+}
+
+const int* cmdvars::getNeco() const
+{
+ return neco;
+}
+
+int cmdvars::getNgpreds() const
+{
+ return ngpreds;
+}
+
+int cmdvars::getNohead() const
+{
+ return nohead;
+}
+
+int cmdvars::getNoutcomes() const
+{
+ return noutcomes;
+}
+
+int cmdvars::getNpeople() const
+{
+ return npeople;
+}
+
+char* cmdvars::getOutfilename() const
+{
+ return outfilename;
+}
+
+char* cmdvars::getProgramName() const
+{
+ return program_name;
+}
+
+int cmdvars::getRobust() const
+{
+ return robust;
+}
+
+int cmdvars::getScore() const
+{
+ return score;
+}
+
+string cmdvars::getSep() const
+{
+ return sep;
+}
+
+int cmdvars::getSkipd() const
+{
+ return skipd;
+}
+
+char* cmdvars::getPhefilename() const
+{
+ return phefilename;
+}
+
+void cmdvars::set_variables(int argc, char * argv[])
+{
+ int next_option;
+ const char * const short_options = "p:i:d:m:n:c:o:s:t:g:a:erlh:b:vu";
+ //b - interaction parameter
+ // ADD --fv FLAG (FILEVECTOR), IN WHICH CASE USE ALTERNATIVE
+ // CONSTRUCTOR FOR GENDATA
+ const struct option long_options[] =
+ {
+ { "pheno", 1, NULL, 'p' },
+ { "info", 1, NULL, 'i' },
+ { "dose", 1, NULL, 'd' },
+ { "map", 1, NULL, 'm' },
+ { "nids", 1, NULL, 'n' },
+ { "chrom", 1, NULL, 'c' },
+ { "out", 1, NULL, 'o' },
+ { "skipd", 1, NULL, 's' },
+ { "ntraits", 1, NULL, 't' },
+ { "ngpreds", 1, NULL, 'g' },
+ { "separat", 1, NULL, 'a' },
+ { "score", 0, NULL, 'r' },
+ { "no-head", 0, NULL, 'e' },
+ { "allcov", 0, NULL, 'l' },
+ { "help", 0, NULL, 'h' },
+ { "interaction", 1, NULL, 'b' },
+ { "interaction_only", 1, NULL, 'k' },
+ { "mmscore", 1, NULL, 'v' },
+ { "robust", 0, NULL, 'u' },
+ { NULL, 0, NULL, 0 } };
+ char * program_name = argv[0];
+ fprintf(stdout, "Usage: %s options\n", PACKAGE_VERSION);
+
+ do
+ {
+ 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;
+
+ case '?':
+ print_usage(program_name, 1);
+ case -1:
+ break;
+ default:
+ abort();
+ } // end of switch
+ } while (next_option != -1);
+} // end of function
+
+bool cmdvars::isIsInteractionExcluded() const
+{
+ return is_interaction_excluded;
+}
+
+void cmdvars::printinfo()
+{
+ fprintf(stdout,
+ "%s v. %s (C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, EMCR\n\n",
+ PACKAGE, PACKAGE_VERSION);
+
+ if (neco[0] != 1 || neco[1] != 1 || neco[2] != 1)
+ {
+ print_usage(program_name, 1);
+ }
+
+ if (score)
+ {
+ 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;
+
+ 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);
+ 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);
+
+ if (inverse_filename != NULL)
+ fprintf(stdout, "\t --mmscore = %s\n", inverse_filename);
+ else
+ fprintf(stdout, "\t --mmscore = not in output\n");
+// fprintf(stdout,"\t --mmscore = %s\n",inverse_filename);
+
+ if (mapfilename != NULL)
+ fprintf(stdout, "\t --map = %s\n", mapfilename);
+ else
+ fprintf(stdout, "\t --map = not in output\n");
+ if (npeople > 0)
+ fprintf(stdout, "\t --nids = %d\n", npeople);
+ else
+ fprintf(stdout, "\t --nids = estimated from data\n");
+ if (chrom != "-1")
+ cout << "\t --chrom = " << chrom << "\n";
+ else
+ cout << "\t --chrom = not in output\n";
+ if (outfilename != NULL)
+ fprintf(stdout, "\t --out = %s\n", outfilename);
+ else
+ fprintf(stdout, "\t --out = regression.out.txt\n");
+ fprintf(stdout, "\t --skipd = %d\n", skipd);
+ cout << "\t --separat = \"" << sep << "\"\n";
+ if (score)
+ fprintf(stdout, "\t --score = ON\n");
+ else
+ fprintf(stdout, "\t --score = OFF\n");
+ if (nohead)
+ fprintf(stdout, "\t --nohead = ON\n");
+ else
+ fprintf(stdout, "\t --nohead = OFF\n");
+ if (allcov)
+ fprintf(stdout, "\t --allcov = ON\n");
+ else
+ fprintf(stdout, "\t --allcov = OFF\n");
+ if (robust)
+ fprintf(stdout, "\t --robust = ON\n");
+ else
+ fprintf(stdout, "\t --robust = OFF\n");
+
+ if (ngpreds != 1 && ngpreds != 2)
+ {
+ fprintf(stderr,
+ "\n\n--ngpreds should be 1 for MLDOSE or 2 for MLPROB\n");
+ exit(1);
+ }
+
+ if (interaction_excluded != 0)
+ {
+ interaction = interaction_excluded; //ups
+ is_interaction_excluded = true;
+ }
+ if (outfilename == NULL)
+ {
+ outfilename = (char *) string("regression").c_str();
+ }
+}
Property changes on: branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.h
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.h (rev 0)
+++ branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.h 2012-04-08 14:37:34 UTC (rev 888)
@@ -0,0 +1,104 @@
+/*
+ * comand_line_settings.h
+ *
+ * Created on: Apr 2; int 2012
+ * Author: mkooyman
+ */
+
+#ifndef COMAND_LINE_SETTINGS_H_
+#define COMAND_LINE_SETTINGS_H_
+
+using namespace std;
+
+class cmdvars
+{
+private:
+
+ char * program_name;
+
+ char *phefilename;
+ char *mlinfofilename;
+ char *genfilename;
+ char *mapfilename;
+ char *outfilename;
+ char *inverse_filename;
+
+ string str_genfilename;
+
+ int nohead;
+ int score;
+ int npeople;
+ int ngpreds;
+ int interaction;
+ int interaction_excluded;
+ bool is_interaction_excluded;
+ int robust;
+ string chrom;
+ string sep;
+ int neco[3];
+ bool iscox;
+ int isFVF;
+ int noutcomes;
+ int skipd;
+ int allcov;
+
+public:
+ cmdvars()
+ {
+ program_name = NULL;
+
+ std::fill_n(neco, 3, 0);
+ phefilename = NULL;
+ mlinfofilename = NULL;
+ genfilename = NULL;
+ mapfilename = NULL;
+ outfilename = NULL;
+ inverse_filename = NULL;
+
+ sep = " ";
+ nohead = 0;
+ score = 0;
+ npeople = -1;
+ ngpreds = 1;
+ interaction = 0;
+ interaction_excluded = 0;
+ is_interaction_excluded = false; //Oh Holy Matrix, forgive me for this!
+ robust = 0;
+ chrom = "-1";
+ str_genfilename = "";
+
+ iscox = false;
+ isFVF = 0;
+ noutcomes = 1;
+ skipd = 2;
+ allcov = 0;
+ }
+ void set_variables(int, char *[]);
+ char* getPhefilename() const;
+ int getAllcov() const;
+ string getChrom() const;
+ char* getGenfilename() const;
+ int getInteraction() const;
+ char* getInverseFilename() const;
+ bool isIscox() const;
+ int getIsFvf() const;
+ char* getMapfilename() const;
+ char* getMlinfofilename() const;
+ const int* getNeco() const;
+ int getNgpreds() const;
+ int getNohead() const;
+ int getNoutcomes() const;
+ int getNpeople() const;
+ char* getOutfilename() const;
+ char* getProgramName() const;
+ int getRobust() const;
+ int getScore() const;
+ string getSep() const;
+ int getSkipd() const;
+ string getStrGenfilename() const;
+
+ void printinfo();
+ bool isIsInteractionExcluded() const;
+};
+
+#endif /* COMAND_LINE_SETTINGS_H_ */
Property changes on: branches/ProbABEL-refactoring/ProbABEL/src/comand_line_settings.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/ProbABEL-refactoring/ProbABEL/src/main.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/main.cpp 2012-04-03 11:25:44 UTC (rev 887)
+++ branches/ProbABEL-refactoring/ProbABEL/src/main.cpp 2012-04-08 14:37:34 UTC (rev 888)
@@ -12,7 +12,7 @@
// Modified by: L.C. Karssen,
// Maksim V. Struchalin
//
-// modified 14-May-2009 by MVS: interaction with SNP, interaction with SNP with exclusion of interacted covariates,
+// modified 14-May-2009 by MVS: interaction with SNP, interaction with SNP with exclusion of interacted covariates,
// mmscore implemented (poor me)
// modified 20-Jul-2009 by YSA: small changes, bug fix in mmscore option
// modified 22-Sep-2009 by YSA: "robust" option added
@@ -33,246 +33,29 @@
#include <string>
#include <iomanip>
#include <stdio.h>
-#include <getopt.h>
#include <vector>
#include <sstream>
-#include "config.h"
#include "mematrix.h"
#include "mematri1.h"
#include "data.h"
#include "reg1.h"
-#include "usage.h"
+#include "comand_line_settings.h"
#define MAXITER 10
#define EPS 1.e-8
#define CHOLTOL 1.5e-12
-bool is_interaction_excluded = false; //Oh Holy Matrix, forgive me for this!
-
int main(int argc, char * argv[])
{
- int next_option;
- const char * const short_options = "p:i:d:m:n:c:o:s:t:g:a:erlh:b:vu";
- //b - interaction parameter
- // ADD --fv FLAG (FILEVECTOR), IN WHICH CASE USE ALTERNATIVE
- // CONSTRUCTOR FOR GENDATA
- const struct option long_options[] =
- {
- { "pheno", 1, NULL, 'p' },
- { "info", 1, NULL, 'i' },
- { "dose", 1, NULL, 'd' },
- { "map", 1, NULL, 'm' },
- { "nids", 1, NULL, 'n' },
- { "chrom", 1, NULL, 'c' },
- { "out", 1, NULL, 'o' },
- { "skipd", 1, NULL, 's' },
- { "ntraits", 1, NULL, 't' },
- { "ngpreds", 1, NULL, 'g' },
- { "separat", 1, NULL, 'a' },
- { "score", 0, NULL, 'r' },
- { "no-head", 0, NULL, 'e' },
- { "allcov", 0, NULL, 'l' },
- { "help", 0, NULL, 'h' },
- { "interaction", 1, NULL, 'b' },
- { "interaction_only", 1, NULL, 'k' },
- { "mmscore", 1, NULL, 'v' },
- { "robust", 0, NULL, 'u' },
- { NULL, 0, NULL, 0 } };
- char * program_name = argv[0];
+ cmdvars input_var;
+ input_var.set_variables(argc, argv);
+ input_var.printinfo();
- char *phefilename = NULL;
- char *mlinfofilename = NULL;
- char *genfilename = NULL;
- char *mapfilename = NULL;
- char *outfilename = NULL;
- char *inverse_filename = NULL;
- string sep = " ";
- int nohead = 0;
- int score = 0;
- int npeople = -1;
- int ngpreds = 1;
- int interaction = 0;
- int interaction_excluded = 0;
- int robust = 0;
- string chrom = "-1";
- int neco[] =
- { 0, 0, 0 };
- bool iscox = false;
- int isFVF = 0;
#if COXPH
- int noutcomes = 2;
- iscox=true;
-#else
- int noutcomes = 1;
-#endif
- int skipd = 2;
- int allcov = 0;
- do
+ if (input_var.getScore())
{
- 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;
- 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();
- }
- } while (next_option != -1);
-
- fprintf(stdout,
- "%s v. %s (C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, EMCR\n\n",
- PACKAGE, PACKAGE_VERSION);
-
- if (neco[0] != 1 || neco[1] != 1 || neco[2] != 1)
- {
- print_usage(program_name, 1);
- }
-
- if (score)
- {
- cout << "option --score suppressed from v 0.1-6\n";
- exit(1);
- }
-
- string str_genfilename = genfilename;
- if (str_genfilename.find(FILEVECTOR_INDEX_FILE_SUFFIX) != string::npos
- || 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);
- 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);
-
- if (inverse_filename != NULL)
- fprintf(stdout, "\t --mmscore = %s\n", inverse_filename);
- else
- fprintf(stdout, "\t --mmscore = not in output\n");
- // fprintf(stdout,"\t --mmscore = %s\n",inverse_filename);
-
- if (mapfilename != NULL)
- fprintf(stdout, "\t --map = %s\n", mapfilename);
- else
- fprintf(stdout, "\t --map = not in output\n");
- if (npeople > 0)
- fprintf(stdout, "\t --nids = %d\n", npeople);
- else
- fprintf(stdout, "\t --nids = estimated from data\n");
- if (chrom != "-1")
- cout << "\t --chrom = " << chrom << "\n";
- else
- cout << "\t --chrom = not in output\n";
- if (outfilename != NULL)
- fprintf(stdout, "\t --out = %s\n", outfilename);
- else
- fprintf(stdout, "\t --out = regression.out.txt\n");
- fprintf(stdout, "\t --skipd = %d\n", skipd);
- cout << "\t --separat = \"" << sep << "\"\n";
- if (score)
- fprintf(stdout, "\t --score = ON\n");
- else
- fprintf(stdout, "\t --score = OFF\n");
- if (nohead)
- fprintf(stdout, "\t --nohead = ON\n");
- else
- fprintf(stdout, "\t --nohead = OFF\n");
- if (allcov)
- fprintf(stdout, "\t --allcov = ON\n");
- else
- fprintf(stdout, "\t --allcov = OFF\n");
- if (robust)
- fprintf(stdout, "\t --robust = ON\n");
- else
- fprintf(stdout, "\t --robust = OFF\n");
-
- if (ngpreds != 1 && ngpreds != 2)
- {
- fprintf(stderr,
- "\n\n--ngpreds should be 1 for MLDOSE or 2 for MLPROB\n");
- exit(1);
- }
-
- if (interaction_excluded != 0)
- {
- interaction = interaction_excluded; //ups
- is_interaction_excluded = true;
- }
-
-#if COXPH
- if (score)
- {
fprintf(stderr,"\n\nOption --score is implemented for linear and logistic models only\n");
exit(1);
}
@@ -283,32 +66,35 @@
// allcov = 0;
// }
- mlinfo mli(mlinfofilename, mapfilename);
+ mlinfo mli(input_var.getMlinfofilename(), input_var.getMapfilename());
int nsnps = mli.nsnps;
phedata phd;
- phd.set_is_interaction_excluded(is_interaction_excluded);
- phd.setphedata(phefilename, noutcomes, npeople, interaction, iscox);
+ phd.set_is_interaction_excluded(input_var.isIsInteractionExcluded());
+ phd.setphedata(input_var.getPhefilename(), input_var.getNoutcomes(),
+ input_var.getNpeople(), input_var.getInteraction(),
+ input_var.isIscox());
- int interaction_cox = interaction;
+ int interaction_cox = input_var.getInteraction();
#if COXPH
interaction_cox--;
#endif
- if (interaction < 0 || interaction > phd.ncov || interaction_cox > phd.ncov)
+ if (input_var.getInteraction() < 0 || input_var.getInteraction() > phd.ncov
+ || interaction_cox > phd.ncov)
{
std::cerr << "error: Interaction parameter is out of range (ineraction="
- << interaction << ") \n";
+ << input_var.getInteraction() << ") \n";
exit(1);
}
//interaction--;
- // if(inverse_filename != NULL && phd.ncov > 1)
+ // if(input_var.getInverseFilename()!= NULL && phd.ncov > 1)
// {
// std::cerr<<"Error: In mmscore you can not use any covariates. You phenotype file must conatin id column and trait (residuals) only\n";
// exit(1);
// }
- // if(inverse_filename != NULL && (allcov == 1 || score == 1 || interaction != 0 || ngpreds==2))
+ // if(input_var.getInverseFilename()!= NULL && (allcov == 1 || score == 1 || input_var.getInteraction()!= 0 || ngpreds==2))
// {
// std::cerr<<"Error: In mmscore you can use additive model without any inetractions only\n";
// exit(1);
@@ -319,33 +105,33 @@
/*
* now should be possible... delete this part later when everything works
#if LOGISTIC
- if(inverse_filename != NULL) {std::cerr<<"ERROR: mmscore is forbidden for logistic regression\n";exit(1);}
+ if(input_var.getInverseFilename()!= NULL) {std::cerr<<"ERROR: mmscore is forbidden for logistic regression\n";exit(1);}
#endif
*/
#if COXPH
- if(inverse_filename != NULL)
+ if(input_var.getInverseFilename()!= NULL)
{
std::cerr<<"ERROR: mmscore is forbidden for cox regression\n";
exit(1);
}
- if (robust)
+ if (input_var.getRobust())
{
std::cerr<<"ERROR: robust standard errors not implemented for Cox regression\n";
exit(1);
}
#endif
- if (inverse_filename != NULL)
+ if (input_var.getInverseFilename() != NULL)
{
std::cout << "you are running mmscore...\n";
}
std::cout << "Reading data ...";
- if (inverse_filename != NULL)
+ if (input_var.getInverseFilename() != NULL)
{
- InvSigma inv(inverse_filename, &phd);
+ InvSigma inv(input_var.getInverseFilename(), &phd);
invvarmatrix = inv.get_matrix();
double par = 1.; //var(phd.Y)*phd.nids/(phd.nids-phd.ncov-1);
invvarmatrix = invvarmatrix * par;
@@ -356,43 +142,46 @@
std::cout.flush();
gendata gtd;
- if (!isFVF)
- gtd.re_gendata(genfilename, nsnps, ngpreds, phd.nids_all, phd.nids,
- phd.allmeasured, skipd, phd.idnames);
+ if (!input_var.getIsFvf())
+ gtd.re_gendata(input_var.getGenfilename(), nsnps,
+ input_var.getNgpreds(), phd.nids_all, phd.nids, phd.allmeasured,
+ input_var.getSkipd(), phd.idnames);
else
- gtd.re_gendata(str_genfilename, nsnps, ngpreds, phd.nids_all, phd.nids,
- phd.allmeasured, phd.idnames);
+ gtd.re_gendata(input_var.getStrGenfilename(), nsnps,
+ input_var.getNgpreds(), phd.nids_all, phd.nids, phd.allmeasured,
+ phd.idnames);
std::cout << " loaded genotypic data ...";
/**
- if (isFVF)
- gendata gtd (str_genfilename,nsnps,ngpreds,phd.nids_all,phd.allmeasured,phd.idnames);
+ if (input_var.getIsFvf())
+ gendata gtd (str_genfilename,nsnps,input_var.getNgpreds(),phd.nids_all,phd.allmeasured,phd.idnames);
else
- gendata gtd (genfilename,nsnps,ngpreds,phd.nids_all,phd.nids,phd.allmeasured,skipd,phd.idnames);
+ gendata gtd (input_var.getGenfilename(),nsnps,input_var.getNgpreds(),phd.nids_all,phd.nids,phd.allmeasured,skipd,phd.idnames);
**/
// estimate null model
double null_loglik = 0.;
#if COXPH
- coxph_data nrgd=coxph_data(phd,gtd,-1);
-#else
- regdata nrgd = regdata(phd, gtd, -1);
+ coxph_data nrgd=coxph_data(phd,gtd,-1,input_var.isIsInteractionExcluded());
+#else
+ regdata nrgd = regdata(phd, gtd, -1,input_var.isIsInteractionExcluded());
#endif
std::cout << " loaded null data ...";
#if LOGISTIC
logistic_reg nrd=logistic_reg(nrgd);
- nrd.estimate(nrgd,0,MAXITER,EPS,CHOLTOL,0, interaction, ngpreds, invvarmatrix, robust, 1);
+ nrd.estimate(nrgd,0,MAXITER,EPS,CHOLTOL,0,input_var.getInteraction(), input_var.getNgpreds(), invvarmatrix, input_var.getRobust(), 1);
#elif LINEAR
- linear_reg nrd=linear_reg(nrgd);
+ linear_reg nrd = linear_reg(nrgd);
- nrd.estimate(nrgd,0,CHOLTOL,0, interaction, ngpreds, invvarmatrix, robust, 1);
+ nrd.estimate(nrgd, 0, CHOLTOL, 0, input_var.getInteraction(),
+ input_var.getNgpreds(), invvarmatrix, input_var.getRobust(), 1);
#elif COXPH
coxph_reg nrd(nrgd);
- nrd.estimate(nrgd,0,MAXITER,EPS,CHOLTOL,0, interaction, ngpreds, 1);
+ nrd.estimate(nrgd,0,MAXITER,EPS,CHOLTOL,0, input_var.getInteraction(), input_var.getNgpreds(), 1);
#endif
null_loglik = nrd.loglik;
@@ -400,9 +189,9 @@
// end null
#if COXPH
- coxph_data rgd(phd,gtd,0);
+ coxph_data rgd(phd,gtd,0,input_var.isIsInteractionExcluded());
#else
- regdata rgd(phd, gtd, 0);
+ regdata rgd(phd, gtd, 0,input_var.isIsInteractionExcluded());
#endif
std::cout << " formed regression object ...";
@@ -413,18 +202,13 @@
//________________________________________________________________
//Maksim, 9 Jan, 2009
- if (outfilename == NULL)
- {
- outfilename = (char *) string("regression").c_str();
- }
-
- std::string outfilename_str(outfilename);
+ std::string outfilename_str(input_var.getOutfilename());
std::vector<std::ofstream*> outfile;
- if (nohead != 1)
+ if (input_var.getNohead() != 1)
{
- if (ngpreds == 2) //All models output. One file per each model
+ if (input_var.getNgpreds() == 2) //All models output. One file per each model
{
// open a file for output
//_____________________
@@ -476,74 +260,88 @@
//_____________________
for (int i = 0; i < outfile.size(); i++)
{
- (*outfile[i]) << "name" << sep << "A1" << sep << "A2" << sep
- << "Freq1" << sep << "MAF" << sep << "Quality" << sep
- << "Rsq" << sep << "n" << sep
- << "Mean_predictor_allele";
- if (chrom != "-1")
- (*outfile[i]) << sep << "chrom";
- if (mapfilename != NULL)
- (*outfile[i]) << sep << "position";
+ (*outfile[i]) << "name" << input_var.getSep() << "A1"
+ << input_var.getSep() << "A2" << input_var.getSep()
+ << "Freq1" << input_var.getSep() << "MAF"
+ << input_var.getSep() << "Quality" << input_var.getSep()
+ << "Rsq" << input_var.getSep() << "n"
+ << input_var.getSep() << "Mean_predictor_allele";
+ if (input_var.getChrom() != "-1")
+ (*outfile[i]) << input_var.getSep()
+ << "input_var.getChrom()";
+ if (input_var.getMapfilename() != NULL)
+ (*outfile[i]) << input_var.getSep() << "position";
}
//_____________________
- if (allcov) //All covariates in output
+ if (input_var.getAllcov()) //All covariates in output
{
for (int file = 0; file < outfile.size(); file++)
for (int i = 0; i < phd.n_model_terms - 1; i++)
- *outfile[file] << sep << "beta_" << phd.model_terms[i]
- << sep << "sebeta_" << phd.model_terms[i];
+ *outfile[file] << input_var.getSep() << "beta_"
+ << phd.model_terms[i] << input_var.getSep()
+ << "sebeta_" << phd.model_terms[i];
}
- *outfile[0] << sep << "beta_SNP_A1A2" << sep << "beta_SNP_A1A1"
- << sep << "sebeta_SNP_A1A2" << sep << "sebeta_SNP_A1A1";
+ *outfile[0] << input_var.getSep() << "beta_SNP_A1A2"
+ << input_var.getSep() << "beta_SNP_A1A1"
+ << input_var.getSep() << "sebeta_SNP_A1A2"
+ << input_var.getSep() << "sebeta_SNP_A1A1";
- *outfile[1] << sep << "beta_SNP_addA1" << sep << "sebeta_SNP_addA1";
- *outfile[2] << sep << "beta_SNP_domA1" << sep << "sebeta_SNP_domA1";
- *outfile[3] << sep << "beta_SNP_recA1" << sep << "sebeta_SNP_recA1";
- *outfile[4] << sep << "beta_SNP_odom" << sep << "sebeta_SNP_odom";
+ *outfile[1] << input_var.getSep() << "beta_SNP_addA1"
+ << input_var.getSep() << "sebeta_SNP_addA1";
+ *outfile[2] << input_var.getSep() << "beta_SNP_domA1"
+ << input_var.getSep() << "sebeta_SNP_domA1";
+ *outfile[3] << input_var.getSep() << "beta_SNP_recA1"
+ << input_var.getSep() << "sebeta_SNP_recA1";
+ *outfile[4] << input_var.getSep() << "beta_SNP_odom"
+ << input_var.getSep() << "sebeta_SNP_odom";
- if (interaction != 0)
+ if (input_var.getInteraction() != 0)
{
//Han Chen
- *outfile[0] << sep << "beta_SNP_A1A2_"
- << phd.model_terms[interaction_cox] << sep
- << "sebeta_SNP_A1A2_"
- << phd.model_terms[interaction_cox] << sep
- << "beta_SNP_A1A1_" << phd.model_terms[interaction_cox]
- << sep << "sebeta_SNP_A1A1_"
+ *outfile[0] << input_var.getSep() << "beta_SNP_A1A2_"
+ << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "sebeta_SNP_A1A2_"
+ << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "beta_SNP_A1A1_"
+ << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "sebeta_SNP_A1A1_"
<< phd.model_terms[interaction_cox];
#if !COXPH
- if (inverse_filename == NULL && !allcov)
+ if (input_var.getInverseFilename() == NULL
+ && !input_var.getAllcov())
{
- *outfile[0] << sep << "cov_SNP_A1A2_int_SNP_"
- << phd.model_terms[interaction_cox] << sep
- << "cov_SNP_A1A1_int_SNP_"
+ *outfile[0] << input_var.getSep() << "cov_SNP_A1A2_int_SNP_"
+ << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "cov_SNP_A1A1_int_SNP_"
<< phd.model_terms[interaction_cox];
}
#endif
//Oct 26, 2009
for (int file = 1; file < outfile.size(); file++)
{
- *outfile[file] << sep << "beta_SNP_"
- << phd.model_terms[interaction_cox] << sep
- << "sebeta_SNP_"
+ *outfile[file] << input_var.getSep() << "beta_SNP_"
+ << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "sebeta_SNP_"
<< phd.model_terms[interaction_cox];
//Han Chen
#if !COXPH
- if (inverse_filename == NULL && !allcov)
+ if (input_var.getInverseFilename() == NULL
+ && !input_var.getAllcov())
{
- *outfile[file] << sep << "cov_SNP_int_SNP_"
+ *outfile[file] << input_var.getSep()
+ << "cov_SNP_int_SNP_"
<< phd.model_terms[interaction_cox];
}
#endif
//Oct 26, 2009
}
}
- *outfile[0] << sep << "loglik\n"; //"chi2_SNP_2df\n";
- *outfile[1] << sep << "loglik\n"; //"chi2_SNP_A1\n";
- *outfile[2] << sep << "loglik\n"; //"chi2_SNP_domA1\n";
- *outfile[3] << sep << "loglik\n"; //"chi2_SNP_recA1\n";
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/genabel -r 888
More information about the Genabel-commits
mailing list