From 3f5d57d302188525f266ec041ebb745f6931876e Mon Sep 17 00:00:00 2001 From: Peter Carbonetto Date: Tue, 30 May 2017 22:36:50 -0500 Subject: Removing FORCE_FLOAT from some C++ source files. --- src/param.cpp | 319 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 196 insertions(+), 123 deletions(-) (limited to 'src/param.cpp') diff --git a/src/param.cpp b/src/param.cpp index 4b8c3a4..63bf349 100644 --- a/src/param.cpp +++ b/src/param.cpp @@ -1,6 +1,6 @@ /* Genome-wide Efficient Mixed Model Association (GEMMA) - Copyright (C) 2011 Xiang Zhou + Copyright (C) 2011-2017 Xiang Zhou This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . */ #include @@ -33,29 +33,20 @@ #include "eigenlib.h" #include "mathfunc.h" - -#ifdef FORCE_FLOAT -#include "param_float.h" -#include "io_float.h" -#else #include "param.h" #include "io.h" -#endif using namespace std; - - - - PARAM::PARAM(void): mode_silence (false), a_mode (0), k_mode(1), d_pace (100000), file_out("result"), path_out("./output/"), miss_level(0.05), maf_level(0.01), hwe_level(0), r2_level(0.9999), -l_min(1e-5), l_max(1e5), n_region(10),p_nr(0.001),em_prec(0.0001),nr_prec(0.0001),em_iter(10000),nr_iter(100),crt(0), +l_min(1e-5), l_max(1e5), n_region(10),p_nr(0.001),em_prec(0.0001), +nr_prec(0.0001),em_iter(10000),nr_iter(100),crt(0), pheno_mean(0), noconstrain (false), -h_min(-1), h_max(-1), h_scale(-1), -rho_min(0.0), rho_max(1.0), rho_scale(-1), +h_min(-1), h_max(-1), h_scale(-1), +rho_min(0.0), rho_max(1.0), rho_scale(-1), logp_min(0.0), logp_max(0.0), logp_scale(-1), h_ngrid(10), rho_ngrid(10), s_min(0), s_max(300), @@ -68,31 +59,22 @@ randseed(-1), window_cm(0), window_bp(0), window_ns(0), n_block(200), error(false), ni_subsample(0), n_cvt(1), n_vc(1), n_cat(0), -time_total(0.0), time_G(0.0), time_eigen(0.0), time_UtX(0.0), time_UtZ(0.0), time_opt(0.0), time_Omega(0.0) +time_total(0.0), time_G(0.0), time_eigen(0.0), time_UtX(0.0), +time_UtZ(0.0), time_opt(0.0), time_Omega(0.0) {} - -//read files -//obtain ns_total, ng_total, ns_test, ni_test -void PARAM::ReadFiles (void) -{ +// Read files: obtain ns_total, ng_total, ns_test, ni_test. +void PARAM::ReadFiles (void) { string file_str; - /* - //read continuous cat file - if (!file_mcatc.empty()) { - if (ReadFile_mcatc (file_mcatc, mapRS2catc, n_cat)==false) {error=true;} - } else if (!file_catc.empty()) { - if (ReadFile_catc (file_catc, mapRS2catc, n_cat)==false) {error=true;} - } - */ - //read cat file + + // Read cat file. if (!file_mcat.empty()) { if (ReadFile_mcat (file_mcat, mapRS2cat, n_vc)==false) {error=true;} } else if (!file_cat.empty()) { if (ReadFile_cat (file_cat, mapRS2cat, n_vc)==false) {error=true;} } - //read snp weight files + // Read snp weight files. if (!file_wcat.empty()) { if (ReadFile_wsnp (file_wcat, n_vc, mapRS2wcat)==false) {error=true;} } @@ -100,45 +82,60 @@ void PARAM::ReadFiles (void) if (ReadFile_wsnp (file_wsnp, mapRS2wsnp)==false) {error=true;} } - //count number of kinship files + // Count number of kinship files. if (!file_mk.empty()) { if (CountFileLines (file_mk, n_vc)==false) {error=true;} } - //read snp set + // Read SNP set. if (!file_snps.empty()) { if (ReadFile_snps (file_snps, setSnps)==false) {error=true;} } else { setSnps.clear(); } - //for prediction + // For prediction. if (!file_epm.empty()) { - if (ReadFile_est (file_epm, est_column, mapRS2est)==false) {error=true;} - + if (ReadFile_est (file_epm, est_column, mapRS2est)==false) { + error=true; + } if (!file_bfile.empty()) { file_str=file_bfile+".bim"; - if (ReadFile_bim (file_str, snpInfo)==false) {error=true;} - + if (ReadFile_bim (file_str, snpInfo)==false) { + error=true; + } file_str=file_bfile+".fam"; - if (ReadFile_fam (file_str, indicator_pheno, pheno, mapID2num, p_column)==false) {error=true;} + if (ReadFile_fam (file_str, indicator_pheno, pheno, + mapID2num, p_column)==false) { + error=true; + } } if (!file_geno.empty()) { - if (ReadFile_pheno (file_pheno, indicator_pheno, pheno, p_column)==false) {error=true;} + if (ReadFile_pheno (file_pheno, indicator_pheno, + pheno, p_column)==false) { + error=true; + } - if (CountFileLines (file_geno, ns_total)==false) {error=true;} + if (CountFileLines (file_geno, ns_total)==false) { + error=true; + } } if (!file_ebv.empty() ) { - if (ReadFile_column (file_ebv, indicator_bv, vec_bv, 1)==false) {error=true;} + if (ReadFile_column (file_ebv, indicator_bv, + vec_bv, 1)==false) { + error=true; + } } if (!file_log.empty() ) { - if (ReadFile_log (file_log, pheno_mean)==false) {error=true;} + if (ReadFile_log (file_log, pheno_mean)==false) { + error=true; + } } - //convert indicator_pheno to indicator_idv + // Convert indicator_pheno to indicator_idv. int k=1; for (size_t i=0; i::size_type i=0; i<(indicator_idv).size(); ++i) { + for (vector::size_type i=0; + i<(indicator_idv).size(); + ++i) { indicator_idv[i]*=indicator_read[i]; ni_test+=indicator_idv[i]; } if (ni_test==0) { - error=true; - cout<<"error! number of analyzed individuals equals 0. "<1) {cout<<"error! missing level needs to be between 0 and 1. current value = "<1 && a_mode!=1 && a_mode!=2 && a_mode!=3 && a_mode!=4 && a_mode!=43) { cout<<"error! the current analysis mode "<