+ //changing ptt_size to row
+ double permuted_ttests[row], pvalues[row], tinitial[row];
+
+ for(i=0;i<row;i++){
+ permuted_ttests[i]=0;}
+
+ for(i=0;i<row;i++){
+ pvalues[i]=0;
+ tinitial[i]=0; }
+
+ // Find the initial values for the matrix.
+ start(pmatrix,gvalue,nr,nc,tinitial,storage);
+
+ // Start the calculations.
+
+ if ( (col==2) || ((g-1)<8) || ((col-g+1) < 8) ){
+
+ double fish[row], fish2[row];
+ for(i=0;i<row;i++){
+ fish[i]=0;
+ fish2[i]=0;}
+
+ for(i=0;i<row;i++){
+
+ for(j=0;j<g-1;j++){
+ fish[i]=fish[i]+matrix[i][j];
+ }
+
+ for(j=g-1;j<col;j++){
+ fish2[i]=fish2[i]+matrix[i][j];
+ }
+
+ double f11,f12,f21,f22;
+
+ f11=fish[i];
+ f12=fish2[i];
+
+ f21=total1-f11;
+ f22=total2-f12;
+
+ double data[] = {f11, f12, f21, f22};
+
+ // CONTINGENGCY TABLE:
+ // f11 f12
+ // f21 f22
+
+ int *nr, *nc, *ldtabl, *work;
+ int nrow=2, ncol=2, ldtable=2, workspace=100000;
+ double *expect, *prc, *emin,*prt,*pre;
+ double e=0, prc1=0, emin1=0, prt1=0, pre1=0;
+
+ nr = &nrow;
+ nc = &ncol;
+ ldtabl=&ldtable;
+ work = &workspace;
+
+ expect = &e;
+ prc = &prc1;
+ emin=&emin1;
+ prt=&prt1;
+ pre=&pre1;
+
+ //MothurFisher fishtere;
+ //double mothurFex = fishtere.fexact(f11, f12, f21, f22);
+
+ fexact(nr,nc,data, ldtabl,expect,prc,emin,prt,pre,work);
+
+ if (*pre>.999999999){
+ *pre=1;
+ }
+
+ //printf("feaxt = %f\t%f\t%f\t%f\t%f\t%f\n", *expect, *pre, f11, f12, f21, f22);
+ storage[i][8] = *pre;
+ pvalues[i]=*pre;
+ }