command() { double tval; int i,echeck; int pmin,pmax,pstep; while (echeck = getstring(": ")) { if (echeck == EOF) { fileinput(EOF); } else if (in[0] == '\0') { errprint(""); } else if (startsame(in,"cycle")) { cycle(); } else if (startsame(in,"clear")) { clear(); } else if (startsame(in,"coarticulation")) { getint(&coartflag); } else if (startsame(in,"rc")) { zarrays(); cycle(); } else if (startsame(in,"wordacts")) { scr_words(printmin,printmax,3,0,"MAX"); } else if (startsame(in,"wtacts")) { scr_words(printmin,printmax,3,0,"ALL"); } else if (startsame(in,"owtacts")) { getstring("word: "); scr_words(printmin,printmax,3,0,in); } else if (startsame(in,"phonacts")) { scr_phonemes(printmin,printmax,3,0); } else if (startsame(in,"featacts")) { scr_features(); } else if (startsame(in,"sfeatacts")) { getstring("fname: "); sfeatacts(in); } else if (startsame(in,"memo")) { getstring("string: "); strcpy(memo,in); } else if (startsame(in,"expr")) { setex(); } else if (startsame(in,"fcopt")) { getint(&fcflag); } else if (startsame(in,"fpcyc")) { getint(&fpcyc); } else if (startsame(in,"finput")) { fileinput(NONSTD); } else if (startsame(in,"inoise")) { getval(&inoise); } else if (startsame(in,"inspecs")) { getstring("File name (- = stdin): "); inspecs(in); } else if (startsame(in,"infeatures")) { getstring("File name: "); infeats(in); } /* NOT PRESENTLY OPERATIVE -- JLM 10-5-82 else if (startsame(in,"wsubset")) { wordsubset(); } */ else if (startsame(in,"test")) { getstring("test string: "); strcpy(memo,in); test(in); } else if (startsame(in,"topdown")) { topdown(); } else if (startsame(in,"output")) { setout(); } else if (startsame(in,"ofile")) { getstring("give filename (or - for none): "); setoutfile(in); } else if (in[0] == '?') { help(); } else if (startsame(in,"help")) { help(); } else if (startsame(in,"lexicon")) { getlex(); } else if (startsame(in,"params")) { getpars(); } else if (startsame(in,"quit")) { quit(); } else if (startsame(in,"decay")) { getdouble(decay,NLEVS,levlabs); } else if (startsame(in,"alpha")) { getdouble(alpha,NPARAMS,conlabs); } else if (startsame(in,"gamma")) { getdouble(ga,NLEVS,levlabs); } else if (startsame(in,"grace")) { getint(&grace); } else if (startsame(in,"rest")) { tval = rest[W]; getdouble(rest,NLEVS,levlabs); if (tval != rest[W]) { initialize(); } } else if (startsame(in,"fweight")) { getdouble(fweight,NCONTINS,contname); } else if (startsame(in,"pthresh")) { getdouble(pthresh,NLEVS,levlabs); } else if (startsame(in,"ngraph")) { newgraph(pmin,ng_max,pstep); } else if (startsame(in,"ngmax")) { getint(&ng_max); } else if (startsame(in,"ngwscale")) { getval(&ng_wscale); } else if (startsame(in,"ngsscale")) { getval(&ng_sscale); } else if (startsame(in,"ngpscale")) { getval(&ng_pscale); } else if (startsame(in,"nreps")) { getint(&nreps); } else if (startsame(in,"pfreq")) { getint(&printfreq); } else if (startsame(in,"rarate")) { getval(&rarate); } else if (startsame(in,"sumpr")) { scr_sum(pmin,pmax,pstep); } else if (startsame(in,"sinspec")) { sinspec(); } else if (startsame(in,"sfeatures")) { getstring("Filename: "); sfeatures(in); } else if (startsame(in,"dinspec")) { dinspec(); } else if (startsame(in,"sumopt")) { getint(&sumflag); } else if (startsame(in,"pmin")) { getint(&pmin); } else if (startsame(in,"pmax")) { getint(&pmax); } else if (startsame(in,"pstep")) { getint(&pstep); } else if (startsame(in,"min")) { getval(&min); } else if (startsame(in,"max")) { getval(&max); } else if (startsame(in,"windowcent")) { getval(&windowcent); } else if (startsame(in,"wbase")) { getval(&wbase); } else if (startsame(in,"wgraph")) { wgraph(pmin,ng_max,pstep); } else if (startsame(in,"wchange")) { getval(&wchange); } else if (startsame(in,"wgain")) { getval(&wgain); } else if (startsame(in,"wramp")) { getval(&wramp); } else if (startsame(in,"imax")) { getval(&imax); } else if (startsame(in,"sscale")) { getval(&sscale); } else if (startsame(in,"nsscale")) { getval(&nsscale); } else if (startsame(in,"freqscale")) { tval = fscale; getval(&fscale); if (tval != fscale) { initialize(); } } else if (startsame(in,"abort")) { abort(); /* to get a core dump for sdb */ } else { errprint("Unrecognized request: For help type ?."); if (infp != stdin) fileinput(STD); } wait(0); } }
void default1D(struct data *d) { struct file fref; struct data ref; struct datablockhead *dbh; int /*dim1,dim2,*/dim3,nr; int i,j; int wref=FALSE; #ifdef DEBUG char function[20]; strcpy(function,"default1D"); /* Set function name */ #endif /* Open data and phasefile file pointers for writing */ openfpw(d,DATA_FILE); openfpw(d,PHAS_FILE); /* Write data and phasefile file headers */ wdfh(d,DATA_FILE); wdfh(d,PHAS_FILE); /* Set data dimensions */ //dim1=d->np/2; //dim2=1; dim3=d->fh.ntraces; nr=d->nr; /* Set nuber of "volumes" */ d->nvols=d->fh.nblocks/nr; /* Check if there is a water reference */ if (spar(d,"ws","y") && spar(d,"wref","y") && spar(d,"wrefstatus","ws")) wref=TRUE; /* Prepare water reference */ if (wref) { setreffile(&fref,d,"waterref"); /* Set reference file */ getpars(fref.procpar[0],&ref); /* Get pars from reference procpar */ opendata(fref.fid[0],&ref); /* Open reference data file fid */ getvol1D(&ref,0,NDCC); /* Get volume without applying dbh.lvl and dbh.tlt */ weightdata1D(&ref,STD,D1); /* Weight data using standard VnmrJ parameters */ } /* Allocate memory for blocks headers from all receivers */ if ((dbh = malloc(nr*sizeof(d->bh))) == NULL) nomem(); /* For spectra we anticipate there is easily sufficient memory for data from all receiver blocks */ for (d->vol=0;d->vol<d->nvols;d->vol++) { /* loop over "volumes" */ for (i=0;i<nr;i++) { /* loop over receivers */ getdbh(d,nr*d->vol+i); /* Get block header */ copydbh(&d->bh,&dbh[i]); /* Store the block headers for writing */ } getvol1D(d,d->vol,NDCC); /* Get data block without applying dbh.lvl and dbh.tlt */ weightdata1D(d,STD,D1); /* Weight data using standard VnmrJ parameters */ if (wref) refcorr1D(d,&ref); /* Phase correct using the reference */ else combine1D(d); /* Combine data from multiple receivers */ zerofill1D(d,STD,D1); /* Zero fill data using standard VnmrJ parameters */ fft1D(d,D1); /* 1D fft */ shiftdata1D(d,STD,D1); /* Shift data to get spectra */ for (i=0;i<nr;i++) { /* loop over receivers */ copydbh(&dbh[i],&d->bh); /* Copy block header for writing */ for (j=0;j<dim3;j++) { d->bh.index=d->vol*nr*dim3+i*dim3+j; /* Set block index */ wdbh(d,DATA_FILE); /* Write block header */ wdbh(d,PHAS_FILE); /* Write block header */ w1Dtrace(d,i,j,DATA_FILE); /* Write block */ w1Dtrace(d,i,j,PHAS_FILE); /* Write block */ } } clear1Ddata(d); /* Clear data "volume" from memory */ } clear1Dall(d); /* Clear everything from memory */ closefp(d,DATA_FILE); closefp(d,PHAS_FILE); }
void main() { int i, j, k, trialnr; /* input pars */ getpars(); /* input training set and test set */ getsets(); if (maxtrials>20) maxtrials=20; if (bias1==1) in_mod++; if (bias2==1) hid_mod++; hi_in_mod = in_mod+hid_mod; cell_mod=hi_in_mod; for (i=0;i<num_blocks;i++) cell_mod+=(2+block_size[i]); ges_mod = cell_mod+out_mod; if (ges_mod>max_units) { printf("Program terminated!\n"); printf("You have to set the constant max_units at begin\n"); printf("of the program file greater or equal %d and then\n",ges_mod); printf("compile the program again.\n"); exit(0); } srand(ran_sta); for (trialnr=0;trialnr<maxtrials;trialnr++) { outfile = outf[trialnr]; weightfile = weig[trialnr]; fp1 = fopen(outfile, "w"); fprintf(fp1,"Trial Nr.:%.1d\n",trialnr); fclose(fp1); fp2 = fopen(weightfile, "w"); fprintf(fp2,"Trial Nr.:%.1d\n",trialnr); fclose(fp2); initia(); examples=0; epoch=0; maxepoch=maxepoch_init; stop_learn=0; learn = 1; while (learn == 1) { /* executing the environment and setting the input */ execute_act(); /* forward pass */ forward_pass(); if (targ==1) /* only if target for this input */ { /* compute error */ for (k=cell_mod,j=0;k<ges_mod;k++,j++) { error[j]= target_a[j] - Yk_mod_new[k]; }; /* Training error */ comp_err(); } /* backward pass */ if (targ==1) /* only if target for this input */ { backward_pass(); } else { derivatives(); } /* set old activations */ for (i=0;i<ges_mod;i++) { Yk_mod_old[i] = Yk_mod_new[i]; } /* update weights */ if (weight_up==1) { weight_up=0; weight_update(); } /* stop if maxepoch reached */ if (epoch>maxepoch) learn=0; } weight_out(); test(); } exit(0); }
void defaultEPI(struct data *d) { int DISCARD=-1; int refEPI=FALSE,refSGE=FALSE; int getscaleref=FALSE; double oversample,lro,lpe; struct data ref1,ref2,ref3,ref4,ref5,ref6; struct segscale scale1,scale2; enum { OFF = 0, POINTWISE = 1, TRIPLE = 2, SCALED_TRIPLE = 3 } epi_pc; #ifdef DEBUG char function[20]; strcpy(function,"defaultEPI"); /* Set function name */ #endif /* Set EPI correction scheme */ if (spar(d,"epi_pc","POINTWISE")) epi_pc=POINTWISE; else if (spar(d,"epi_pc","TRIPLE")) epi_pc=TRIPLE; else if (spar(d,"epi_pc","SCALED_TRIPLE")) epi_pc=SCALED_TRIPLE; else epi_pc=OFF; /* Check whether to output or discard reference scans */ if (spar(d,"imRF","y")) refEPI=TRUE; if (spar(d,"imSGE","y")) refSGE=TRUE; /* Set reference data */ if (epi_pc > OFF) { /* Pointwise or triple reference phase correction */ getpars(d->procpar,&ref1); initdata(&ref1); getpars(d->procpar,&ref3); /* ref3 used in pointwise phase correction of inverted */ initdata(&ref3); /* reference scans if reference output is selected */ } if (epi_pc > POINTWISE) { /* Triple reference phase corrections */ getpars(d->procpar,&ref2); initdata(&ref2); getpars(d->procpar,&ref4); initdata(&ref4); } if (epi_pc > TRIPLE) { /* Scaled triple reference phase correction */ getpars(d->procpar,&ref5); initdata(&ref5); getpars(d->procpar,&ref6); initdata(&ref6); } d->nv=(int)*val("nphase",&d->p); /* Set d->nv for dimorder2D */ d->pssorder=sliceorder(d,d->ns,"pss"); /* Fill pssorder with the slice order */ d->dim2order=phaseorder(d,d->nv,"par_does_not_exist"); /* Set dim2order=-1 for sequential phase encode order */ d->dim3order=phaseorder(d,d->nv,"sgepelist"); /* Fill dim3order with the standard gradient echo phase encode order */ d->nv2=d->nv; /* Set d->nv2 for dim3order */ d->dimorder=IM2D; /* Set dimorder flag */ d->nv=(int)*val("nseg",&d->p); /* Use d->nv for the number of shots */ setnvolsEPI(d); /* Set the number of data volumes */ /* Allow for scaled FOV in ASL test setup expt */ lro=*val("lro",&d->p)**val("aslfov",&d->p); lpe=*val("lpe",&d->p)**val("aslfov",&d->p); /* Set default of no compressed segment scaling just in case it's never set */ scale1.data=FALSE; scale2.data=FALSE; /* Loop over data blocks */ for (d->block=0;d->block<d->nblocks;d->block++) { d->outvol=0; /* Initialise output data volume (that will not include reference scans) */ for (d->vol=0;d->vol<d->nvols;d->vol++) { /* Loop over "volumes" */ setoutvolEPI(d); /* Set output data volume */ if (d->outvol>d->endvol) break; /* Break if last requested volume has been processed */ getblockEPI(d,d->vol,NDCC); /* Get block without applying dbh.lvl and dbh.tlt */ zeromax(d); /* Zero max structure & coordinates of maximum */ zeronoise(d); /* Zero values in noise structure */ #ifdef DEBUG fprintf(stdout,"\n%s: %s()\n",SOURCEFILE,function); switch (epi_pc) { case OFF: fprintf(stdout," Correction: OFF \n"); break; case POINTWISE: fprintf(stdout," Correction: POINTWISE \n"); break; case TRIPLE: fprintf(stdout," Correction: TRIPLE \n"); break; case SCALED_TRIPLE: fprintf(stdout," Correction: SCALED_TRIPLE \n"); break; } fflush(stdout); #endif /* Process data as directed by image parameter */ switch ((int)getelem(d,"image",d->vol)) { case 0: /* Reference, no phase-encode */ setblockEPI(d); /* Set block for 2D data (d->nv > 1) and navigators */ if (refEPI) w2Dfdfs(d,VJ,FLT32,d->vol); /* Output raw data for the volume, if requested */ if (epi_pc > OFF) { /* If there is phase correction */ ftnpEPI(d); /* FT along readout dimension */ clear2Ddata(&ref1); /* Clear ref1 */ copy2Ddata(d,&ref1); /* Copy to ref1 */ ref1.datamode=EPIREF; /* Flag as EPIREF data */ } else { /* else there is no phase correction */ ref1.datamode=NONE; /* Flag as no data */ if (refEPI) ftnpEPI(d); /* FT along readout dimension */ } setsegscale(d,&scale1); /* Set scaling for compressed segments */ segscale(d,&scale1); /* Scale compressed segments */ if (refEPI) /* If reference output is requested */ w2Dfdfs(d,VJ,FLT32,d->vol); /* Output data for the volume */ else w2Dfdfs(d,VJ,FLT32,DISCARD); /* Else use DISCARD to flag skip the volume */ wnifti(d,VJ,FLT32,DISCARD); break; case -1: /* Inverted Readout Reference, with phase-encode */ #ifdef DEBUG fprintf(stdout," Processing reference -1 data ...\n"); fflush(stdout); #endif setblockEPI(d); /* Set block for 2D data (d->nv > 1) and navigators */ if (refEPI) w2Dfdfs(d,VJ,FLT32,d->vol); /* Output raw data for the volume, if requested */ ftnpEPI(d); /* FT along readout dimension */ segscale(d,&scale2); /* Scale compressed segments */ if (epi_pc > POINTWISE) { /* if triple or scaled triple reference phase correction */ clear2Ddata(&ref2); /* Clear ref2 */ copy2Ddata(d,&ref2); /* Copy to ref2 */ ref2.datamode=EPIREF; /* Flag ref2 as EPIREF data */ if (ref3.datamode == EPIREF) { /* if there is ref3 reference data */ phaseEPIref(&ref2,&ref3,&ref4); /* Phase correct ref2 data using ref3 and put result in ref4 */ /* analyseEPInav(&ref4); // Analyse the navigators */ stripEPInav(&ref4); /* Strip the navigator scans */ ftnvEPI(&ref4); /* FT along phase encode dimension */ revreadEPI(&ref4); /* Reverse the data in readout dimension */ getscaleref=TRUE; /* Flag to store the next regular image for scaling in SCALED_TRIPLE */ } } if (refEPI) { /* if reference output is requested */ if (ref3.datamode == EPIREF) { /* if there is ref3 reference data */ phaseEPI(d,&ref3); /* Phase correct with the reference */ } navcorrEPI(d); /* Phase correct with the navigator */ stripEPInav(d); /* Strip the navigator scans */ ftnvEPI(d); /* FT along phase encode dimension */ revreadEPI(d); /* Reverse the data in readout dimension */ w2Dfdfs(d,VJ,FLT32,d->vol); /* Output data for the volume */ } else w2Dfdfs(d,VJ,FLT32,DISCARD); /* Use DISCARD to flag skip the volume */ wnifti(d,VJ,FLT32,DISCARD); break; case -2: /* Inverted Readout Reference, no phase-encode */ #ifdef DEBUG fprintf(stdout," Processing reference -2 data ...\n"); fflush(stdout); #endif setblockEPI(d); /* Set block for 2D data (d->nv > 1) and navigators */ if (refEPI) w2Dfdfs(d,VJ,FLT32,d->vol); ftnpEPI(d); /* FT along readout dimension */ setsegscale(d,&scale2); /* Set scaling for compressed segments */ segscale(d,&scale2); /* Scale compressed segments */ if (epi_pc > POINTWISE) { /* if old triple or triple reference phase correction */ clear2Ddata(&ref3); /* Clear ref3 */ copy2Ddata(d,&ref3); /* Copy to ref3 */ ref3.datamode=EPIREF; /* Flag ref3 as EPIREF data */ if (ref2.datamode == EPIREF) { /* if there is ref2 reference data */ phaseEPIref(&ref2,&ref3,&ref4); /* Phase correct ref2 data using ref3 and put result in ref4 */ /* analyseEPInav(&ref4); // Analyse the navigators */ stripEPInav(&ref4); /* Strip the navigator scans */ ftnvEPI(&ref4); /* FT along phase encode dimension */ revreadEPI(&ref4); /* Reverse the data in readout dimension */ getscaleref=TRUE; /* Flag to store the next regular image for scaling in SCALED_TRIPLE */ } } if (refEPI) { /* if reference output is requested */ if (epi_pc == POINTWISE) { /* if pointwise reference phase correction */ clear2Ddata(&ref3); /* Clear ref3 */ copy2Ddata(d,&ref3); /* Copy to ref3 */ ref3.datamode=EPIREF; /* Flag ref3 as EPIREF data */ } revreadEPI(d); /* Reverse the data in readout dimension */ w2Dfdfs(d,VJ,FLT32,d->vol); /* Output data for the volume */ } else w2Dfdfs(d,VJ,FLT32,DISCARD); /* Use DISCARD to flag skip the volume */ wnifti(d,VJ,FLT32,DISCARD); break; case 1: /* Regular image */ #ifdef DEBUG fprintf(stdout," Processing image 1 data ...\n"); fflush(stdout); #endif setblockEPI(d); /* Set block for 2D data (d->nv > 1) and navigators */ if (d->outvol>=d->startvol) w2Dfdfs(d,VJ,FLT32,d->vol); /* Output raw data for the volume, if requested */ switch (epi_pc) { case SCALED_TRIPLE: /* Scaled triple reference phase correction */ if (getscaleref) { /* If the scale reference has just been acquired */ clear2Ddata(&ref5); /* Clear ref5 */ copy2Ddata(d,&ref5); /* Copy to ref5 */ ref5.datamode=EPIREF; /* Flag ref5 as EPIREF data */ prepEPIref(&ref5,&ref1); /* Prepare ref5 data so it can be used to scale ref4 data */ } break; default: break; } ftnpEPI(d); /* FT along readout dimension */ segscale(d,&scale1); /* Scale compressed segments */ phaseEPI(d,&ref1); /* Phase correct with the reference */ navcorrEPI(d); /* Phase correct with the navigator */ /* analyseEPInav(d); // Analyse the navigators */ stripEPInav(d); /* Strip the navigator scans */ ftnvEPI(d); /* FT along phase encode dimension */ switch (epi_pc) { case TRIPLE: /* Triple reference phase correction */ addEPIref(d,&ref4); /* Add ref4 data to cancel N/2 ghost */ break; case SCALED_TRIPLE: /* Scaled triple reference phase correction */ if (getscaleref) { /* If the scale reference has just been acquired */ addEPIref(d,&ref4); /* Add ref4 data to cancel N/2 ghost */ getscaleref=FALSE; /* Flag that scale reference has been acquired */ } else { addscaledEPIref(d,&ref4,&ref5); /* Scale ref4 data according to d/ref5, then add to d */ } break; default: break; } if (d->outvol>=d->startvol) { phasedata2D(d,VJ); /* Phase data if required */ w2Dfdfs(d,VJ,FLT32,d->vol); /* Write 2D fdf data from volume */ wnifti(d,VJ,FLT32,d->vol); } break; default: /* Reference Standard Gradient Echo */ setblockSGE(d); setval(&d->p,"lro",lro); /* Set suitable lro in case it has been scaled */ setval(&d->p,"lpe",lpe); /* Set suitable lpe in case it has been scaled */ if (refSGE) w2Dfdfs(d,VJ,FLT32,d->vol); /* Output raw data for the volume, if requested */ getmax(d); /* Get coordinates of maximum */ shiftdata2D(d,OPT); /* Shift FID data for fft */ equalizenoise2D(d,STD); /* Scale for equal noise in all receivers */ phaseramp2D(d,READ); /* Phase ramp the data to correct for readout offset pro */ phaseramp2D(d,PHASE); /* Phase ramp the data to correct for phase encode offset ppe */ weightdata2D(d,STD); /* Weight data using standard VnmrJ parameters */ oversample=*val("oversample",&d->p); /* Check to see if there is oversampling */ d->fn *=oversample; /* Correct d->fn for oversample */ zerofill2D(d,STD); /* Zero fill data using standard VnmrJ parameters */ fft2D(d); /* 2D fft */ phasedata2D(d,VJ); /* Phase data if required */ shiftdata2D(d,STD); /* Shift data to get images */ if (oversample>1) zoomEPI(d); /* If oversampled, zoom to get the requested FOV */ if (refSGE) /* If standard gradient echo reference output is requested */ w2Dfdfs(d,VJ,FLT32,d->vol); /* Output data for the volume */ else w2Dfdfs(d,VJ,FLT32,DISCARD); /* Else use DISCARD to flag skip the volume */ wnifti(d,VJ,FLT32,DISCARD); break; } /* end image parameter switch */ clear2Ddata(d); /* Clear data volume from memory */ setdatapars(d); /* Sets d->nv=1 */ d->nv=*val("nseg",&d->p); /* Use d->nv for the number of shots */ d->nv2=(int)*val("nphase",&d->p); /* Use d->nv2 for number of standard gradient echo phase encodes */ d->zerofill=FALSE; /* Make sure setdatapars will not overwrite d->nv */ } /* end volume loop */ } /* end data block loop */ /* Clear all reference data */ if (epi_pc > OFF) { /* Pointwise or triple reference phase correction */ clear2Dall(&ref1); clear2Dall(&ref3); } if (epi_pc > POINTWISE) { /* Triple and scaled triple reference phase correction */ clear2Dall(&ref2); clear2Dall(&ref4); } if (epi_pc > TRIPLE) { /* Scaled triple reference phase correction */ clear2Dall(&ref5); clear2Dall(&ref6); } clear2Dall(d); /* Clear everything from memory */ }
/********************************************************* * * * Main Function * * ------------- * * * ********************************************************* | Takes arguments and launches the gof simulations. | *-------------------------------------------------------*/ int main(int argc, char *argv[]) // Array of char=arguments line { //--- Declarations & Call Function ---// int i=0, j=0, k=0, count=0, howmany=0, segsites=0, okim=0, oksim=0, numsim=0, totsim=0, nokl=0, nokl0=0; int **statseg=NULL, **nbvariant=NULL, oks[3], okstot[3]; FILE *pf=NULL, *fopen(const char*, const char*); // Pointer on File for outputs (pf) and IM input file double tajd(); char **list=NULL; // Haplotype list void updatemainparams(struct params*); int gensam(struct params*, char**, int**, int*); int **imatrix(int, int); //// From rand1.c //// /* Celine changed 03/18/2010 */ void seedit(char*, FILE*, struct params *);/*/////*/ char **cmatrix(int, int); //// From params.c //// void changeparams(struct params*); void changeparamslocus(struct params*, int); struct params getpars(int, char*[], int*); //--- Structure declaration---// struct params param; //--- Get arguments ---// param=getpars(argc, argv, &howmany); // Get input by user for parameters pf=stdout; // Output /* Celine changed 03/18/2010 */ if( !param.commandlineseedflag ) seedit("s", pf, ¶m);// WRITE seeds in summary output file /*/////*/ /* Uncommented for Celine's use */ /* for(i=0;i<argc;i++) // Information on simulation fprintf(pf, "%s ", argv[i]); */////\ //---------- Initialisation & Memory allocation ------------------// nbvariant=imatrix(param.cp.npop+1, maxsites); // array of nb of frequency spectrum typeseg=(int*)malloc((unsigned)(maxsites*sizeof(int))); // type of sites statseg=imatrix(param.cp.npop+3, howmany); // Records locus specific S1, S2, Ss, Sf, changeparams(¶m); // Change estimates parameters from priors updatemainparams(¶m); // Update parameters for the coalescent oksim=totsim=okstot[0]=okstot[1]=okstot[1]=okstot[2]=0; // simulation check, total #of sim, check on statistics for all simulations for(numsim=0; numsim<param.cp.nsim;numsim++) // Loop along number of simulations for this set of parameters { //--- Initialization and reset of quality checks ---// count=nokl=nokl0=okim=oks[0]=oks[1]=oks[1]=oks[2]=0; // number of loci, # loci with ok genealogies, no set sites, #statistics ok for(i=0;i<11;i++) // Sim specific Stats param.cp.sSiFst[i]=0; //--- Loop along the loci in the simulation ---// while((howmany-count++)) { if(okim==0) // Case All loci ok in the sample { for(i=0;i<11;i++) { param.cp.lSiFst[i]=0.0; if(i<9) param.lp[count-1].tpH[i]=0; } changeparamslocus(¶m, count-1); // Get locus specific parameters list=cmatrix(param.cp.nsam, maxsites+1); // Allocate list of haplotypes segsites=gensam(¶m, list, nbvariant, param.lp[count-1].S);// Generate a new gene ARG statseg[0][count-1]=segsites; // Total number of seg sites in sample for(i=1;i<3+param.cp.npop;i++) statseg[i][count-1]=0; if((segsites>0)) // Case segsite>0: get stats { /* fprintf(pf, "segsites:%d\npositions:\n",segsites); */ /* for(i=0;i<param.cp.nsam;i++) fprintf(pf, "%s\n", list[i]); */ /* fprintf(pf, "\n"); */ if(segsites<=param.cp.nsites) // Case segsite < lenght of locus { for(k=0;k<param.cp.nsam;k++) { for(i=k+1;i<param.cp.nsam;i++) { if((k<param.lp[count-1].ni[1])&&(i<param.lp[count-1].ni[1])) // pop1 { param.lp[count-1].tpH[0]++; // # chromosomes for(j=0;j<segsites;j++) { if(list[k][j]!=list[i][j]) param.lp[count-1].tpH[1]++; // # seg sites } } else if((k>=param.lp[count-1].ni[1])&&(i>=param.lp[count-1].ni[1])) // pop2 { param.lp[count-1].tpH[2]++; // # chromosomes for(j=0;j<segsites;j++) { if(list[k][j]!=list[i][j]) param.lp[count-1].tpH[3]++; // # seg sites } } else // total sample { param.lp[count-1].tpH[4]++;; // Totsal sample size for(j=0;j<segsites;j++) { if(list[k][j]!=list[i][j]) param.lp[count-1].tpH[5]++; // total S } } }// Loop on chromosome }// Loop along all sampled sequence for the locus for(i=0;i<segsites;i++) // Calulate S statistics for the locus { if(typeseg[i]<0) statseg[3][count-1]++; // shared else if(typeseg[i]<param.cp.npop+1) statseg[typeseg[i]][count-1]++; // population specific else statseg[4][count-1]++; // fixed } for(i=1;i<5;i++) //--- Record S1 S2 Ss Sf forthe locus ---// param.cp.lSiFst[i-1]+=statseg[i][count-1]; for(i=0;i<param.cp.nsam;i++) // Free memory for this locus free(list[i]); free(list); }// End case segsite<lenght of locus else // Case segsites>lenght of locus { okim=1; // Sample have a wrong locus oksim=1; // stop this simulation break; } }// End locus polymorphic else // Locus without seg sites { okim=1; // Sample have a wrong locus (S=0) oksim=2; // 0 for all stats } }// End Sample good until now if(okim==0) // All loci good until now { nokl++; // +1 good locus nokl0++; // +1 polymorphic locus for(i=0;i<7;i++) { if(i<4) param.cp.sSiFst[i]+=param.cp.lSiFst[i]; // sum of Sk param.lp[count-1].H[i]=param.lp[count-1].tpH[i]; // locus specific stats } param.cp.lSiFst[5]=param.lp[count-1].H[1]/=param.lp[count-1].H[0]; // Hw1 param.cp.lSiFst[6]=param.lp[count-1].H[3]/=param.lp[count-1].H[2]; // Hw2 param.lp[count-1].H[5]/=param.lp[count-1].H[4]; // Hb param.cp.lSiFst[4]=param.lp[count-1].H[6]=1-((param.lp[count-1].H[1]+param.lp[count-1].H[3])/2)/ param.lp[count-1].H[5];// locis specific Fst if((param.lp[count-1].S[0]>0)&&(param.lp[count-1].ni[1]>2)) // Locus popymorphic in pop1 { param.cp.lSiFst[7]=tajd(param.lp[count-1].ni[1], param.lp[count-1].S[0], param.lp[count-1].H[1]); param.cp.sSiFst[7]+=param.cp.lSiFst[7]; oks[0]++; // +1 good stat for pop1 } if((param.lp[count-1].S[1]>0)&&(param.lp[count-1].ni[2]>2)) // Locus popymorphic in pop2 { param.cp.lSiFst[8]=tajd(param.lp[count-1].ni[2], param.lp[count-1].S[1], param.lp[count-1].H[3]); param.cp.sSiFst[8]+=param.cp.lSiFst[8]; oks[1]++; // +1 good stat for pop2 } if(statseg[1][count-1]>0) // Locus popymorphic private in pop1 param.lp[count-1].H[7]=param.cp.lSiFst[9]+=(double) param.lp[count-1].S[2]/(statseg[1][count-1]*param.lp[count-1].ni[1]*2); // p(1) if(statseg[2][count-1]>0) // Locus popymorphic private in pop2 param.lp[count-1].H[7]=param.cp.lSiFst[9]+=(double) param.lp[count-1].S[3]/(statseg[2][count-1]*param.lp[count-1].ni[2]*2); // p(1) param.cp.sSiFst[9]+=param.cp.lSiFst[9]; // sum p1 if(statseg[3][count-1]>0) // Locus popymorphic private in pop2 { param.lp[count-1].H[8]=param.cp.lSiFst[10]=(double) param.lp[count-1].S[4]/(statseg[3][count-1]*(param.lp[count-1].ni[2]+param.lp[count-1].ni[1])); // p(2) param.cp.sSiFst[10]+=param.cp.lSiFst[10]; // sum p2 oks[2]++; } param.cp.sSiFst[4]+=param.lp[count-1].H[6]; // sum Fst param.cp.sSiFst[5]+=param.lp[count-1].H[1]; // sum Hw1 param.cp.sSiFst[6]+=param.lp[count-1].H[3]; // sum Hw2 } else if(oksim==2) // Case no seg site for that locus { oksim=0; // reset checks okim=0; nokl++; // 1+ locus to count in mean (all 0 values) for(i=0;i<9;i++) param.lp[count-1].H[i]=param.lp[count-1].tpH[i]; // locus specific stats } }// End loop on loci if(nokl==howmany) // All sample good { totsim++; // 1+ good simulation for(i=0;i<4;i++) param.cp.SiFst[i]+=param.cp.sSiFst[i]; // sum of S stats along simulations for(i=4;i<11;i++) { if(((i<7)||(i>=9))&&(nokl0>0)) param.cp.SiFst[i]+=(double)param.cp.sSiFst[i]/nokl0; // mean of other stats along simulations if((i>=7)&&(i<9)&&(oks[i-7]>0)) { param.cp.SiFst[i]+=(double)param.cp.sSiFst[i]/oks[i-7]; okstot[i-7]++; } } } }// End loop on simulations if(oksim==0) // All simulations worked { /* Uncommented for Celine's use */ /* for(i=0;i<11;i++) *///// for(i=0;i<9;i++) { if((i<7)||(i>=9)) fprintf(pf, "%lg\t", (double) param.cp.SiFst[i]/(totsim)); // write mean of sum of S stats, Fst and Hws over simulations if((i>=7)&&(i<9)) { if(oks[i-7]>0) fprintf(pf, "%lg\t", (double) param.cp.SiFst[i]/(okstot[i-7])); // write mean Tds if S>0 in pops else fprintf(pf, "NA\t" ); } } fprintf(pf, "\n"); } else // Case one locus with too much seg sites { for(i=0;i<9;i++) fprintf(pf, "NA\t" ); fprintf(pf, "\n"); } /* Celine changed 03/18/2010 */ seedit("end", pf, ¶m); // in randx.c, flag[0]!="s" so create/rewrite seed in seedmimar /*/////*/ fclose(pf); free(typeseg); for(i=0;i<param.cp.npop+3;i++) { if(i<param.cp.npop+1) free(nbvariant[i]); free(statseg[i]); } free(nbvariant); free(statseg); ///////// FREE PARAM /////// for(i=0;i<param.cp.npop;i++) free(param.cp.mig_mat[i]); free(param.cp.mig_mat); free(param.cp.config); /* Celine changed 11/27/2009 */ for(i=9;i>=0;i--) if(param.cp.listevent[i]!=NULL && param.cp.listevent[i]->nextde!=NULL) free(param.cp.listevent[i]->nextde); if(param.cp.listevent!=NULL) free(param.cp.listevent); /*/////*/ free(param.cp.deventlist); free(param.cp.size); free(param.cp.alphag); for(i=0;i<3;i++) free(param.cp.uniform[i]); free(param.cp.uniform); free(param.cp.oldest); free(param.cp.newest); free(param.cp.newparam); /* Celine changed 11/27/2009 */ for(i=0;i<howmany;i++) free(param.lp[i].name); /*/////*/ free(param.lp); /* Celine changed 03/18/2010 */ free( param.tableseeds); /*/////*/ exit(0); }// End main function
int main(int argc, char *argv[]) { int i, k, howmany, segsites ; char **list, **cmatrix(), **tbsparamstrs ; FILE *pf, *fopen() ; double probss, tmrca, ttot ; void seedit( const char * ) ; void getpars( int argc, char *argv[], int *howmany ) ; int gensam( char **list, double *probss, double *ptmrca, double *pttot ) ; ntbs = 0 ; /* these next few lines are for reading in parameters from a file (for each sample) */ tbsparamstrs = (char **)malloc( argc*sizeof(char *) ) ; for( i=0; i<argc; i++) printf("%s ",argv[i]); for( i =0; i<argc; i++) tbsparamstrs[i] = (char *)malloc(30*sizeof(char) ) ; for( i = 1; i<argc ; i++) if( strcmp( argv[i],"tbs") == 0 ) argv[i] = tbsparamstrs[ ntbs++] ; count=0; if( ntbs > 0 ) for( k=0; k<ntbs; k++) scanf(" %s", tbsparamstrs[k] ); getpars( argc, argv, &howmany) ; /* results are stored in global variable, pars */ if( !pars.commandlineseedflag ) seedit( "s"); pf = stdout ; if( pars.mp.segsitesin == 0 ) { list = cmatrix(pars.cp.nsam,maxsites+1); posit = (double *)malloc( (unsigned)( maxsites*sizeof( double)) ) ; } else { list = cmatrix(pars.cp.nsam, pars.mp.segsitesin+1 ) ; posit = (double *)malloc( (unsigned)( pars.mp.segsitesin*sizeof( double)) ) ; if( pars.mp.theta > 0.0 ) { segfac = 1.0 ; for( i= pars.mp.segsitesin; i > 1; i--) segfac *= i ; } } while( howmany-count++ ) { if( (ntbs > 0) && (count >1 ) ) { for( k=0; k<ntbs; k++) { if( scanf(" %s", tbsparamstrs[k]) == EOF ) { if( !pars.commandlineseedflag ) seedit( "end" ); exit(0); } } getpars( argc, argv, &howmany) ; } fprintf(pf,"\n//"); if( ntbs >0 ) { for(k=0; k< ntbs; k++) printf("\t%s", tbsparamstrs[k] ) ; } printf("\n"); segsites = gensam( list, &probss, &tmrca, &ttot ) ; if( pars.mp.timeflag ) fprintf(pf,"time:\t%lf\t%lf\n",tmrca, ttot ) ; if( (segsites > 0 ) || ( pars.mp.theta > 0.0 ) ) { if( (pars.mp.segsitesin > 0 ) && ( pars.mp.theta > 0.0 )) fprintf(pf,"prob: %g\n", probss ) ; fprintf(pf,"segsites: %d\n",segsites); if( segsites > 0 ) fprintf(pf,"positions: "); for( i=0; i<segsites; i++) fprintf(pf,"%6.*lf ", pars.output_precision,posit[i] ); fprintf(pf,"\n"); if( segsites > 0 ) for(i=0; i<pars.cp.nsam; i++) { fprintf(pf,"%s\n", list[i] ); } } } if( !pars.commandlineseedflag ) seedit( "end" ); }
int main(int argc, char *argv[]) { int i,j/*,k,test*/; int ndomain,total,add; int gottrans; int T_FLAG; /* char c; */ char *env; char *deffile,*keyword,*value; FILE *PARMS,*TRANS,*PDB; struct parameters *parms; struct domain_loc *domain; if(argc<2) exit_error(); /* get environment variable */ if((env=getenv("STAMPDIR"))==NULL) { fprintf(stderr,"error: environment variable STAMPDIR must be set\n"); exit(-1); } parms=(struct parameters*)malloc(sizeof(struct parameters)); strcpy(parms[0].stampdir,env); /* read in default parameters from $STAMPDIR/stamp.defaults */ deffile=(char*)malloc(1000*sizeof(char)); #if defined(_MSC_VER) sprintf(deffile,"%s\\stamp.defaults",env); #else sprintf(deffile,"%s/stamp.defaults",env); #endif if((PARMS=fopen(deffile,"r"))==NULL) { fprintf(stderr,"error: default parameter file %s does not exist\n",deffile); exit(-1); } if(getpars(PARMS,parms)==-1) exit(-1); fclose(PARMS); /* define DSSP directory file name */ sprintf(&parms[0].dsspfile[0],"%s/dssp.directories",env); /* now search the command line for commands */ keyword=(char*)malloc(1000*sizeof(char)); value=(char*)malloc(1000*sizeof(char)); for(i=1; i<argc; ++i) { if(argv[i][0]!='-') exit_error(); strcpy(keyword,&argv[i][1]); if(i+1<argc) strcpy(value,argv[i+1]); else strcpy(value,"none"); for(j=0; j<strlen(keyword); ++j) keyword[j]=ltou(keyword[j]); /* change to upper case */ T_FLAG=(value[0]=='Y' || value[0]=='y' || value[0]=='1' || value[0]=='T' || value[0]=='t' || value[0]=='o' || value[0]=='O'); /* enables one to write '1', 'YES', 'Yes', 'yes', 'T_FLAG', 'True' or 'true' to * set any boolean parmsiable to one */ if((strcmp(&argv[i][1],"l")==0) || (strcmp(&argv[i][1],"f")==0) || (strcmp(&argv[i][1],"p")==0)) { if(i+1>=argc) exit_error(); /* listfile name */ strcpy(parms[0].listfile,argv[i+1]); i++; } else if(strcmp(&argv[i][1],"P")==0) { /* want to read in parameter file */ if(i+1>=argc) exit_error(); if((PARMS=fopen(argv[i+1],"r"))==NULL) { fprintf(stderr,"error opening file %s\n",argv[i+1]); exit(-1); } if(getpars(PARMS,parms)==-1) exit(-1); fclose(PARMS); i++; } else if(strcmp(&argv[i][1],"o")==0) { /* output file */ if(i+1>=argc) exit_error(); strcpy(parms[0].logfile,argv[i+1]); i++; } else if(strcmp(&argv[i][1],"help")==0) { help_exit_error(); } else if((strcmp(&argv[i][1],"V")==0) || (strcmp(&argv[i][1],"v")==0)) { parms[0].verbose=1; strcpy(parms[0].logfile,"stdout"); } else if(strcmp(&argv[i][1],"s")==0) { parms[0].SCAN=1; parms[0].TREEWISE=parms[0].PAIRWISE=0; } else if(strcmp(&argv[i][1],"n")==0) { if(i+1>=argc) exit_error(); sscanf(argv[i+1],"%d",&parms[0].NPASS); i++; if(parms[0].NPASS!=1 && parms[0].NPASS!=2) exit_error(); } else if(strcmp(keyword,"PAIRPEN") == 0 || strcmp(keyword,"PEN")==0 || strcmp(keyword,"SECOND_PAIRPEN")==0) { sscanf(value,"%f",&parms[0].second_PAIRPEN); i++; } else if(strcmp(keyword,"FIRST_PAIRPEN")==0) { sscanf(value,"%f",&parms[0].first_PAIRPEN); i++; } else if(strcmp(keyword,"MAXPITER") == 0 || strcmp(keyword,"MAXSITER") == 0) { sscanf(value,"%d",&parms[0].MAXPITER); i++; } else if(strcmp(keyword,"MAXTITER") == 0) { sscanf(value,"%d",&parms[0].MAXTITER); i++; } else if(strcmp(keyword,"TREEPEN") == 0 || strcmp(keyword,"SECOND_TREEPEN")==0) { sscanf(value,"%f",&parms[0].second_TREEPEN); i++; } else if(strcmp(keyword,"FIRST_TREEPEN")==0) { sscanf(value,"%f",&parms[0].first_TREEPEN); i++; } else if(strcmp(keyword,"SCORETOL") == 0) { sscanf(value,"%f",&parms[0].SCORETOL); i++; } else if(strcmp(keyword,"CLUSTMETHOD") == 0) { sscanf(value,"%d",&parms[0].CLUSTMETHOD); i++; } else if(strcmp(keyword,"E1") == 0 || strcmp(keyword,"SECOND_E1")==0) { sscanf(value,"%f",&parms[0].second_E1); i++; } else if(strcmp(keyword,"E2") == 0 || strcmp(keyword,"SECOND_E2")==0) { sscanf(value,"%f",&parms[0].second_E2); i++; } else if(strcmp(keyword,"FIRST_E1")==0) { sscanf(value,"%f",&parms[0].first_E1); i++; } else if(strcmp(keyword,"FIRST_E2")==0) { sscanf(value,"%f",&parms[0].first_E2); i++; } else if(strcmp(keyword,"NPASS")==0) { sscanf(value,"%d",&parms[0].NPASS); i++; if(parms[0].NPASS!=1 && parms[0].NPASS!=2) { fprintf(stderr,"error: NPASS must be either 1 or 2\n"); return -1; } } else if(strcmp(keyword,"CUTOFF") == 0 || strcmp(keyword,"SECOND_CUTOFF")==0) { sscanf(value,"%f",&parms[0].second_CUTOFF); i++; } else if(strcmp(keyword,"FIRST_CUTOFF")==0) { sscanf(value,"%f",&parms[0].first_CUTOFF); i++; } else if(strcmp(keyword,"TREEPLOT") == 0) { parms[0].TREEPLOT=T_FLAG; i++; } else if(strcmp(keyword,"PAIRPLOT") == 0) { parms[0].PAIRPLOT=T_FLAG; i++; } else if(strcmp(keyword,"NALIGN") == 0) { sscanf(value,"%d",&parms[0].NALIGN); i++; } else if(strcmp(keyword,"DISPALL") == 0) { parms[0].DISPALL=T_FLAG; i++; } else if(strcmp(keyword,"HORIZ") ==0) { parms[0].HORIZ=T_FLAG; i++; } else if(strcmp(keyword,"ADD") ==0) { sscanf(value,"%f",&parms[0].ADD); i++; } else if(strcmp(keyword,"NMEAN") ==0) { sscanf(value,"%f",&parms[0].NMEAN); i++; } else if(strcmp(keyword,"NSD") ==0) { sscanf(value,"%f",&parms[0].NSD); i++; } else if(strcmp(keyword,"STATS") ==0) { parms[0].STATS=T_FLAG; i++; } else if(strcmp(keyword,"NA") == 0) { sscanf(value,"%f",&parms[0].NA); i++; } else if(strcmp(keyword,"NB") == 0) { sscanf(value,"%f",&parms[0].NB); i++; } else if(strcmp(keyword,"NASD") == 0) { sscanf(value,"%f",&parms[0].NASD); i++; } else if(strcmp(keyword,"NBSD") == 0) { sscanf(value,"%f",&parms[0].NBSD); i++; } else if(strcmp(keyword,"PAIRWISE") == 0) { parms[0].PAIRWISE=T_FLAG; i++; } else if(strcmp(keyword,"TREEWISE") == 0) { parms[0].TREEWISE=T_FLAG; i++; } else if(strcmp(keyword,"ORDFILE") == 0) { strcpy(parms[0].ordfile,value); i++; } else if(strcmp(keyword,"TREEFILE") == 0) { strcpy(parms[0].treefile,value); i++; } else if(strcmp(keyword,"PLOTFILE") == 0) { strcpy(parms[0].plotfile,value); i++; } else if(strcmp(keyword,"PREFIX") == 0 || strcmp(keyword,"TRANSPREFIX")==0 || strcmp(keyword,"STAMPPREFIX")==0) { strcpy(parms[0].transprefix,value); i++; } else if(strcmp(keyword,"MATFILE") == 0) { strcpy(parms[0].matfile,value); i++; } else if(strcmp(keyword,"THRESH") ==0) { sscanf(value,"%f",&parms[0].THRESH); i++; } else if(strcmp(keyword,"TREEALIGN")==0) { parms[0].TREEALIGN=T_FLAG; i++; } else if(strcmp(keyword,"TREEALLALIGN")==0) { parms[0].TREEALLALIGN=T_FLAG; i++; } else if(strcmp(keyword,"PAIRALIGN")==0 || strcmp(keyword,"SCANALIGN")==0) { parms[0].PAIRALIGN=T_FLAG; i++; } else if(strcmp(keyword,"PAIRALLALIGN")==0 || strcmp(keyword,"SCANALLALIGN")==0) { parms[0].PAIRALLALIGN=T_FLAG; i++; } else if(strcmp(keyword,"PRECISION")==0) { sscanf(value,"%d",&parms[0].PRECISION); i++; } else if(strcmp(keyword,"MAX_SEQ_LEN")==0) { sscanf(value,"%d",&parms[0].MAX_SEQ_LEN); i++; } else if(strcmp(keyword,"ROUGHFIT")==0) { parms[0].ROUGHFIT=T_FLAG; i++; } else if(strcmp(keyword,"ROUGH")==0) { parms[0].ROUGHFIT=1; } else if(strcmp(keyword,"ROUGHOUT")==0) { parms[0].roughout=1; } else if(strcmp(keyword,"ROUGHOUTFILE")==0) { if(i+1>=argc) exit_error(); strcpy(&parms[0].roughoutfile[0],argv[i+1]); i++; parms[0].roughout=1; } else if(strcmp(keyword,"BOOLCUT")==0 || strcmp(keyword,"SECOND_BOOLCUT")==0) { sscanf(value,"%f",&parms[0].second_BOOLCUT); i++; } else if(strcmp(keyword,"FIRST_BOOLCUT")==0) { sscanf(value,"%f",&parms[0].first_BOOLCUT); i++; } else if(strcmp(keyword,"SCANSLIDE")==0) { sscanf(value,"%d",&parms[0].SCANSLIDE); i++; } else if(strcmp(keyword,"SCAN")==0) { parms[0].SCAN=T_FLAG; i++; if(T_FLAG) parms[0].PAIRWISE=parms[0].TREEWISE=0; } else if(strcmp(keyword,"SCANMODE")==0) { sscanf(value,"%d",&parms[0].SCANMODE); i++; if(parms[0].SCANMODE==1) parms[0].PAIRALIGN=1; } else if(strcmp(keyword,"SCANCUT")==0) { sscanf(value,"%f",&parms[0].SCANCUT); i++; } else if(strcmp(keyword,"SECSCREEN")==0) { parms[0].SECSCREEN=T_FLAG; i++; } else if(strcmp(keyword,"SECSCREENMAX")==0) { sscanf(value,"%f",&parms[0].SECSCREENMAX); i++; } else if(strcmp(keyword,"SCANTRUNC")==0) { parms[0].SCANTRUNC=T_FLAG; i++; } else if(strcmp(keyword,"SCANTRUNCFACTOR")==0) { sscanf(value,"%f",&parms[0].SCANTRUNCFACTOR); i++; } else if(strcmp(keyword,"DATABASE")==0) { strcpy(&parms[0].database[0],value); i++; } else if(strcmp(keyword,"SCANFILE")==0) { strcpy(&parms[0].scanfile[0],value); i++; } else if(strcmp(keyword,"LOGFILE")==0) { strcpy(&parms[0].logfile[0],value); i++; } else if(strcmp(keyword,"SECTYPE")==0) { sscanf(value,"%d",&parms[0].SECTYPE); i++; } else if(strcmp(keyword,"SCANSEC")==0) { sscanf(value,"%d",&parms[0].SCANSEC); i++; } else if(strcmp(keyword,"SECFILE")==0) { strcpy(&parms[0].secfile[0],value); i++; parms[0].SECTYPE=2; } else if(strcmp(keyword,"BOOLEAN")==0) { parms[0].BOOLEAN=T_FLAG; i++; } else if(strcmp(keyword,"BOOLMETHOD")==0) { sscanf(value,"%d",&parms[0].BOOLMETHOD); i++; } else if(strcmp(keyword,"LISTFILE")==0) { strcpy(&parms[0].listfile[0],value); i++; } else if(strcmp(keyword,"STAMPDIR")==0) { strcpy(&parms[0].stampdir[0],value); i++; } else if(strcmp(keyword,"CLUST")==0) { parms[0].CLUST=T_FLAG; i++; } else if(strcmp(keyword,"COLUMNS")==0) { sscanf(value,"%d",&parms[0].COLUMNS); i++; } else if(strcmp(keyword,"SW")==0) { sscanf(value,"%d",&parms[0].SW); i++; } else if(strcmp(keyword,"CCFACTOR")==0) { sscanf(value,"%f",&parms[0].CCFACTOR); i++; } else if(strcmp(keyword,"CCADD")==0) { parms[0].CCADD=T_FLAG; i++; } else if(strcmp(keyword,"MINFIT")==0) { sscanf(value,"%d",&parms[0].MINFIT); i++; } else if(strcmp(keyword,"ROUGHALIGN")==0) { strcpy(parms[0].roughalign,value); i++; } else if(strcmp(keyword,"FIRST_THRESH")==0) { sscanf(value,"%f",&parms[0].first_THRESH); i++; } else if(strcmp(keyword,"MIN_FRAC")==0) { sscanf(value,"%f",&parms[0].MIN_FRAC); i++; } else if(strcmp(keyword,"SCORERISE")==0) { parms[0].SCORERISE=T_FLAG; i++; } else if(strcmp(keyword,"SKIPAHEAD")==0) { parms[0].SKIPAHEAD=T_FLAG; i++; } else if(strcmp(keyword,"SCANSCORE")==0) { sscanf(value,"%d",&parms[0].SCANSCORE); i++; } else if(strcmp(keyword,"PAIROUTPUT")==0) { parms[0].PAIROUTPUT=T_FLAG; i++; } else if(strcmp(keyword,"ALLPAIRS")==0) { parms[0].ALLPAIRS=T_FLAG; i++; } else if (strcmp(keyword,"ATOMTYPE")==0) { parms[0].ATOMTYPE=T_FLAG; i++; } else if(strcmp(keyword,"DSSP")==0) { parms[0].DSSP=T_FLAG; i++; } else if(strcmp(keyword,"SLOWSCAN")==0) { parms[0].SLOWSCAN=T_FLAG; i++; } else if(strcmp(keyword,"SLOW")==0) { parms[0].SLOWSCAN=1; } else if(strcmp(keyword,"CUT")==0) { parms[0].CO=1; } else if(strcmp(&argv[i][1],"slide")==0) { if(i+1>=argc) exit_error(); sscanf(argv[i+1],"%d",&parms[0].SCANSLIDE); i++; } else if(strcmp(&argv[i][1],"d")==0) { /* database file */ if(i+1>=argc) exit_error(); strcpy(&parms[0].database[0],argv[i+1]); i++; } else if(strcmp(&argv[i][1],"pen1")==0) { if(i+1>=argc) exit_error(); sscanf(argv[i+1],"%f",&parms[0].first_PAIRPEN); i++; } else if(strcmp(&argv[i][1],"pen2")==0) { if(i+1>=argc) exit_error(); sscanf(argv[i+1],"%f",&parms[0].second_PAIRPEN); i++; } else if(strcmp(&argv[i][1],"prefix")==0) { if(i+1>=argc) exit_error(); strcpy(&parms[0].transprefix[0],argv[i+1]); i++; } else if(strcmp(&argv[i][1],"scancut")==0) { if(i+1>=argc) exit_error(); sscanf(argv[i+1],"%f",&parms[0].SCANCUT); i++; } else if(strcmp(&argv[i][1],"opd")==0) { parms[0].opd=1; } else { exit_error(); } } free(keyword); free(value); /* make the names of all the output files using the prefix */ sprintf(&parms[0].ordfile[0],"%s.ord",parms[0].transprefix); sprintf(&parms[0].treefile[0],"%s.tree",parms[0].transprefix); sprintf(&parms[0].plotfile[0],"%s.plot",parms[0].transprefix); sprintf(&parms[0].matfile[0],"%s.mat",parms[0].transprefix); sprintf(&parms[0].roughalign[0],"%s_align.rough",parms[0].transprefix); sprintf(&parms[0].scanfile[0],"%s.scan",parms[0].transprefix); if(strcmp(parms[0].logfile,"stdout")==0 || strcmp(parms[0].logfile,"STDOUT")==0) { parms[0].LOG=stdout; } else if(strcmp(parms[0].logfile,"silent")==0 || strcmp(parms[0].logfile,"SILENT")==0) { #if defined(_MSC_VER) parms[0].LOG=stdout; #else parms[0].LOG=fopen("/dev/null","w"); #endif } else { if((parms[0].LOG=fopen(parms[0].logfile,"w"))==NULL) { fprintf(stderr,"error opening file %s\n",parms[0].logfile); exit(-1); } } if(strcmp(parms[0].logfile,"silent")==0) { printf("\nSTAMP Structural Alignment of Multiple Proteins\n"); printf(" by Robert B. Russell & Geoffrey J. Barton \n"); printf(" Please cite PROTEINS, v14, 309-323, 1992\n\n"); } fprintf(parms[0].LOG,"-------------------------------------------------------------------------------\n"); fprintf(parms[0].LOG," S t A M P\n"); fprintf(parms[0].LOG," Structural Alignment of\n"); fprintf(parms[0].LOG," Multiple Proteins\n"); fprintf(parms[0].LOG," By Robert B. Russell & Geoffrey J. Barton \n"); fprintf(parms[0].LOG," Last Modified: %s\n",lastmod); fprintf(parms[0].LOG," Please cite Ref: Russell and GJ Barton, PROTEINS, v14, 309-323, 1992\n"); fprintf(parms[0].LOG,"-------------------------------------------------------------------------------\n\n"); fprintf(parms[0].LOG,"STAMPDIR has been set to %s\n\n\n",parms[0].stampdir); /* read in coordinate locations and initial transformations */ if((TRANS = fopen(parms[0].listfile,"r")) == NULL) { fprintf(stderr,"error: file %s does not exist\n",parms[0].listfile); exit(-1); } /* determine the number of domains specified */ ndomain=count_domain(TRANS); domain=(struct domain_loc*)malloc(ndomain*sizeof(struct domain_loc)); rewind(TRANS); if(getdomain(TRANS,domain,&ndomain,ndomain,&gottrans,parms[0].stampdir,parms[0].DSSP,parms[0].LOG)==-1) exit(-1); fclose(TRANS); fprintf(parms[0].LOG,"Details of this run:\n"); if(parms[0].PAIRWISE) fprintf(parms[0].LOG,"PAIRWISE mode specified\n"); if(parms[0].TREEWISE) fprintf(parms[0].LOG,"TREEWISE mode specified\n"); if(parms[0].SCAN) fprintf(parms[0].LOG,"SCAN mode specified\n"); if(!parms[0].SCAN) { /* if no MINFIT has been given, then take the smallest length and divide it by two */ if(parms[0].MINFIT==-1) { parms[0].MINFIT=parms[0].MAXLEN; for(i=0; i<ndomain; ++i) if(domain[i].ncoords<parms[0].MINFIT) parms[0].MINFIT=domain[i].ncoords; parms[0].MINFIT/=2; } fprintf(parms[0].LOG," pairwise score file: %s\n",parms[0].matfile); if(parms[0].TREEWISE) { fprintf(parms[0].LOG," tree order file: %s\n",parms[0].ordfile); fprintf(parms[0].LOG," tree file: %s\n",parms[0].treefile); fprintf(parms[0].LOG," tree plot file: %s\n",parms[0].plotfile); } } else { fprintf(parms[0].LOG," SCANMODE set to %d\n",parms[0].SCANMODE); fprintf(parms[0].LOG," SCANSCORE set to %d\n",parms[0].SCANSCORE); fprintf(parms[0].LOG," (see documentation for an explanation)\n"); if(parms[0].opd==1) fprintf(parms[0].LOG," Domains will be skipped after the first match is found\n"); if(parms[0].SCANMODE==1) { fprintf(parms[0].LOG," Transformations for Sc values greater than %f are to be output\n",parms[0].SCANCUT); fprintf(parms[0].LOG," to the file %s\n",parms[0].transprefix); } else { fprintf(parms[0].LOG," Only the scores are to be output to the file %s\n",parms[0].scanfile); } fprintf(parms[0].LOG," secondary structures are "); switch(parms[0].SCANSEC) { case 0: fprintf(parms[0].LOG," not to be considered\n"); break; case 1: fprintf(parms[0].LOG," to be from DSSP\n"); break; case 2: fprintf(parms[0].LOG," to be read in from %s\n",parms[0].secfile); break; default: fprintf(parms[0].LOG," not to be considered\n"); } if(parms[0].SECSCREEN) { fprintf(parms[0].LOG," An initial screen on secondary structure content is to performed when possible\n"); fprintf(parms[0].LOG," Secondary structure summaries farther than %6.2f %% apart result in\n",parms[0].SECSCREENMAX); fprintf(parms[0].LOG," a comparison being ignored\n"); } fprintf(parms[0].LOG," Initial fits are to be performed by aligning the N-terminus of the query\n with every %d residue of the database sequence\n",parms[0].SCANSLIDE); fprintf(parms[0].LOG," of the query along the database structure.\n"); if(parms[0].SCANTRUNC) { fprintf(parms[0].LOG," If sequences in the database are > %5.3f x the query sequence length\n",parms[0].SCANTRUNCFACTOR); fprintf(parms[0].LOG," then a fraction of the the database structure, corresponding to this\n"); fprintf(parms[0].LOG," of length %5.3f x the query, will be considered\n",parms[0].SCANTRUNCFACTOR); fprintf(parms[0].LOG," comparisons are to be ignored if the database structure is less than\n %6.4f x the length of the query structure\n",parms[0].MIN_FRAC); } fprintf(parms[0].LOG," Domain database file to be scanned %s\n",parms[0].database); } if(parms[0].TREEWISE) fprintf(parms[0].LOG," output files prefix: %s\n",parms[0].transprefix); fprintf(parms[0].LOG,"\n\nParameters:\n"); fprintf(parms[0].LOG,"Rossmann and Argos parameters:\n"); if(parms[0].NPASS==2) { fprintf(parms[0].LOG," Two fits are to be performed, the first fit with:\n"); fprintf(parms[0].LOG," E1=%7.3f,",parms[0].first_E1); fprintf(parms[0].LOG," E2=%7.3f,",parms[0].first_E2); fprintf(parms[0].LOG," CUT=%7.3f,",parms[0].first_CUTOFF); fprintf(parms[0].LOG," PAIRPEN=%7.3f,",parms[0].first_PAIRPEN); fprintf(parms[0].LOG," TREEPEN=%7.3f\n",parms[0].first_TREEPEN); /* fprintf(parms[0].LOG," E1=%7.3f, E2=%7.3f, CUT=%7.3f, PAIRPEN=%7.3f, TREEPEN=%7.3f\n", parms[0].first_E1,parms[0].first_E2,parms[0].first_CUTOFF,parms[0].first_PAIRPEN,parms[0].first_TREEPEN); */ fprintf(parms[0].LOG," The second fit with:\n"); } else fprintf(parms[0].LOG," One fit is to performed with:\n"); fprintf(parms[0].LOG," E1=%7.3f, E2=%7.3f, CUT=%7.3f, PAIRPEN=%7.3f, TREEPEN=%7.3f\n", parms[0].second_E1,parms[0].second_E2,parms[0].second_CUTOFF,parms[0].second_PAIRPEN,parms[0].second_TREEPEN); if(parms[0].BOOLEAN) { fprintf(parms[0].LOG," BOOLEAN mode specified\n"); fprintf(parms[0].LOG," A boolean matrix will be calculated corresponding to whether\n"); fprintf(parms[0].LOG," positions have Pij values greater than:\n"); if(parms[0].NPASS==2) fprintf(parms[0].LOG," %7.3f, for the first fit and\n",parms[0].first_BOOLCUT); fprintf(parms[0].LOG," %7.3f",parms[0].second_BOOLCUT); if(parms[0].NPASS==2) fprintf(parms[0].LOG," for the second fit.\n"); else fprintf(parms[0].LOG,".\n"); fprintf(parms[0].LOG," In the multiple case, this criteria must be satisfied for *all*\n"); fprintf(parms[0].LOG," possible pairwise comparisons\n"); } if(parms[0].SW==1) { fprintf(parms[0].LOG," Corner cutting is to be performed\n"); fprintf(parms[0].LOG," Corner cutting length: %6.2f\n",parms[0].CCFACTOR); if(parms[0].CCADD) fprintf(parms[0].LOG," The length difference is to be added to this value\n"); } else { fprintf(parms[0].LOG," The entire SW matrix is to be calculated and used\n"); } fprintf(parms[0].LOG," The minimum length of alignment to be evaluated further is %3d residues\n",parms[0].MINFIT); fprintf(parms[0].LOG,"\n"); fprintf(parms[0].LOG," Convergence tolerance SCORETOL= %f %%\n", parms[0].SCORETOL); fprintf(parms[0].LOG," Other parameters:\n"); fprintf(parms[0].LOG," MAX_SEQ_LEN=%d, MAXPITER=%d, MAXTITER=%d\n", parms[0].MAX_SEQ_LEN,parms[0].MAXPITER,parms[0].MAXTITER); fprintf(parms[0].LOG," PAIRPLOT (SCANPLOT) = %d, TREEPLOT = %d, PAIRALIGN (SCANALIGN) = %d, TREEALIGN = %d\n", parms[0].PAIRPLOT,parms[0].TREEPLOT,parms[0].PAIRALIGN,parms[0].TREEALIGN); fprintf(parms[0].LOG," PAIRALLALIGN (SCANALLALIGN) = %d, TREEALLALIGN = %d\n",parms[0].PAIRALLALIGN,parms[0].TREEALLALIGN); if(!parms[0].BOOLEAN) { fprintf(parms[0].LOG,"\n\nDetails of Confidence value calculations:\n"); if(parms[0].STATS) fprintf(parms[0].LOG," actual mean and standard deviations are to be\n used for determination of Pij' values.\n"); else { fprintf(parms[0].LOG," pre-set mean and standard deviations are to be used\n and multiple comparisons are to be corrected.\n"); fprintf(parms[0].LOG," mean Xt = %f, standard deviation SDt = %f\n", parms[0].NMEAN,parms[0].NSD); fprintf(parms[0].LOG," for the multiple case:\n"); fprintf(parms[0].LOG," pairwise means are to be calculated from:\n Xp = exp(%6.4f * log(length) + %6.4f)\n",parms[0].NA,parms[0].NB); fprintf(parms[0].LOG," and pairwise standard deviations from:\n SDp = exp(%6.4f * log(length) + %6.4f)\n",parms[0].NASD,parms[0].NBSD); fprintf(parms[0].LOG," the mean to be used is calculated from: \n Xc = (Xm/Xp) * Xt).\n"); fprintf(parms[0].LOG," and the standard deviation from: \n SDc = (SDm/SDp)*SDt).\n"); } /* End of if(parms[0].STATS) */ } else { fprintf(parms[0].LOG," Positional values will consist of one's or zeros depending on whether\n"); fprintf(parms[0].LOG," a position satisfies the BOOLEAN criterion above\n"); fprintf(parms[0].LOG," The score (Sp) for each alignment will be a sum of these positions.\n"); } /* end of if(parms[0].BOOLEAN */ if(!parms[0].SCAN && parms[0].TREEWISE) { fprintf(parms[0].LOG,"\n\nTree is to be generated by "); if(parms[0].CLUSTMETHOD==0) fprintf(parms[0].LOG,"1/rms values.\n"); if(parms[0].CLUSTMETHOD==1) { fprintf(parms[0].LOG,"scores from path tracings modified as follows:\n"); fprintf(parms[0].LOG," Sc = (Sp/Lp) * ((Lp-ia)/La) * ((Lp-ib)/Lb),\n"); fprintf(parms[0].LOG," where Sp is the actual score, Lp is the path length.\n"); fprintf(parms[0].LOG," and La & Lb are the lengths of the structures considered.\n"); } /* End of if(parms[0].METHOD==2) */ } fprintf(parms[0].LOG,"\n\n"); fprintf(parms[0].LOG,"Reading coordinates...\n"); for(i=0; i<ndomain; ++i) { fprintf(parms[0].LOG,"Domain %3d %s %s\n ",i+1,domain[i].filename,domain[i].id); if((PDB=openfile(domain[i].filename,"r"))==NULL) { fprintf(stderr,"error opening file %s\n",domain[i].filename); exit(-1); } domain[i].ncoords=0; domain[i].coords=(int**)malloc(parms[0].MAX_SEQ_LEN*sizeof(int*)); domain[i].aa=(char*)malloc((parms[0].MAX_SEQ_LEN+1)*sizeof(char)); domain[i].numb=(struct brookn*)malloc((parms[0].MAX_SEQ_LEN)*sizeof(struct brookn)); total=0; fprintf(parms[0].LOG," "); for(j=0; j<domain[i].nobj; ++j) { if(!parms[0].DSSP) { if(igetca(PDB,&domain[i].coords[total],&domain[i].aa[total],&domain[i].numb[total], &add,domain[i].start[j],domain[i].end[j],domain[i].type[j],(parms[0].MAX_SEQ_LEN-total), domain[i].reverse[j],parms[0].PRECISION,parms[0].ATOMTYPE,parms[0].LOG)==-1) { fprintf(stderr,"Error in domain %s object %d \n",domain[i].id,j+1); exit(-1); } } else { if(igetcadssp(PDB,&domain[i].coords[total],&domain[i].aa[total],&domain[i].numb[total], &add,domain[i].start[j],domain[i].end[j],domain[i].type[j],(parms[0].MAX_SEQ_LEN-total), domain[i].reverse[j],parms[0].PRECISION,parms[0].LOG)==-1) exit(-1); } switch(domain[i].type[j]) { case 1: fprintf(parms[0].LOG," all residues"); break; case 2: fprintf(parms[0].LOG," chain %c",domain[i].start[j].cid); break; case 3: fprintf(parms[0].LOG," from %c %4d %c to %c %4d %c", domain[i].start[j].cid,domain[i].start[j].n,domain[i].start[j].in, domain[i].end[j].cid,domain[i].end[j].n,domain[i].end[j].in); break; } fprintf(parms[0].LOG,"%4d CAs ",add); total+=add; closefile(PDB,domain[i].filename); PDB=openfile(domain[i].filename,"r"); } domain[i].ncoords=total; fprintf(parms[0].LOG,"=> %4d CAs in total\n",domain[i].ncoords); fprintf(parms[0].LOG,"Applying the transformation... \n"); printmat(domain[i].R,domain[i].V,3,parms[0].LOG); fprintf(parms[0].LOG," ...to these coordinates.\n"); matmult(domain[i].R,domain[i].V,domain[i].coords,domain[i].ncoords,parms[0].PRECISION); closefile(PDB,domain[i].filename); } fprintf(parms[0].LOG,"\n\n"); fprintf(parms[0].LOG,"Secondary structure...\n"); for(i=0; i<ndomain; ++i) domain[i].sec=(char*)malloc(parms[0].MAX_SEQ_LEN*sizeof(char)); switch(parms[0].SECTYPE) { case 0: { fprintf(parms[0].LOG,"No secondary structure assignment will be considered\n"); for(i=0; i<ndomain; ++i) { for(j=0; j<domain[i].ncoords; ++j) domain[i].sec[j]='?'; domain[i].sec[j]='\0'; } parms[0].SECSCREEN=0; } break; case 1: { fprintf(parms[0].LOG,"Will try to find Kabsch and Sander DSSP assignments\n"); if(getks(domain,ndomain,parms)!=0) parms[0].SECSCREEN=0; } break; case 2: { fprintf(parms[0].LOG,"Reading in secondary structure assignments from file: %s\n",parms[0].secfile); if(getsec(domain,ndomain,parms)!=0) parms[0].SECSCREEN=0; } break; default: { fprintf(stderr,"error: unrecognised secondary structure assignment option\n"); exit(-1); } } fprintf(parms[0].LOG,"\n\n"); if(parms[0].SCAN) { i=0; fprintf(parms[0].LOG,"Scanning with domain %s\n",&(domain[i].id[0])); if(strcmp(parms[0].logfile,"silent")==0) { printf("Results of scan will be written to file %s\n",parms[0].scanfile); printf("Fits = no. of fits performed, Sc = STAMP score, RMS = RMS deviation\n"); printf("Align = alignment length, Nfit = residues fitted, Eq. = equivalent residues\n"); printf("Secs = no. equiv. secondary structures, %%I = seq. identity, %%S = sec. str. identity\n"); printf("P(m) = P value (p=1/10) calculated after Murzin (1993), JMB, 230, 689-694\n"); printf("\n"); printf(" Domain1 Domain2 Fits Sc RMS Len1 Len2 Align Fit Eq. Secs %%I %%S P(m)\n"); } if(parms[0].SLOWSCAN==1) { if(slow_scan(domain[i],parms)==-1) exit(-1); } else { if(scan(domain[i],parms)==-1) exit(-1); } if(strcmp(parms[0].logfile,"silent")==0) printf("See the file %s.scan\n",parms[0].transprefix); fprintf(parms[0].LOG,"\n"); } else { if(parms[0].ROUGHFIT) if(roughfit(domain,ndomain,parms)==-1) exit(-1); if(parms[0].PAIRWISE) if(pairwise(domain,ndomain,parms)==-1) exit(-1); if(parms[0].TREEWISE) if(treewise(domain,ndomain,parms)==-1) exit(-1); } /* end of if(parms[0].SCAN... */ /* freeing memory to keep purify happy */ /* for(i=0; i<ndomain; ++i) { free(domain[i].aa); free(domain[i].sec); free(domain[i].v); free(domain[i].V); for(j=0; j<3; ++j) { free(domain[i].R[j]); free(domain[i].r[j]); } free(domain[i].R); free(domain[i].r); for(j=0; j<domain[i].ncoords; ++j) free(domain[i].coords[j]); free(domain[i].coords); free(domain[i].type); free(domain[i].start); free(domain[i].end); free(domain[i].reverse); free(domain[i].numb); } */ free(domain); exit(0); }
command() { float tval; int i,echeck; int pmin,pmax,pstep; char tbuf[20]; while (echeck = getstring(": ")) { if (echeck == EOF) { fileinput(STD); } else if (startsame(in,"cycle")) { cycle(); } else if (startsame(in,"coarticulation")) { ttyprint("coarticulation %s: change? ",(coartflag ? "ON":"OFF")); fscanf(infp,"%s",in); if(in[0] == 'n') continue; coartflag = 1 - coartflag; } else if (startsame(in,"rc")) { printf("reset and cycle\n"); zarrays(); cycle(); } else if (startsame(in,"wordacts")) { printwords(printmin,printmax,3,stdout); if (outfile) printwords(printmin,printmax,3,outfile); } else if (startsame(in,"wtacts")) { printwt(printmin,printmax,3,stdout); if (outfile) printwt(printmin,printmax,3,outfile); } else if (startsame(in,"owtacts")) { getstring("word: "); strcpy(tbuf,in); printonewt(tbuf,printmin,printmax,3,stdout); if (outfile) printonewt(tbuf,printmin,printmax,3,outfile); } else if (startsame(in,"phonacts")) { printphonemes(printmin,printmax,3,stdout); if (outfile) printphonemes(printmin,printmax,3,outfile); } else if (startsame(in,"featacts")) { printf("feature activations - give min,max,step: "); scanf("%d %d %d",&pmin,&pmax,&pstep); printfeatures(pmin,pmax,pstep,stdout); if (outfile) printfeatures(pmin,pmax,pstep,outfile); } else if (startsame(in,"expression")) { setex(); } else if (startsame(in,"fileinput")) { fileinput(NONSTD); } else if (startsame(in,"inspecs")) { ttyprint("File name (- = stdin): "); fscanf(infp,"%s",in); inspecs(in); } else if (startsame(in,"infeatures")) { ttyprint("File name: "); fscanf(infp,"%s",in); infeats(in); } /* NOT PRESENTLY OPERATIVE -- JLM 10-5-82 else if (startsame(in,"wsubset")) { wordsubset(); } */ else if (startsame(in,"test")) { getstring("test string: "); test(in); } else if (startsame(in,"topdown")) { topdown(); } else if (startsame(in,"output")) { setout(); } else if (startsame(in,"ofile")) { getstring("give filename (or - for none): "); setoutfile(in); } else if (in[0] == '!') { system(&in[1]); } else if (in[0] == '?') { help(); } else if (startsame(in,"help")) { help(); } else if (startsame(in,"lexicon")) { getlex(); } else if (startsame(in,"parameters")) { getpars(); } else if (startsame(in,"quit")) { quit(); } else if (startsame(in,"decay")) { ttyprint ("decay values:\n"); getfloat(decay,NLEVS,"F","P","W"); } else if (startsame(in,"alpha")) { ttyprint ("alpha values:\n"); getfloat(alpha,NPARAMS, "IF","FF","FP","PP","PW","WW","WP","PF","PFC"); } else if (startsame(in,"gamma")) { ttyprint ("gamma values:\n"); getfloat(ga,NLEVS,"F","P","W"); } else if (startsame(in,"grace")) { ttyprint ("grace %s: change? ",(grace ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; grace = 1 - grace; } else if (startsame(in,"rest")) { tval = rest[W]; ttyprint ("rest values:\n"); getfloat(rest,NLEVS,"F","P","W"); if (tval != rest[W]) { initialize(); } } else if (startsame(in,"fweight")) { ttyprint ("fweight values:\n"); getfloat(fweight,NCONTINS, "POW","PIT","VOI","ABT","DIF","ACU","CON","LWS", "MDS", "HIS","FT1","FT2","FT3","FT4","FT5","FT6"); } else if (startsame(in,"pthresh")) { ttyprint ("pthresh values:\n"); getfloat(pthresh,NLEVS,"F","P","W"); } else if (startsame(in,"nreps")) { ttyprint ("%d nreps: change? ",nreps); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sscanf(in,"%d",&nreps); } else if (startsame(in,"pfreq")) { ttyprint ("%d pfreq: change? ",printfreq); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sscanf(in,"%d",&printfreq); } else if (startsame(in,"summarypr")) { ttyprint("give min, max, and step: "); fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep); summarypr(pmin,pmax,pstep,stdout); if (outfile) summarypr(pmin,pmax,pstep,outfile); } else if (startsame(in,"spointers")) { qsort(wordptr,nwptrs,sizeof(struct word *),ecomp); } else if (startsame(in,"sinspec")) { sinspec(); } else if (startsame(in,"sfeatures")) { ttyprint("file name: "); fscanf(infp,"%s",in); sfeatures(in); } else if (startsame(in,"dinspec")) { dinspec(); } else if (startsame(in,"acoustinput")) { ttyprint("give min, max, and step: "); fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep); acoustinput(pmin,pmax,pstep,stdout); if (outfile) acoustinput(pmin,pmax,pstep,outfile); } else if (startsame(in,"sumopt")) { ttyprint ("summaryprint %s: change? ",(sumflag ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sumflag = 1 - sumflag; } else if (startsame(in,"echooutput")) { ttyprint ("echooutput %s: change? ",(echoflag ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; echoflag = 1 - echoflag; } else if (startsame(in,"min")) { ttyprint ("min = "); getval(&min); } else if (startsame(in,"max")) { ttyprint ("max = "); getval(&max); } else if (startsame(in,"windowcent")) { ttyprint ("windowcent = "); getval(&windowcent); } else if (startsame(in,"wbase")) { ttyprint ("wbase = "); getval(&wbase); } else if (startsame(in,"wchange")) { ttyprint ("wchange = "); getval(&wchange); } else if (startsame(in,"wgain")) { ttyprint ("wgain = "); getval(&wgain); } else if (startsame(in,"wramp")) { ttyprint ("wramp = "); getval(&wramp); } else if (startsame(in,"imax")) { ttyprint ("imax = "); getval(&imax); } else if (startsame(in,"freqscale")) { ttyprint ("freqscale = "); tval = fscale; getval(&fscale); if (tval != fscale) { initialize(); } } else if (startsame(in,"abort")) { abort(); /* to get a core dump for sdb */ } else { printf("Unrecognized request: For help type ?.\n"); if (infp != stdin) fileinput(STD); } wait(0); } }