void readcommands(int argc, char **argv) { int i ; phandle *ph ; int t ; while ((i = getopt (argc, argv, "p:vV")) != -1) { switch (i) { case 'p': parname = strdup(optarg) ; break; case 'v': printf("version: %s\n", WVERSION) ; break; case 'V': verbose = YES ; break; case '?': printf ("Usage: bad params.... \n") ; fatalx("bad params\n") ; } } if (parname==NULL) { fprintf(stderr, "no parameters\n") ; return ; } pcheck(parname,'p') ; printf("parameter file: %s\n", parname) ; ph = openpars(parname) ; dostrsub(ph) ; getstring(ph, "genotypename:", &genotypename) ; getstring(ph, "snpname:", &snpname) ; getstring(ph, "indivname:", &indivname) ; getstring(ph, "poplistname:", &poplistname) ; getstring(ph, "snpeigname:", &snpeigname) ; getstring(ph, "snpweightoutname:", &snpeigname) ; /* changed 09/18/07 */ getstring(ph, "output:", &outputname) ; getstring(ph, "outputvecs:", &outputname) ; getstring(ph, "evecoutname:", &outputname) ; /* changed 11/02/06 */ getstring(ph, "outputvals:", &outputvname) ; getstring(ph, "evaloutname:", &outputvname) ; /* changed 11/02/06 */ getstring(ph, "badsnpname:", &badsnpname) ; getstring(ph, "outliername:", &outliername) ; getstring(ph, "outlieroutname:", &outliername) ; /* changed 11/02/06 */ getstring(ph, "phylipname:", &phylipname) ; getstring(ph, "phylipoutname:", &phylipname) ; /* changed 11/02/06 */ getstring(ph, "weightname:", &weightname) ; getstring(ph, "fstdetailsname:", &fstdetailsname) ; getdbl(ph, "relthresh:", &relthresh) ; getint(ph, "numeigs:", &numeigs) ; getint(ph, "numoutevec:", &numeigs) ; /* changed 11/02/06 */ getint(ph, "markerscore:", &markerscore) ; getint(ph, "chisqmode:", &chisqmode) ; getint(ph, "missingmode:", &missingmode) ; getint(ph, "fancynorm:", &fancynorm) ; getint(ph, "usenorm:", &fancynorm) ; /* changed 11/02/06 */ getint(ph, "dotpopsmode:", &dotpopsmode) ; getint(ph, "pcorrmode:", &pcorrmode) ; /* print correlations */ getint(ph, "pcpopsonly:", &pcpopsonly) ; /* but only within population */ getint(ph, "altnormstyle:", &altnormstyle) ; getint(ph, "hashcheck:", &hashcheck) ; getint(ph, "popgenmode:", &altnormstyle) ; getint(ph, "noxdata:", &noxdata) ; t = -1 ; getint(ph, "xdata:", &t) ; if (t>=0) noxdata = 1-t ; getint(ph, "nostatslim:", &nostatslim) ; getint(ph, "popsizelimit:", &popsizelimit) ; getint(ph, "minallelecnt:", &minallelecnt) ; getint(ph, "chrom:", &xchrom) ; getint(ph, "lopos:", &lopos) ; getint(ph, "hipos:", &hipos) ; getint(ph, "checksizemode:", &checksizemode) ; getint(ph, "pubmean:", &pubmean) ; getint(ph, "fstonly:", &fstonly) ; getint(ph, "fsthiprecision:", &fsthiprec) ; getint(ph, "ldregress:", &ldregress) ; getint(ph, "nsnpldregress:", &ldregress) ; /* changed 11/02/06 */ getdbl(ph, "ldlimit:", &ldlimit) ; /* in morgans */ getdbl(ph, "maxdistldregress:", &ldlimit) ; /* in morgans */ /* changed 11/02/06 */ getint(ph, "minleneig:", &nostatslim) ; getint(ph, "malexhet:", &malexhet) ; getint(ph, "nomalexhet:", &malexhet) ; /* changed 11/02/06 */ getint(ph, "familynames:", &familynames) ; getint(ph, "numoutliter:", &numoutliter) ; getint(ph, "numoutlieriter:", &numoutliter) ; /* changed 11/02/06 */ getint(ph, "numoutleigs", &numoutleigs) ; getint(ph, "numoutlierevec:", &numoutleigs) ; /* changed 11/02/06 */ getdbl(ph, "outlthresh:", &outlthresh) ; getdbl(ph, "outliersigmathresh:", &outlthresh) ; /* changed 11/02/06 */ getdbl(ph, "blgsize:", &blgsize) ; getstring(ph, "indoutfilename:", &indoutfilename) ; getstring(ph, "indivoutname:", &indoutfilename) ; /* changed 11/02/06 */ getstring(ph, "snpoutfilename:", &snpoutfilename) ; getstring(ph, "snpoutname:", &snpoutfilename) ; /* changed 11/02/06 */ getstring(ph, "genooutfilename:", &genooutfilename) ; getstring(ph, "genotypeoutname:", &genooutfilename) ; /* changed 11/02/06 */ getstring(ph, "outputformat:", &omode) ; getstring(ph, "outputmode:", &omode) ; getint(ph, "outputgroup:", &ogmode) ; getint(ph, "packout:", &packout) ; /* now obsolete 11/02/06 */ getstring(ph, "twxtabname:", &twxtabname) ; getdbl(ph, "r2thresh:", &r2thresh) ; getdbl(ph, "r2genlim:", &r2genlim) ; getdbl(ph, "r2physlim:", &r2physlim) ; getint(ph, "killr2:", &killr2) ; getint(ph, "numchrom:", &numchrom) ; printf("### THE INPUT PARAMETERS\n"); printf("##PARAMETER NAME: VALUE\n"); writepars(ph); }
void readcommands(int argc, char **argv) { int i,haploid=0; phandle *ph ; char str[5000] ; char *tempname ; int n, t ; while ((i = getopt (argc, argv, "f:b:p:g:s:o:vVx")) != -1) { switch (i) { case 'p': parname = strdup(optarg) ; break; case 'f': snpdetailsname = strdup(optarg) ; break; case 'g': graphname = strdup(optarg) ; break; case 'o': graphoutname = strdup(optarg) ; break; case 's': seed = atoi(optarg) ; break; case 'b': baseval = atof(optarg) ; break; case 'v': printf("version: %s\n", WVERSION) ; break; case 'x': doanalysis = NO ; break; case 'V': verbose = YES ; break; case '?': printf ("Usage: bad params.... \n") ; fatalx("bad params\n") ; } } if (parname==NULL) { fprintf(stderr, "no parameters\n") ; return ; } pcheck(parname,'p') ; printf("parameter file: %s\n", parname) ; ph = openpars(parname) ; dostrsub(ph) ; getstring(ph, "genotypename:", &genotypename) ; getstring(ph, "snpname:", &snpname) ; getstring(ph, "indivname:", &indivname) ; getstring(ph, "graphname:", &graphname) ; getstring(ph, "graphoutname:", &graphoutname) ; int numeg = 4 ; getstring(ph, "snpdetailsname:", &snpdetailsname) ; getstring(ph, "outpop:", &outpop) ; getstring(ph, "output:", &outputname) ; getstring(ph, "badsnpname:", &badsnpname) ; getstring(ph, "popfilename:", &popfilename) ; getstring(ph, "f3log:", &f3name) ; getstring(ph, "root:", &rootname) ; getdbl(ph, "blgsize:", &blgsize) ; getdbl(ph, "diag:", &diag) ; getdbl(ph, "f2diag:", &f2diag) ; getdbl(ph, "minvar:", &minvar) ; getint(ph, "bigiter:", &bigiter) ; getint(ph, "inbreed:", &inbreed) ; getint(ph, "startiter:", &startiter) ; getint(ph, "fancynorm:", &fancynorm) ; getint(ph, "noxdata:", &noxdata) ; t = -1 ; getint(ph, "xdata:", &t) ; if (t>=0) noxdata = 1-t ; getint(ph, "chrom:", &xchrom) ; getint(ph, "nochrom:", &zchrom) ; getint(ph, "doanalysis:", &doanalysis) ; getint(ph, "quartet:", &quartet) ; getint(ph, "nostatslim:", &nostatslim) ; getint(ph, "popsizelimit:", &popsizelimit) ; getint(ph, "gfromp:", &gfromp) ; // gen dis from phys getint(ph, "seed:", &seed) ; getint(ph, "details:", &details) ; getint(ph, "forcezmode:", &forcezmode) ; getint(ph, "dzeromode:", &dzeromode) ; getdbl(ph, "baseval:", &baseval) ; getdbl(ph, "jackquart:", &jackquart) ; getint(ph, "jackweight:", &jackweight) ; getint(ph, "pubjack:", &pubjack) ; getstring(ph, "dumpname:", &dumpname) ; getstring(ph, "loadname:", &loadname) ; printf("### THE INPUT PARAMETERS\n"); printf("##PARAMETER NAME: VALUE\n"); writepars(ph); }
void readcommands (int argc, char **argv) { int i; char *parname = NULL; phandle *ph; while ((i = getopt (argc, argv, "i:o:p:n:m:t:V")) != -1) { switch (i) { case 'i': iname = strdup (optarg); break; case 'o': oname = strdup (optarg); break; case 't': twxtab = strdup (optarg); break; case 'n': nval = atof (optarg); break; case 'm': minleneig = atoi (optarg); break; case 'p': parname = strdup (optarg); break; case 'V': verbose = YES; break; case '?': printf ("Usage: bad params.... \n"); fatalx ("bad params\n"); } } if (parname == NULL) return; printf ("parameter file: %s\n", parname); ph = openpars (parname); getstring (ph, "input:", &iname); getstring (ph, "output:", &oname); getdbl (ph, "nval:", &nval); getint (ph, "minleneig:", &minleneig); writepars (ph); closepars (ph); }
gaint gaexpr (char *expr, struct gastat *pst) { struct gagrid *pgr; struct gastn *stn; struct smem *stack; char *ptr, *pos; gadouble val; gaint cmdlen,i,j,rc,curr; gaint state,cont,err; gaint size; if (gaqsig()) return(1); pass++; cmdlen = strlen(expr); /* size = cmdlen * ( 7 + sizeof(struct smem) ); */ size = sizeof(struct smem[cmdlen+10]); stack = (struct smem *)malloc(size); if (stack==NULL) { gaprnt (0,"Memory Allocation Error: parser stack\n"); return (1); } state=1; curr = -1; pos = expr; cont=1; err=0; while (cont) { /* Loop while parsing exprssn */ if (state) { /* Expect operand or '(' */ if (*pos=='(') { /* Handle left paren */ curr++; stack[curr].type = 2; pos++; } else if (*pos=='-') { /* Handle unary '-' operator */ curr++; stack[curr].type = -1; stack[curr].obj.pgr = gagrvl(-1.0); curr++; stack[curr].type=1; stack[curr].obj.op = 0; pos++; } else if (*pos>='0' && *pos<='9') { /* Handle numeric value */ if ((ptr=getdbl(pos,&val))==NULL) { cont=0; err=1; i = 1 + pos - expr; gaprnt (0,"Syntax Error: Invalid numeric value\n"); } else { curr++; stack[curr].type = -1; stack[curr].obj.pgr = gagrvl(val); /* stkdmp(stack,curr); */ rc = eval(0, stack, &curr); if (rc) { err=1; cont=0; } state = 0; pos=ptr; } } else if (*pos>='a' && *pos<='z') { /* Handle variable */ if ((ptr=varprs(pos, pst))==NULL) { cont=0; err=1; } else { curr++; if (pst->type) { stack[curr].type = -1; stack[curr].obj.pgr = pst->result.pgr; } else { stack[curr].type = -2; stack[curr].obj.stn = pst->result.stn; } /* stkdmp(stack,curr); */ rc = eval(0, stack, &curr); if (rc) { err=1; cont=0; } state = 0; pos=ptr; } } else { cont=0; err=1; gaprnt (0,"Syntax Error: Expected operand or '('\n"); } } else { /* Expect operator or ')' */ if (*pos==')') { /* Handle right paren */ curr++; stack[curr].type = 3; pos++; rc = eval(0, stack, &curr); /* Process stack */ if (rc) { err=1; cont=0; pos--; } } /* Handle operator */ else if ( (*pos=='*')||(*pos=='/')||(*pos=='+')||(*pos=='-') ) { curr++; stack[curr].type=1; if (*pos=='*') stack[curr].obj.op=0; if (*pos=='/') stack[curr].obj.op=1; if (*pos=='+') stack[curr].obj.op=2; if (*pos=='-') { stack[curr].obj.op=2; curr++; stack[curr].type = -1; stack[curr].obj.pgr = gagrvl(-1.0); curr++; stack[curr].type=1; stack[curr].obj.op = 0; } /* stkdmp(stack,curr); */ pos++; state=1; } else { gaprnt (0,"Syntax Error: Expected operator or ')'\n"); cont=0; err=1; } } if (*pos=='\0'||*pos=='\n') cont=0; } if (!err) { rc = eval(1, stack, &curr); /* stkdmp(stack,curr); */ if (rc) { err=1; } else { if (curr==0) { if (stack[0].type == -1) { pst->type = 1; pst->result.pgr = stack[0].obj.pgr; } else if (stack[0].type == -2) { pst->type = 0; pst->result.stn = stack[0].obj.stn; } else { gaprnt (0,"GAEXPR Logic Error Number 29\n"); err=1; } } else { gaprnt (0,"Syntax Error: Unmatched Parens\n"); err=1; } } } if (err) { if (pass==1) { i = 1 + pos - expr; sprintf (pout," Error ocurred at column %i\n",i); gaprnt (0,pout); } /* release any memory still hung off the stack */ for (i=0; i<curr; i++) { if (stack[i].type==-1) { pgr = stack[i].obj.pgr; gagfre(pgr); } else if (stack[i].type==-2) { stn = stack[i].obj.stn; for (j=0; j<BLKNUM; j++) { if (stn->blks[j] != NULL) free(stn->blks[j]); } free(stn); } } } free(stack); pass--; return (err); }
void readcommands(int argc, char **argv) { int i,haploid=0; char *parname = NULL ; phandle *ph ; char str[5000] ; char *tempname ; int n ; while ((i = getopt (argc, argv, "p:vV")) != -1) { switch (i) { case 'p': parname = strdup(optarg) ; break; case 'v': printf("version: %s\n", WVERSION) ; break; case 'V': verbose = YES ; break; case '?': printf ("Usage: bad params.... \n") ; fatalx("bad params\n") ; } } pcheck(parname,'p') ; printf("parameter file: %s\n", parname) ; ph = openpars(parname) ; dostrsub(ph) ; /** DIR2: /fg/nfiles/admixdata/ms2 SSSS: DIR2/outfiles genotypename: DIR2/autos_ccshad_fakes eglistname: DIR2/eurlist output: eurout */ getstring(ph, "genotypename:", &genotypename) ; getstring(ph, "genotypelist:", &genotypelist) ; getstring(ph, "snpname:", &snpname) ; getstring(ph, "indivname:", &indivname) ; getstring(ph, "badsnpname:", &badsnpname) ; getstring(ph, "flipsnpname:", &flipsnpname) ; getstring(ph, "flipstrandname:", &flipstrandname) ; getstring(ph, "indoutfilename:", &indoutfilename) ; getstring(ph, "indivoutname:", &indoutfilename) ; /* changed 11/02/06 */ getstring(ph, "snpoutfilename:", &snpoutfilename) ; getstring(ph, "snpoutname:", &snpoutfilename) ; /* changed 11/02/06 */ getstring(ph, "genooutfilename:", &genooutfilename) ; getstring(ph, "genotypeoutname:", &genooutfilename) ; /* changed 11/02/06 */ getstring(ph, "outputformat:", &omode) ; getstring(ph, "outputmode:", &omode) ; getstring(ph, "polarize:", &polarid) ; getint(ph, "zerodistance:", &zerodistance) ; getint(ph, "checksizemode:", &checksizemode) ; getint(ph, "badpedignore:", &badpedignore) ; getint(ph, "numchrom:", &numchrom) ; getstring(ph, "xregionname:", &xregionname) ; getdbl(ph, "hwfilter:", &nhwfilter) ; getstring(ph, "deletesnpoutname:", &deletesnpoutname); getint(ph, "outputgroup:", &ogmode) ; getint(ph, "malexhet:", &malexhet) ; getint(ph, "nomalexhet:", &malexhet) ; /* changed 11/02/06 */ getint(ph, "tersemode:", &tersem) ; getint(ph, "familynames:", &familynames) ; getint(ph, "packout:", &packout) ; /* now obsolete 11/02/06 */ getint(ph, "decimate:", &decim) ; getint(ph, "dmindis:", &dmindis) ; getint(ph, "dmaxdis:", &dmaxdis) ; getint(ph, "fastdup:", &fastdup) ; getint(ph, "flipreference:", &flipreference) ; getint(ph, "fastdupnum:", &fastdupnum) ; getdbl(ph, "fastdupthresh:", &fastdupthresh) ; getdbl(ph, "fastdupkill:", &fastdupkill) ; getint(ph, "killr2:", &killr2) ; getint(ph, "hashcheck:", &hashcheck) ; getint(ph, "outputall:", &outputall) ; getint(ph, "sevencolumnped:", &sevencolumnped) ; getint(ph, "phasedmode:", &phasedmode) ; getdbl(ph, "r2thresh:", &r2thresh) ; getdbl(ph, "r2genlim:", &r2genlim) ; getdbl(ph, "r2physlim:", &r2physlim) ; getint(ph, "chrom:", &xchrom) ; getint(ph, "lopos:", &lopos) ; getint(ph, "hipos:", &hipos) ; getint(ph, "minchrom:", &minchrom) ; getint(ph, "maxchrom:", &maxchrom) ; getdbl(ph, "maxmissfrac:", &maxmissfrac) ; getint(ph, "maxmissing:", &maxmiss) ; getstring(ph, "poplistname:", &poplistname) ; getstring(ph, "newsnpname:", &newsnpname) ; getstring(ph, "newindivname:", &newindivname) ; getint(ph, "deletedup:", &deletedup) ; getint(ph, "mkdiploid:", &mkdiploid) ; writepars(ph) ; closepars(ph) ; }