aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiangzhou2015-07-11 15:36:03 -0400
committerxiangzhou2015-07-11 15:36:03 -0400
commit3ab77854a52ac016b9e2b824858f5f0c695d4170 (patch)
tree040c78f03f5bf22df7c4b2b8263702a842249adf
parent2e82184182d8bbaa2cc3fa8088058bf3de2048bd (diff)
downloadpangemma-3ab77854a52ac016b9e2b824858f5f0c695d4170.tar.gz
add GxE test
-rw-r--r--src/io.cpp31
-rw-r--r--src/param.cpp15
2 files changed, 23 insertions, 23 deletions
diff --git a/src/io.cpp b/src/io.cpp
index d6a70dd..03b8e3f 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -1759,17 +1759,18 @@ bool ReadFile_sample(const string &file_sample, vector<vector<int> > &indicator_
pheno_row.push_back(-9);
ind_pheno_row.push_back(0);
}
+
// read header line1
if(!safeGetline(infile, line).eof()) {
- ch_ptr=strtok((char *)line.c_str(), " ");
+ ch_ptr=strtok((char *)line.c_str(), " \t");
if(strcmp(ch_ptr, "ID_1")!=0) {return false;}
- ch_ptr=strtok(NULL, " ");
+ ch_ptr=strtok(NULL, " \t");
if(strcmp(ch_ptr, "ID_2")!=0) {return false;}
- ch_ptr=strtok(NULL, " ");
+ ch_ptr=strtok(NULL, " \t");
if(strcmp(ch_ptr, "missing")!=0) {return false;}
while (ch_ptr!=NULL) {
num_cols++;
- ch_ptr=strtok (NULL, " ");
+ ch_ptr=strtok (NULL, " \t");
}
num_cols--;
@@ -1780,30 +1781,30 @@ bool ReadFile_sample(const string &file_sample, vector<vector<int> > &indicator_
char col_type[num_cols];
// read header line2
if(!safeGetline(infile, line).eof()) {
- ch_ptr=strtok ((char *)line.c_str(), " ");
+ ch_ptr=strtok ((char *)line.c_str(), " \t");
if(strcmp(ch_ptr, "0")!=0) {return false;}
- ch_ptr=strtok(NULL, " ");
+ ch_ptr=strtok(NULL, " \t");
if(strcmp(ch_ptr, "0")!=0) {return false;}
- ch_ptr=strtok(NULL, " ");
+ ch_ptr=strtok(NULL, " \t");
if(strcmp(ch_ptr, "0")!=0) {return false;}
size_t it=0;
- ch_ptr=strtok (NULL, " ");
+ ch_ptr=strtok (NULL, " \t");
if(ch_ptr!=NULL)
while(ch_ptr!=NULL){
col_type[it++]=ch_ptr[0];
if(ch_ptr[0]=='D') {cvt_factor_levels.push_back(map<uint32_t, size_t>());num_cvt_in_file++;}
if(ch_ptr[0]=='C') {num_cvt_in_file++;}
if((ch_ptr[0]=='P')||(ch_ptr[0]=='B')) {num_p_in_file++;}
- ch_ptr=strtok(NULL, " ");
+ ch_ptr=strtok(NULL, " \t");
}
}
while (!safeGetline(infile, line).eof()) {
- ch_ptr=strtok ((char *)line.c_str(), " ");
+ ch_ptr=strtok ((char *)line.c_str(), " \t");
- for(int it=0;it<3;it++){ch_ptr=strtok(NULL, " ");}
+ for(int it=0;it<3;it++){ch_ptr=strtok(NULL, " \t");}
size_t i=0;
@@ -1827,7 +1828,7 @@ bool ReadFile_sample(const string &file_sample, vector<vector<int> > &indicator_
fac_cvt_i++;
}
- ch_ptr=strtok (NULL, " ");
+ ch_ptr=strtok (NULL, " \t");
i++;
}
@@ -1853,9 +1854,9 @@ bool ReadFile_sample(const string &file_sample, vector<vector<int> > &indicator_
while (!safeGetline(infile2, line).eof()) {
vector<double> v_d; flag_na=0;
- ch_ptr=strtok ((char *)line.c_str(), " ");
+ ch_ptr=strtok ((char *)line.c_str(), " \t");
- for(int it=0;it<3;it++){ch_ptr=strtok(NULL, " ");}
+ for(int it=0;it<3;it++){ch_ptr=strtok(NULL, " \t");}
size_t i=0;
@@ -1884,7 +1885,7 @@ bool ReadFile_sample(const string &file_sample, vector<vector<int> > &indicator_
fac_cvt_i++;
}
- ch_ptr=strtok (NULL, " ");
+ ch_ptr=strtok (NULL, " \t");
i++;
}
diff --git a/src/param.cpp b/src/param.cpp
index c4b234a..33b7b48 100644
--- a/src/param.cpp
+++ b/src/param.cpp
@@ -169,7 +169,6 @@ void PARAM::ReadFiles (void)
//post-process covariates and phenotypes, obtain ni_test, save all useful covariates
ProcessCvtPhen();
-
//obtain covariate matrix
gsl_matrix *W=gsl_matrix_alloc (ni_test, n_cvt);
CopyCvt (W);
@@ -242,12 +241,12 @@ void PARAM::ReadFiles (void)
indicator_idv.push_back(k);
}
- //post-process covariates and phenotypes, obtain ni_test, save all useful covariates
- ProcessCvtPhen();
+ //post-process covariates and phenotypes, obtain ni_test, save all useful covariates
+ ProcessCvtPhen();
- //obtain covariate matrix
- gsl_matrix *W=gsl_matrix_alloc (ni_test, n_cvt);
- CopyCvt (W);
+ //obtain covariate matrix
+ gsl_matrix *W=gsl_matrix_alloc (ni_test, n_cvt);
+ CopyCvt (W);
if (ReadFile_gene (file_gene, vec_read, snpInfo, ng_total)==false) {error=true;}
}
@@ -381,9 +380,9 @@ void PARAM::CheckParam (void)
}
if (!file_oxford.empty()) {
- str=file_bfile+".bgen";
+ str=file_oxford+".bgen";
if (stat(str.c_str(),&fileInfo)==-1) {cout<<"error! fail to open .bgen file: "<<str<<endl; error=true;}
- str=file_bfile+".sample";
+ str=file_oxford+".sample";
if (stat(str.c_str(),&fileInfo)==-1) {cout<<"error! fail to open .sample file: "<<str<<endl; error=true;}
}