From 3935ba39d30666dd7d4a831155631847c77b70c4 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 2 Aug 2017 08:46:58 +0000 Subject: Massive patch using LLVM coding style. It was generated with: clang-format -style=LLVM -i *.cpp *.h Please set your editor to replace tabs with spaces and use indentation of 2 spaces. --- src/io.h | 335 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 156 insertions(+), 179 deletions(-) (limited to 'src/io.h') diff --git a/src/io.h b/src/io.h index 9d6f8cc..3e1145a 100644 --- a/src/io.h +++ b/src/io.h @@ -19,195 +19,172 @@ #ifndef __IO_H__ #define __IO_H__ -#include -#include -#include -#include "gsl/gsl_vector.h" #include "gsl/gsl_matrix.h" +#include "gsl/gsl_vector.h" +#include +#include +#include #include "gzstream.h" #include "param.h" using namespace std; -void ProgressBar (string str, double p, double total); -void ProgressBar (string str, double p, double total, double ratio); -std::istream& safeGetline(std::istream& is, std::string& t); - -bool ReadFile_snps (const string &file_snps, set &setSnps); -bool ReadFile_snps_header (const string &file_snps, set &setSnps); -bool ReadFile_log (const string &file_log, double &pheno_mean); - -bool ReadFile_bim (const string &file_bim, vector &snpInfo); -bool ReadFile_fam (const string &file_fam, - vector > &indicator_pheno, - vector > &pheno, - map &mapID2num, - const vector &p_column); - -bool ReadFile_cvt (const string &file_cvt, - vector &indicator_cvt, - vector > &cvt, - size_t &n_cvt); -bool ReadFile_anno (const string &file_bim, map &mapRS2chr, - map &mapRS2bp, - map &mapRS2cM); -bool ReadFile_pheno (const string &file_pheno, - vector > &indicator_pheno, - vector > &pheno, - const vector &p_column); -bool ReadFile_column (const string &file_pheno, vector &indicator_idv, - vector &pheno, const int &p_column); - -bool ReadFile_geno (const string &file_geno, const set &setSnps, - const gsl_matrix *W, vector &indicator_idv, - vector &indicator_snp, const double &maf_level, - const double &miss_level, const double &hwe_level, - const double &r2_level, map &mapRS2chr, - map &mapRS2bp, - map &mapRS2cM, vector &snpInfo, - size_t &ns_test); -bool ReadFile_bed (const string &file_bed, const set &setSnps, - const gsl_matrix *W, vector &indicator_idv, - vector &indicator_snp, vector &snpInfo, - const double &maf_level, const double &miss_level, - const double &hwe_level, const double &r2_level, - size_t &ns_test); -bool Bimbam_ReadOneSNP (const size_t inc, const vector &indicator_idv, - igzstream &infile, gsl_vector *geno, - double &geno_mean); -void Plink_ReadOneSNP (const int pos, const vector &indicator_idv, - ifstream &infile, gsl_vector *geno, double &geno_mean); - -void ReadFile_kin (const string &file_kin, vector &indicator_idv, - map &mapID2num, const size_t k_mode, - bool &error, gsl_matrix *G); -void ReadFile_mk (const string &file_mk, vector &indicator_idv, - map &mapID2num, const size_t k_mode, - bool &error, gsl_matrix *G); -void ReadFile_eigenU (const string &file_u, bool &error, gsl_matrix *U); -void ReadFile_eigenD (const string &file_d, bool &error, gsl_vector *eval); - -bool BimbamKin (const string &file_geno, vector &indicator_snp, - const int k_mode, const int display_pace, - gsl_matrix *matrix_kin); -bool PlinkKin (const string &file_bed, vector &indicator_snp, - const int k_mode, const int display_pace, - gsl_matrix *matrix_kin); - -bool ReadFile_geno (const string &file_geno, vector &indicator_idv, - vector &indicator_snp, gsl_matrix *UtX, - gsl_matrix *K, const bool calc_K); -bool ReadFile_bed (const string &file_bed, vector &indicator_idv, - vector &indicator_snp, gsl_matrix *UtX, - gsl_matrix *K, const bool calc_K); -bool ReadFile_geno (const string &file_geno, vector &indicator_idv, - vector &indicator_snp, - vector > &Xt, gsl_matrix *K, - const bool calc_K, const size_t ni_test, - const size_t ns_test); -bool ReadFile_bed (const string &file_bed, vector &indicator_idv, - vector &indicator_snp, - vector > &Xt, gsl_matrix *K, - const bool calc_K, const size_t ni_test, - const size_t ns_test); - -bool ReadFile_est (const string &file_est, const vector &est_column, - map &mapRS2est); - -bool CountFileLines (const string &file_input, size_t &n_lines); - -bool ReadFile_gene (const string &file_gene, vector &vec_read, - vector &snpInfo, size_t &ng_total); - -bool ReadHeader_io (const string &line, HEADER &header); -bool ReadFile_cat (const string &file_cat, map &mapRS2cat, - size_t &n_vc); -bool ReadFile_mcat (const string &file_mcat, map &mapRS2cat, - size_t &n_vc); - -bool ReadFile_catc (const string &file_cat, - map > &mapRS2catc, - size_t &n_cat); -bool ReadFile_mcatc (const string &file_mcat, map > &mapRS2catc, size_t &n_cat); - -bool BimbamKin (const string &file_geno, const int display_pace, - const vector &indicator_idv, - const vector &indicator_snp, - const map &mapRS2weight, - const map &mapRS2cat, - const vector &snpInfo, const gsl_matrix *W, - gsl_matrix *matrix_kin, gsl_vector *vector_ns); -bool PlinkKin (const string &file_bed, const int display_pace, - const vector &indicator_idv, - const vector &indicator_snp, - const map &mapRS2weight, - const map &mapRS2cat, - const vector &snpInfo, - const gsl_matrix *W, gsl_matrix *matrix_kin, - gsl_vector *vector_ns); -bool MFILEKin (const size_t mfile_mode, const string &file_mfile, - const int display_pace, const vector &indicator_idv, - const vector > &mindicator_snp, - const map &mapRS2weight, - const map &mapRS2cat, - const vector > &msnpInfo, - const gsl_matrix *W, gsl_matrix *matrix_kin, - gsl_vector *vector_ns); - -bool ReadFile_wsnp (const string &file_wsnp, - map &mapRS2double); -bool ReadFile_wsnp (const string &file_wcat, const size_t n_vc, - map > &mapRS2vector); - -void ReadFile_beta (const string &file_beta, - const map &mapRS2cat, - const map &mapRS2wA, - vector &vec_cat, vector &vec_ni, - vector &vec_weight, vector &vec_z2, - size_t &ni_total, size_t &ns_total, size_t &ns_test); -void ReadFile_beta (const string &file_beta, - const map &mapRS2wA, - map &mapRS2A1, - map &mapRS2z); -void Calcq (const size_t n_block, const vector &vec_cat, - const vector &vec_ni, - const vector &vec_weight, const vector &vec_z2, - gsl_matrix *Vq, gsl_vector *q, gsl_vector *s); - -void ReadFile_study (const string &file_study, gsl_matrix *Vq, - gsl_vector *q_vec, gsl_vector *s_vec, size_t &ni); -void ReadFile_ref (const string &file_ref, gsl_matrix *S_mat, - gsl_matrix *Svar_mat, gsl_vector *s_vec, size_t &ni); -void ReadFile_mstudy (const string &file_mstudy, gsl_matrix *Vq, - gsl_vector *q_vec, gsl_vector *s_vec, size_t &ni); -void ReadFile_mref (const string &file_mref, gsl_matrix *S_mat, - gsl_matrix *Svar_mat, gsl_vector *s_vec, size_t &ni); +void ProgressBar(string str, double p, double total); +void ProgressBar(string str, double p, double total, double ratio); +std::istream &safeGetline(std::istream &is, std::string &t); + +bool ReadFile_snps(const string &file_snps, set &setSnps); +bool ReadFile_snps_header(const string &file_snps, set &setSnps); +bool ReadFile_log(const string &file_log, double &pheno_mean); + +bool ReadFile_bim(const string &file_bim, vector &snpInfo); +bool ReadFile_fam(const string &file_fam, vector> &indicator_pheno, + vector> &pheno, map &mapID2num, + const vector &p_column); + +bool ReadFile_cvt(const string &file_cvt, vector &indicator_cvt, + vector> &cvt, size_t &n_cvt); +bool ReadFile_anno(const string &file_bim, map &mapRS2chr, + map &mapRS2bp, + map &mapRS2cM); +bool ReadFile_pheno(const string &file_pheno, + vector> &indicator_pheno, + vector> &pheno, + const vector &p_column); +bool ReadFile_column(const string &file_pheno, vector &indicator_idv, + vector &pheno, const int &p_column); + +bool ReadFile_geno(const string &file_geno, const set &setSnps, + const gsl_matrix *W, vector &indicator_idv, + vector &indicator_snp, const double &maf_level, + const double &miss_level, const double &hwe_level, + const double &r2_level, map &mapRS2chr, + map &mapRS2bp, + map &mapRS2cM, vector &snpInfo, + size_t &ns_test); +bool ReadFile_bed(const string &file_bed, const set &setSnps, + const gsl_matrix *W, vector &indicator_idv, + vector &indicator_snp, vector &snpInfo, + const double &maf_level, const double &miss_level, + const double &hwe_level, const double &r2_level, + size_t &ns_test); +bool Bimbam_ReadOneSNP(const size_t inc, const vector &indicator_idv, + igzstream &infile, gsl_vector *geno, double &geno_mean); +void Plink_ReadOneSNP(const int pos, const vector &indicator_idv, + ifstream &infile, gsl_vector *geno, double &geno_mean); + +void ReadFile_kin(const string &file_kin, vector &indicator_idv, + map &mapID2num, const size_t k_mode, bool &error, + gsl_matrix *G); +void ReadFile_mk(const string &file_mk, vector &indicator_idv, + map &mapID2num, const size_t k_mode, bool &error, + gsl_matrix *G); +void ReadFile_eigenU(const string &file_u, bool &error, gsl_matrix *U); +void ReadFile_eigenD(const string &file_d, bool &error, gsl_vector *eval); + +bool BimbamKin(const string &file_geno, vector &indicator_snp, + const int k_mode, const int display_pace, + gsl_matrix *matrix_kin); +bool PlinkKin(const string &file_bed, vector &indicator_snp, + const int k_mode, const int display_pace, gsl_matrix *matrix_kin); + +bool ReadFile_geno(const string &file_geno, vector &indicator_idv, + vector &indicator_snp, gsl_matrix *UtX, gsl_matrix *K, + const bool calc_K); +bool ReadFile_bed(const string &file_bed, vector &indicator_idv, + vector &indicator_snp, gsl_matrix *UtX, gsl_matrix *K, + const bool calc_K); +bool ReadFile_geno(const string &file_geno, vector &indicator_idv, + vector &indicator_snp, + vector> &Xt, gsl_matrix *K, + const bool calc_K, const size_t ni_test, + const size_t ns_test); +bool ReadFile_bed(const string &file_bed, vector &indicator_idv, + vector &indicator_snp, vector> &Xt, + gsl_matrix *K, const bool calc_K, const size_t ni_test, + const size_t ns_test); + +bool ReadFile_est(const string &file_est, const vector &est_column, + map &mapRS2est); + +bool CountFileLines(const string &file_input, size_t &n_lines); + +bool ReadFile_gene(const string &file_gene, vector &vec_read, + vector &snpInfo, size_t &ng_total); + +bool ReadHeader_io(const string &line, HEADER &header); +bool ReadFile_cat(const string &file_cat, map &mapRS2cat, + size_t &n_vc); +bool ReadFile_mcat(const string &file_mcat, map &mapRS2cat, + size_t &n_vc); + +bool ReadFile_catc(const string &file_cat, + map> &mapRS2catc, size_t &n_cat); +bool ReadFile_mcatc(const string &file_mcat, + map> &mapRS2catc, size_t &n_cat); + +bool BimbamKin(const string &file_geno, const int display_pace, + const vector &indicator_idv, + const vector &indicator_snp, + const map &mapRS2weight, + const map &mapRS2cat, + const vector &snpInfo, const gsl_matrix *W, + gsl_matrix *matrix_kin, gsl_vector *vector_ns); +bool PlinkKin(const string &file_bed, const int display_pace, + const vector &indicator_idv, + const vector &indicator_snp, + const map &mapRS2weight, + const map &mapRS2cat, + const vector &snpInfo, const gsl_matrix *W, + gsl_matrix *matrix_kin, gsl_vector *vector_ns); +bool MFILEKin(const size_t mfile_mode, const string &file_mfile, + const int display_pace, const vector &indicator_idv, + const vector> &mindicator_snp, + const map &mapRS2weight, + const map &mapRS2cat, + const vector> &msnpInfo, const gsl_matrix *W, + gsl_matrix *matrix_kin, gsl_vector *vector_ns); + +bool ReadFile_wsnp(const string &file_wsnp, map &mapRS2double); +bool ReadFile_wsnp(const string &file_wcat, const size_t n_vc, + map> &mapRS2vector); + +void ReadFile_beta(const string &file_beta, + const map &mapRS2cat, + const map &mapRS2wA, vector &vec_cat, + vector &vec_ni, vector &vec_weight, + vector &vec_z2, size_t &ni_total, size_t &ns_total, + size_t &ns_test); +void ReadFile_beta(const string &file_beta, const map &mapRS2wA, + map &mapRS2A1, map &mapRS2z); +void Calcq(const size_t n_block, const vector &vec_cat, + const vector &vec_ni, const vector &vec_weight, + const vector &vec_z2, gsl_matrix *Vq, gsl_vector *q, + gsl_vector *s); + +void ReadFile_study(const string &file_study, gsl_matrix *Vq, gsl_vector *q_vec, + gsl_vector *s_vec, size_t &ni); +void ReadFile_ref(const string &file_ref, gsl_matrix *S_mat, + gsl_matrix *Svar_mat, gsl_vector *s_vec, size_t &ni); +void ReadFile_mstudy(const string &file_mstudy, gsl_matrix *Vq, + gsl_vector *q_vec, gsl_vector *s_vec, size_t &ni); +void ReadFile_mref(const string &file_mref, gsl_matrix *S_mat, + gsl_matrix *Svar_mat, gsl_vector *s_vec, size_t &ni); // WJA added. -bool bgenKin (const string &file_geno, vector &indicator_snp, - const int k_mode, const int display_pace, - gsl_matrix *matrix_kin); +bool bgenKin(const string &file_geno, vector &indicator_snp, + const int k_mode, const int display_pace, gsl_matrix *matrix_kin); bool ReadFile_bgen(const string &file_bgen, const set &setSnps, - const gsl_matrix *W, vector &indicator_idv, - vector &indicator_snp, vector &snpInfo, - const double &maf_level, const double &miss_level, - const double &hwe_level, const double &r2_level, - size_t &ns_test); + const gsl_matrix *W, vector &indicator_idv, + vector &indicator_snp, vector &snpInfo, + const double &maf_level, const double &miss_level, + const double &hwe_level, const double &r2_level, + size_t &ns_test); bool ReadFile_sample(const string &file_sample, - vector > &indicator_pheno, - vector > &pheno, - const vector &p_column, - vector &indicator_cvt, - vector > &cvt, - size_t &n_cvt); + vector> &indicator_pheno, + vector> &pheno, + const vector &p_column, vector &indicator_cvt, + vector> &cvt, size_t &n_cvt); #endif - - - - - - - -- cgit v1.2.3