/* This file contains the highest level source code for DHS mapping software */ #include #include #include #include #include #include #include "includes.h" #include "unistd.h" #include "grid.h" #include "vector.h" #include "declare.h" #include "time.h" ofstream errorfs; int main(int argc, char** argv) { if (argc != 3) { cerr << "Usage: readinput datafile pedfile\n"; exit(1); } char* datafile = argv[1]; char* pedfile = argv[2]; int debug = 0; errorfs.open("dhsmap_errors"); if (!errorfs.is_open()) { cout << "ERROR: Unable to open dhsmap_errors for reading\n"; exit(1); } int i,j; //declarations needed for readinput int program_code, data_type, num_loci, numblanks, num_markers; ivector markers; int map_type, map_size; dvector map; int num_indiv, num_total_affecteds; ivector indiv_list; int hap_or_freq, mkvorder, bayes, num_total_control, num_control; ivector control_list, num_alleles; ivectors allele_list; dvectors allele_freq; dvector mut_rates; int est_p; double p, max_res; int map_res, max_cand, anc_hap_known, num_anc_hap_known, C_loc, C_all, E_int, L_End, R_End; ivectors anc_hap; double fixed_thresh, var_thresh; pedvector peds; //char ancout[100]; char maxout[100]; char oneout[100]; simpstrg resout, ancout, maxout, oneout; //read input readinput(datafile, pedfile, 0, program_code, data_type, num_loci, numblanks, num_markers, markers, map_type, map_size, map, num_total_affecteds,num_indiv, indiv_list, hap_or_freq, mkvorder, bayes, num_total_control, num_control, control_list, num_alleles, allele_list, allele_freq, mut_rates, est_p, p, max_res, map_res, max_cand, anc_hap_known, num_anc_hap_known, anc_hap, C_loc, C_all, E_int, resout,ancout,maxout,oneout, L_End, R_End, fixed_thresh, var_thresh, peds); //check that inputted C_all matches anc_hap for pc==3 if (program_code==3) { if (C_all != anc_hap[0](C_loc) ) { errorfs << "ERROR: Entered allele at center (" << C_all << ") \n does not match allele in ancestral haplotype (" << anc_hap[0](C_loc) << ") \n"; exit(1); } } //initialize anc_hap if (program_code==2) { anc_hap.init(1); anc_hap[0].init(num_markers); } //markers, indiv_list, control_list given as counting from 1; //change to counting from 0 for (i=0;i> h2_freq_lists " << endl; //for (i=0;i> h2_freq_lists[i][j]; //adjust in case alleles/haplotypes do not appear in controls //const double e=0.01; //how small we allow minimum freq. to be //make_adj_to_hfreqlists(h2_freq_lists_adj, h2_freq_lists, allele_list, // e, additionalalleles,hap_or_freq,controls,debug); //make other freq. objects for use in onehap,onegen makejf2(jointfreq2,h2_freq_lists, 0); makefa(freqallele,allele_list, 0); makeff(freqfreq, freqallele, allele_list, jointfreq2, 0); //delete me //double loglik=0; //for (i=0;i> h3_freq_lists " << endl; //for (i=0;i> h3_freq_lists[i][j]; makejf3fromh3fl(jointfreq3mkv2,h3_freq_lists,0); makejf3f(jointfreq3fmkv2, jointfreq3mkv2, allele_list,0); makejf2fromjf3(jointfreq2,jointfreq3mkv2,allele_list,0); makefa(freqallele,allele_list, 0); makeff(freqfreq, freqallele, allele_list, jointfreq2, 0); } } } else {//(hap_or_freq==3); allele frequencies reported //give counts of alleles in order makeallelecountsff(allelecountsff, num_markers, markers, num_alleles, hap_or_freq, debug); //check if there are alleles in data that do not appear in list //of control freqs countadditionalalleles(additionalalleles, allele_list,data,debug); for (j=0;j0) { errorfs << "ERROR: allele found in data not found in reported list" << endl; exit(1); } makeindfreq(freqallele, freqfreq, num_markers, markers, num_alleles, allele_list, allele_freq, hap_or_freq,debug); makeindjointfreq2(jointfreq2, allelecountsff, freqfreq, num_markers, 0); makeindjointfreq3(jointfreq3mkv2, allelecountsff, freqfreq, num_markers, 0); makejf3f(jointfreq3fmkv2, jointfreq3mkv2, allele_list,0); //if estimating tau at marker, make jointfreq2C,jointfreq3 //if (program_code==2 || program_code==3) { //makejointfreq2C(jointfreq2C, allelecountsff, freqfreq, C_loc, debug); //if (0ll[0][maxlik]) maxlik=j; //find how many locations share maximum likelihood int num_maxlik=0; for (j=0;j