#include #include #include #include #include #include #include #include #include "peddata.h" using namespace std; void kill_IQLS() { fprintf(stderr, "\nExiting IQLS due to error(s) listed above.\n\n"); exit(1); } int check_paramset(ParamSet &ps) { int status = 1; if(strlen(ps.phenofile)>0) { if(!fopen(ps.phenofile, "r")) { fprintf(stderr, "Error: cannot open phenotype data file \"%s\".\n", ps.phenofile); status = -1; } } if(strlen(ps.genofile)>0) { if(!fopen(ps.genofile, "r")) { fprintf(stderr, "Error: cannot open genotype data file \"%s\".\n", ps.genofile); status = -1; } } if(strlen(ps.ibdfile)>0) { if(!fopen(ps.ibdfile, "r")) { fprintf(stderr, "Error: cannot open IBD coefficients file \"%s\".\n", ps.ibdfile); status = -1; } } if(strlen(ps.parameterfile)>0) { if(!fopen(ps.parameterfile, "r")) { fprintf(stderr, "Error: cannot open parameter file \"%s\".\n", ps.parameterfile); status = -1; } } return status; } void invoke_IQLS(ParamSet &ps) { PedData ped; FILE *fp = fopen("IQLStest.out", "w"); if(!fp) { fprintf(stderr, "Error: cannot open output file \"IQLStest.out\" for writing.\n"); kill_IQLS(); } FILE *fpp = fopen("IQLStest.fdf.top", "w"); if(!fpp) { fprintf(stderr, "Error: cannot open significance file \"IQLStest.fdf.top\" for writing.\n"); kill_IQLS(); } FILE *fppp = fopen("IQLStest.1df.top", "w"); if(!fppp) { fprintf(stderr, "Error: cannot open output file \"IQLStest.1df.top\" for writing.\n"); kill_IQLS(); } ped.set_output(fp,fpp,fppp); if(ped.run(ps)<0) kill_IQLS(); fprintf(stderr, "\nIQLS is completed\n\n"); } int main(int argc, char **argv) { ParamSet ps; // input files for(int i=1;i