Delete unneeded directory
[jabaws.git] / website / archive / binaries / mac / src / mafft / core / MSalignmm.c.algLargeA
diff --git a/website/archive/binaries/mac/src/mafft/core/MSalignmm.c.algLargeA b/website/archive/binaries/mac/src/mafft/core/MSalignmm.c.algLargeA
deleted file mode 100644 (file)
index fd77355..0000000
+++ /dev/null
@@ -1,1461 +0,0 @@
-#include "mltaln.h"
-#include "dp.h"
-
-#define DEBUG 0
-#define XXXXXXX    0
-#define USE_PENALTY_EX  0
-#define STOREWM 0
-
-#define DPTANNI 1000
-
-
-static reccycle = 0;
-
-static void OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len )
-{
-       int i, j, gc, gb; 
-       float feff;
-       
-       for( i=0; i<len; i++ ) ogcp[i] = 0.0;
-       for( j=0; j<clus; j++ ) 
-       {
-               feff = (float)eff[j];
-               gc = 0;
-//             gc = ( gappat[j] == '-' );
-               for( i=0; i<len; i++ ) 
-               {
-                       gb = gc;
-                       gc = ( seq[j][i] == '-' );
-                       {
-                               if( !gb *  gc ) ogcp[i] += feff;
-                       }
-               }
-       }
-//     for( i=0; i<len; i++ ) 
-//     {
-//             fprintf( stderr, "ogcp[%d] = %30.20f\n", i, ogcp[i] );
-//     }
-}
-
-static void FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len )
-{
-       int i, j, gc, gb; 
-       float feff;
-       
-       for( i=0; i<len; i++ ) fgcp[i] = 0.0;
-       for( j=0; j<clus; j++ ) 
-       {
-               feff = (float)eff[j];
-//             gc = ( seq[j][0] == '-' );
-               gc = 0;
-               for( i=1; i<len; i++ ) 
-               {
-                       gb = gc;
-                       gc = ( seq[j][i] == '-' );
-                       {
-                               if( gb * !gc ) 
-                               {
-                                       fgcp[i-1] += feff;
-                               }
-                       }
-               }
-               {
-                       gb = gc;
-                       gc = 0;
-                       {
-//                             fprintf( stderr, "changed gc=%d, gb=%d\n", gc, gb );
-                               if( gb * !gc ) fgcp[i-1] += feff;
-                       }
-               }
-//             fprintf( stderr, "eff[%d] = %30.20f\n", j, eff[j] );
-       }
-//     for( i=0; i<len; i++ ) 
-//     {
-//             fprintf( stderr, "fgcp[%d] = %30.20f\n", i, fgcp[i] );
-//     }
-}
-
-static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
-{
-       int j, k, l;
-       float scarr[26];
-       float **cpmxpd = floatwork;
-       int **cpmxpdn = intwork;
-       int count = 0;
-
-       if( initialize )
-       {
-               for( j=0; j<lgth2; j++ )
-               {
-                       count = 0;
-                       for( l=0; l<26; l++ )
-                       {
-                               if( cpmx2[j][l] )
-                               {
-                                       cpmxpd[j][count] = cpmx2[j][l];
-                                       cpmxpdn[j][count] = l;
-                                       count++;
-                               }
-                       }
-                       cpmxpdn[j][count] = -1;
-               }
-       }
-
-       for( l=0; l<26; l++ )
-       {
-               scarr[l] = 0.0;
-               for( k=0; k<26; k++ )
-               {
-                       scarr[l] += n_dis[k][l] * cpmx1[i1][k];
-               }
-       }
-#if 0 /* ¤³¤ì¤ò»È¤¦¤È¤\ad¤Ïfloatwork¤Î¥¢¥í¥±¡¼¥È¤òµÕ¤Ë¤¹¤ë */
-       {
-               float *fpt, **fptpt, *fpt2;
-               int *ipt, **iptpt;
-               fpt2 = match;
-               iptpt = cpmxpdn;
-               fptpt = cpmxpd;
-               while( lgth2-- )
-               {
-                       *fpt2 = 0.0;
-                       ipt=*iptpt,fpt=*fptpt;
-                       while( *ipt > -1 )
-                               *fpt2 += scarr[*ipt++] * *fpt++;
-                       fpt2++,iptpt++,fptpt++;
-               } 
-       }
-#else
-       for( j=0; j<lgth2; j++ )
-       {
-               match[j] = 0.0;
-               for( k=0; cpmxpdn[j][k]>-1; k++ )
-                       match[j] += scarr[cpmxpdn[j][k]] * cpmxpd[j][k];
-       } 
-#endif
-}
-
-static float Atracking( 
-                                               char **seq1, char **seq2, 
-                        char **mseq1, char **mseq2, 
-                        short **ijp, int icyc, int jcyc,
-                                               int ist, int ien, int jst, int jen )
-{
-       int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, klim;
-       char gap[] = "-";
-       float wm;
-       lgth1 = ien-ist+1;
-       lgth2 = jen-jst+1;
-
-#if 0
-       for( i=0; i<lgth1; i++ ) 
-       {
-               fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
-       }
-#endif
-
-
-//     fprintf( stderr, "in Atracking, lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
-    for( i=0; i<lgth1+1; i++ ) 
-    {
-        ijp[i][0] = i + 1;
-    }
-    for( j=0; j<lgth2+1; j++ ) 
-    {
-        ijp[0][j] = -( j + 1 );
-    }
-
-
-       for( i=0; i<icyc; i++ )
-       {
-               mseq1[i] += lgth1+lgth2;
-               *mseq1[i] = 0;
-       }
-       for( j=0; j<jcyc; j++ )
-       {
-               mseq2[j] += lgth1+lgth2;
-               *mseq2[j] = 0;
-       }
-
-//     if( lgth2 == 1 ) fprintf( stderr, "in Atracking, mseq1 = %s, mseq2 = %s\n", mseq1[0], mseq2[0] );
-
-       iin = lgth1; jin = lgth2;
-       klim = lgth1+lgth2;
-       for( k=0; k<=klim; k++ ) 
-       {
-               if( ijp[iin][jin] < 0 ) 
-               {
-                       ifi = iin-1; jfi = jin+ijp[iin][jin];
-               }
-               else if( ijp[iin][jin] > 0 )
-               {
-                       ifi = iin-ijp[iin][jin]; jfi = jin-1;
-               }
-               else
-               {
-                       ifi = iin-1; jfi = jin-1;
-               }
-               l = iin - ifi;
-               while( --l ) 
-               {
-                       for( i=0; i<icyc; i++ )
-                               *--mseq1[i] = seq1[i][ist+ifi+l];
-                       for( j=0; j<jcyc; j++ ) 
-                               *--mseq2[j] = *gap;
-                       k++;
-               }
-               l= jin - jfi;
-               while( --l )
-               {
-                       for( i=0; i<icyc; i++ ) 
-                               *--mseq1[i] = *gap;
-                       for( j=0; j<jcyc; j++ ) 
-                               *--mseq2[j] = seq2[j][jst+jfi+l];
-                       k++;
-               }
-               if( iin <= 0 || jin <= 0 ) break;
-               for( i=0; i<icyc; i++ ) 
-                       *--mseq1[i] = seq1[i][ist+ifi];
-               for( j=0; j<jcyc; j++ ) 
-                       *--mseq2[j] = seq2[j][jst+jfi];
-               k++;
-               iin = ifi; jin = jfi;
-
-//             if( lgth2 == 1 ) fprintf( stderr, "in Atracking, mseq1 = %s, mseq2 = %s\n", mseq1[0], mseq2[0] );
-       }
-//     fprintf( stderr, "in Atracking (owari), mseq1 = %s\n", mseq1[0] );
-//     fprintf( stderr, "in Atracking (owari), mseq2 = %s\n", mseq2[0] );
-       return( 0.0 );
-}
-
-static float MSalignmm_tanni( int icyc, int jcyc, double *eff1, double *eff2, char **seq1, char **seq2, float **cpmx1, float **cpmx2, int ist, int ien, int jst, int jen, int alloclen, char **mseq1, char **mseq2, float **gapinfo )
-/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
-{
-//     int k;
-       register int i, j;
-       int ll1, ll2;
-       int lasti, lastj;
-       int resultlen;
-       float wm;   /* int ?????? */
-       float g;
-       float *currentw, *previousw;
-       float fpenalty = (float)penalty;
-       float fpenalty_ex = (float)penalty_ex;
-#if 1
-       float *wtmp;
-       short *ijppt;
-       float *mjpt, *prept, *curpt;
-       int *mpjpt;
-#endif
-       float mi, *m;
-       short **ijp;
-       int mpi, *mp;
-       float *w1, *w2;
-       float *initverticalw;    /* kufuu sureba iranai */
-       float *lastverticalw;    /* kufuu sureba iranai */
-       int **intwork;
-       float **floatwork;
-       short **shortmtx;
-       float dumfl;
-       int lgth1, lgth2;
-       float *ogcp1;
-       float *fgcp1;
-       float *ogcp2;
-       float *fgcp2;
-       char **aseq1;
-       char **aseq2;
-       char **aseq1bk, **aseq2bk;
-
-       ogcp1 = gapinfo[0] + ist;
-       fgcp1 = gapinfo[1] + ist;
-       ogcp2 = gapinfo[2] + jst;
-       fgcp2 = gapinfo[3] + jst;
-
-#if STOREWM
-       char ttt1[10000], ttt2[10000];
-#endif
-
-
-       lgth1 = ien-ist+1;
-       lgth2 = jen-jst+1;
-
-#if STOREWM
-       strncpy( ttt1, seq1[0]+ist, lgth1 ); ttt1[lgth1] = 0;
-       strncpy( ttt2, seq2[0]+jst, lgth2 ); ttt2[lgth2] = 0;
-
-       fprintf( stderr, "in _tanni ist,ien = %d,%d, lgth1=%d\n", ist, ien, lgth1 );
-       fprintf( stderr, "in _tanni jst,jen = %d,%d, lgth2=%d\n", jst, jen, lgth2 );
-       fprintf( stderr, "ttt1 = %s\n", ttt1 );
-       fprintf( stderr, "ttt2 = %s\n", ttt2 );
-#endif
-
-
-       ll1 = ( (int)(1.3*lgth1) ) + 100;
-       ll2 = ( (int)(1.3*lgth2) ) + 100;
-
-       aseq1 = AllocateCharMtx( icyc, 0 );
-       aseq2 = AllocateCharMtx( jcyc, 0 );
-       aseq1bk = AllocateCharMtx( icyc, lgth1+lgth2+100 );
-       aseq2bk = AllocateCharMtx( jcyc, lgth1+lgth2+100 );
-       for( i=0; i<icyc; i++ ) aseq1[i] = aseq1bk[i];
-       for( i=0; i<jcyc; i++ ) aseq2[i] = aseq2bk[i];
-
-       w1 = AllocateFloatVec( ll2+2 );
-       w2 = AllocateFloatVec( ll2+2 );
-
-       initverticalw = AllocateFloatVec( ll1+2 );
-       lastverticalw = AllocateFloatVec( ll1+2 );
-
-       m = AllocateFloatVec( ll2+2 );
-       mp = AllocateIntVec( ll2+2 );
-
-       floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 27 ); 
-       intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
-
-
-       shortmtx = AllocateShortMtx( ll1+1, ll2+1 );
-
-       ijp = shortmtx;
-
-       currentw = w1;
-       previousw = w2;
-
-       match_calc( initverticalw, cpmx2+jst, cpmx1+ist, 0, lgth1, floatwork, intwork, 1 );
-
-       match_calc( currentw, cpmx1+ist, cpmx2+jst, 0, lgth2, floatwork, intwork, 1 );
-
-       for( i=1; i<lgth1+1; i++ )
-       {
-               initverticalw[i] += fpenalty * ( ogcp1[0] + fgcp1[i-1] );
-       }
-       for( j=1; j<lgth2+1; j++ )
-       {
-               currentw[j] += fpenalty * ( ogcp2[0] + fgcp2[j-1] );
-       }
-
-       for( j=1; j<lgth2+1; ++j ) 
-       {
-               m[j] = currentw[j-1] + fpenalty * ogcp1[1]; mp[j] = 0;;
-       }
-
-       lastverticalw[0] = currentw[lgth2-1];
-
-
-
-       lasti = lgth1+1;
-       for( i=1; i<lasti; i++ )
-       {
-
-               wtmp = previousw; 
-               previousw = currentw;
-               currentw = wtmp;
-
-               previousw[0] = initverticalw[i-1];
-
-               match_calc( currentw, cpmx1+ist, cpmx2+jst, i, lgth2, floatwork, intwork, 0 );
-               currentw[0] = initverticalw[i];
-
-               mi = previousw[0] + fpenalty * ogcp2[1]; 
-               mpi = 0;
-
-               ijppt = ijp[i] + 1;
-               mjpt = m + 1;
-               prept = previousw;
-               curpt = currentw + 1;
-               mpjpt = mp + 1;
-               lastj = lgth2+1;
-               for( j=1; j<lastj; j++ )
-               {
-                       wm = *prept;
-                       *ijppt = 0;
-
-#if 0
-                       fprintf( stderr, "%5.0f->", wm );
-#endif
-                       g = mi + fpenalty * fgcp2[j-1];
-#if 0
-                       fprintf( stderr, "%5.0f?", g );
-#endif
-                       if( g > wm )
-                       {
-                               wm = g;
-                               *ijppt = -( j - mpi );
-                       }
-                       g = *prept + fpenalty * ogcp2[j];
-                       if( g >= mi )
-                       {
-                               mi = g;
-                               mpi = j-1;
-                       }
-#if USE_PENALTY_EX
-                       mi += fpenalty_ex;
-#endif
-
-                       g = *mjpt + fpenalty * fgcp1[i-1];
-#if 0 
-                       fprintf( stderr, "%5.0f?", g );
-#endif
-                       if( g > wm )
-                       {
-                               wm = g;
-                               *ijppt = +( i - *mpjpt );
-                       }
-                       g = *prept + fpenalty * ogcp1[i];
-                       if( g >= *mjpt )
-                       {
-                               *mjpt = g;
-                               *mpjpt = i-1;
-                       }
-#if USE_PENALTY_EX
-                       m[j] += fpenalty_ex;
-#endif
-
-#if 0
-                       fprintf( stderr, "%5.0f ", wm );
-#endif
-                       *curpt += wm;
-
-
-                       ijppt++;
-                       mjpt++;
-                       prept++;
-                       mpjpt++;
-                       curpt++;
-               }
-               lastverticalw[i] = currentw[lgth2-1];
-       }
-
-//     fprintf( stderr, "wm = %f\n", wm );
-
-       Atracking( seq1, seq2, aseq1, aseq2, ijp, icyc, jcyc, ist, ien, jst, jen );
-
-       for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
-       for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
-
-//     fprintf( stderr, "in _tanni, aseq1 = %s\n", aseq1[0] );
-//     fprintf( stderr, "in _tanni, mseq1 = %s\n", mseq1[0] );
-
-       FreeFloatVec( w1 );
-       FreeFloatVec( w2 );
-       FreeFloatVec( initverticalw );
-       FreeFloatVec( lastverticalw );
-
-       FreeFloatVec( m );
-       FreeIntVec( mp );
-
-
-       FreeFloatMtx( floatwork );
-       FreeIntMtx( intwork );
-
-       FreeShortMtx( shortmtx );
-
-       FreeCharMtx( aseq1bk );
-       FreeCharMtx( aseq2bk );
-
-       free( aseq1 );
-       free( aseq2 );
-
-       return( wm );
-
-}
-
-static float MSalignmm_rec( int icyc, int jcyc, double *eff1, double *eff2, char **seq1, char **seq2, float **cpmx1, float **cpmx2, int ist, int ien, int jst, int jen, int alloclen, char **mseq1, char **mseq2, int depth, float **gapinfo )
-/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
-{
-//     int k;
-       float value = 0.0;
-       register int i, j;
-       char **aseq1, **aseq2;
-       int ll1, ll2, l, len;
-       int lasti, lastj, imid, jmid;
-       int resultlen;
-       float wm;   /* int ?????? */
-       float g;
-       float *currentw, *previousw;
-       float fpenalty = (float)penalty;
-       float fpenalty_ex = (float)penalty_ex;
-       float *wtmp;
-//     short *ijppt;
-       int *mpjpt;
-//     short **ijp;
-       int *mp;
-       int mpi;
-       float *mjpt, *prept, *curpt;
-       float mi;
-       float *m;
-       float *w1, *w2;
-//     float *match;
-       float *initverticalw;    /* kufuu sureba iranai */
-       float *lastverticalw;    /* kufuu sureba iranai */
-       int **intwork;
-       float **floatwork;
-//     short **shortmtx;
-#if STOREWM
-       float **WMMTX;
-       float **WMMTX2;
-#endif
-       float *midw;
-       float *midm;
-       float *midn;
-       float dumfl;
-       int lgth1, lgth2;
-       float maxwm;
-       int *jumpforwi;
-       int *jumpforwj;
-       int *jumpbacki;
-       int *jumpbackj;
-       int *jumpdummi; //muda
-       int *jumpdummj; //muda
-       int jumpi, jumpj;
-       char *gaps;
-       int ijpi, ijpj;
-       float *ogcp1;
-       float *fgcp1;
-       float *ogcp2;
-       float *fgcp2;
-       float firstm;
-       int firstmp;
-#if STOREWM
-       static char ttt1[50000];
-       static char ttt2[50000];
-#endif
-
-       ogcp1 = gapinfo[0] + ist;
-       fgcp1 = gapinfo[1] + ist;
-       ogcp2 = gapinfo[2] + jst;
-       fgcp2 = gapinfo[3] + jst;
-
-       depth++;
-       reccycle++;
-
-       lgth1 = ien-ist+1;
-       lgth2 = jen-jst+1;
-
-
-#if STOREWM
-       fprintf( stderr, "==== MSalign (depth=%d, reccycle=%d), ist=%d, ien=%d, jst=%d, jen=%d\n", depth, reccycle, ist, ien, jst, jen );
-       strncpy( ttt1, seq1[0]+ist, lgth1 );
-       strncpy( ttt2, seq2[0]+jst, lgth2 );
-       ttt1[lgth1] = 0;
-       ttt2[lgth2] = 0;
-       fprintf( stderr, "seq1 = %s\n", ttt1 );
-       fprintf( stderr, "seq2 = %s\n", ttt2 );
-#endif
-       if( lgth2 <= 0 ) // lgth1 <= 0 ha?
-       {
-               fprintf( stderr, "\n\n==== jimei\n\n" );
-//             exit( 1 );
-               for( i=0; i<icyc; i++ ) 
-               {
-                       strncpy( mseq1[i], seq1[i]+ist, lgth1 );
-                       mseq1[i][lgth1] = 0;
-               }
-               for( i=0; i<jcyc; i++ ) 
-               {
-                       mseq2[i][0] = 0;
-                       for( j=0; j<lgth1; j++ )
-                               strcat( mseq2[i], "-" );
-               }
-
-               fprintf( stderr, "==== mseq1[0] (%d) = %s\n", depth, mseq1[0] );
-               fprintf( stderr, "==== mseq2[0] (%d) = %s\n", depth, mseq2[0] );
-
-               return( 0.0 );
-       }
-
-       aseq1 = AllocateCharMtx( icyc, lgth1+lgth2+100 );
-       aseq2 = AllocateCharMtx( jcyc, lgth1+lgth2+100 );
-
-       if( lgth1 < DPTANNI || lgth2 < DPTANNI )
-       {
-//             fprintf( stderr, "==== Going to _tanni\n" );
-
-               value = MSalignmm_tanni( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist, ien, jst, jen, alloclen, aseq1, aseq2, gapinfo );       
-
-
-               for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
-               for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
-
-//             fprintf( stderr, "==== mseq1[0] (%d) = %s\n", depth, mseq1[0] );
-//             fprintf( stderr, "==== mseq2[0] (%d) = %s\n", depth, mseq2[0] );
-
-//             fprintf( stderr, "freeing aseq\n" );
-               FreeCharMtx( aseq1 );
-               FreeCharMtx( aseq2 );
-
-//             fprintf( stderr, "value = %f\n", value );
-
-               return( value );
-       }
-//     fprintf( stderr, "Trying to divide the mtx\n" );
-
-       ll1 = ( (int)(1.3*lgth1) ) + 100;
-       ll2 = ( (int)(1.3*lgth2) ) + 100;
-
-//     fprintf( stderr, "ll1,ll2=%d,%d\n", ll1, ll2 );
-
-       w1 = AllocateFloatVec( ll2+2 );
-       w2 = AllocateFloatVec( ll2+2 );
-//     match = AllocateFloatVec( ll2+2 );
-       midw = AllocateFloatVec( ll2+2 );
-       midn = AllocateFloatVec( ll2+2 );
-       midm = AllocateFloatVec( ll2+2 );
-       jumpbacki = AllocateIntVec( ll2+2 );
-       jumpbackj = AllocateIntVec( ll2+2 );
-       jumpforwi = AllocateIntVec( ll2+2 );
-       jumpforwj = AllocateIntVec( ll2+2 );
-       jumpdummi = AllocateIntVec( ll2+2 );
-       jumpdummj = AllocateIntVec( ll2+2 );
-
-       initverticalw = AllocateFloatVec( ll1+2 );
-       lastverticalw = AllocateFloatVec( ll1+2 );
-
-       m = AllocateFloatVec( ll2+2 );
-       mp = AllocateIntVec( ll2+2 );
-       gaps = AllocateCharVec( MAX( ll1, ll2 ) + 2 );
-
-       floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
-       intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 26 ); 
-
-#if DEBUG
-       fprintf( stderr, "succeeded\n" );
-#endif
-
-#if STOREWM
-       WMMTX = AllocateFloatMtx( ll1, ll2 );
-       WMMTX2 = AllocateFloatMtx( ll1, ll2 );
-#endif
-#if 0
-       shortmtx = AllocateShortMtx( ll1, ll2 );
-
-#if DEBUG
-       fprintf( stderr, "succeeded\n\n" );
-#endif
-
-       ijp = shortmtx;
-#endif
-
-       currentw = w1;
-       previousw = w2;
-
-       match_calc( initverticalw, cpmx2+jst, cpmx1+ist, 0, lgth1, floatwork, intwork, 1 );
-
-       match_calc( currentw, cpmx1+ist, cpmx2+jst, 0, lgth2, floatwork, intwork, 1 );
-
-       for( i=1; i<lgth1+1; i++ )
-       {
-               initverticalw[i] += fpenalty  * ( ogcp1[0] + fgcp1[i-1] );
-//             initverticalw[i] += fpenalty;
-       }
-       for( j=1; j<lgth2+1; j++ )
-       {
-               currentw[j] += fpenalty * ( ogcp2[0] + fgcp2[j-1] );
-//             currentw[j] += fpenalty;
-       }
-
-#if STOREWM
-       WMMTX[0][0] = initverticalw[0];
-       for( i=1; i<lgth1+1; i++ )
-       {
-               WMMTX[i][0] = initverticalw[i];
-       }
-       for( j=1; j<lgth2+1; j++ )
-       {
-               WMMTX[0][j] = currentw[j];
-       }
-#endif
-
-
-       for( j=1; j<lgth2+1; ++j ) 
-       {
-               m[j] = currentw[j-1] + fpenalty * ogcp1[1];
-//             m[j] = currentw[j-1];
-               mp[j] = 0;
-       }
-
-       lastverticalw[0] = currentw[lgth2-1];
-
-       imid = lgth1 * 0.5;
-
-       jumpi = 0; // atode kawaru.
-       lasti = lgth1+1;
-#if STOREWM
-       for( i=1; i<lasti; i++ )
-#else
-       for( i=1; i<=imid; i++ )
-#endif
-       {
-               wtmp = previousw; 
-               previousw = currentw;
-               currentw = wtmp;
-
-               previousw[0] = initverticalw[i-1];
-
-               match_calc( currentw, cpmx1+ist, cpmx2+jst, i, lgth2, floatwork, intwork, 0 );
-               currentw[0] = initverticalw[i];
-
-               m[0] = fpenalty * ogcp1[i];
-#if STOREM
-               WMMTX2[i][0] = m[0];
-#endif
-               if( i == imid ) midm[0] = m[0];
-
-               mi = previousw[0] + fpenalty * ogcp2[1]; 
-//             mi = previousw[0];
-               mpi = 0;
-
-
-//             ijppt = ijp[i] + 1;
-               mjpt = m + 1;
-               prept = previousw;
-               curpt = currentw + 1;
-               mpjpt = mp + 1;
-
-
-               lastj = lgth2+1;
-               for( j=1; j<lastj; j++ )
-               {
-
-                       wm = *prept;
-
-#if 0
-                       fprintf( stderr, "%5.0f->", wm );
-#endif
-                       g = mi + fpenalty * fgcp2[j-1];
-//                     g = mi + fpenalty;
-#if 0
-                       fprintf( stderr, "%5.0f?", g );
-#endif
-                       if( g > wm )
-                       {
-                               wm = g;
-//                             *ijppt = -( j - mpi );
-                       }
-                       g = *prept + fpenalty * ogcp2[j];
-//                     g = *prept;
-                       if( g >= mi )
-                       {
-                               mi = g;
-                               mpi = j-1;
-                       }
-#if USE_PENALTY_EX
-                       mi += fpenalty_ex;
-#endif
-
-                       g = *mjpt + fpenalty  * fgcp1[i-1];
-//                     g = *mjpt + fpenalty;
-#if 0 
-                       fprintf( stderr, "%5.0f?", g );
-#endif
-                       if( g > wm )
-                       {
-                               wm = g;
-//                             *ijppt = +( i - *mpjpt );
-                       }
-
-
-                       g = *prept + fpenalty * ogcp1[i];
-//                     g = *prept;
-                       if( g >= *mjpt )
-                       {
-                               *mjpt = g;
-                               *mpjpt = i-1;
-                       }
-#if USE_PENALTY_EX
-                       m[j] += fpenalty_ex;
-#endif
-
-#if 0
-                       fprintf( stderr, "%5.0f ", wm );
-#endif
-                       *curpt += wm;
-
-#if STOREWM
-                       WMMTX[i][j] = *curpt;
-                       WMMTX2[i][j] = *mjpt;
-#endif
-
-                       if( i == imid ) //muda
-                       {       
-                               jumpbackj[j] = *mpjpt; // muda atode matomeru
-                               jumpbacki[j] = mpi; // muda atode matomeru
-//                             fprintf( stderr, "jumpbackj[%d] in forward dp is %d\n", j, *mpjpt );
-//                             fprintf( stderr, "jumpbacki[%d] in forward dp is %d\n", j, mpi );
-                               midw[j] = *curpt;
-                               midm[j] = *mjpt;
-                               midn[j] = mi;
-                       }
-
-//                     fprintf( stderr, "m[%d] = %f\n", j, m[j] );
-                       mjpt++;
-                       prept++;
-                       mpjpt++;
-                       curpt++;
-
-               }
-               lastverticalw[i] = currentw[lgth2-1];
-
-#if STOREWM
-               WMMTX2[i][lgth2] = m[lgth2-1];
-#endif
-
-#if 0  // ue
-               if( i == imid )
-               {
-                       for( j=0; j<lgth2; j++ ) midw[j] = currentw[j];
-                       for( j=0; j<lgth2; j++ ) midm[j] = m[j];
-               }
-#endif
-       }
-//     for( j=0; j<lgth2; j++ ) midw[j] = WMMTX[imid][j];
-//     for( j=0; j<lgth2; j++ ) midm[j] = WMMTX2[imid][j];
-
-#if 0
-    for( i=0; i<lgth1; i++ )
-    {
-        for( j=0; j<lgth2; j++ )
-        {
-            fprintf( stderr, "% 10.2f ", WMMTX[i][j] );
-        }
-        fprintf( stderr, "\n" );
-    }
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "WMMTX2 = \n" );
-    for( i=0; i<lgth1; i++ )
-    {
-        for( j=0; j<lgth2; j++ )
-        {
-            fprintf( stderr, "% 10.2f ", WMMTX2[i][j] );
-        }
-        fprintf( stderr, "\n" );
-    }
-       fprintf( stderr, "\n" );
-#endif
-
-// gyakudp
-
-       match_calc( initverticalw, cpmx2+jst, cpmx1+ist, lgth2-1, lgth1, floatwork, intwork, 1 );
-       match_calc( currentw, cpmx1+ist, cpmx2+jst, lgth1-1, lgth2, floatwork, intwork, 1 );
-
-       for( i=0; i<lgth1-1; i++ )
-       {
-               initverticalw[i] += fpenalty * ( fgcp1[lgth1-1] + ogcp1[i+1] );
-//             initverticalw[i] += fpenalty;
-       }
-       for( j=0; j<lgth2-1; j++ )
-       {
-               currentw[j] += fpenalty * ( fgcp2[lgth2-1] + ogcp2[j+1] );
-//             currentw[j] += fpenalty;
-       }
-
-#if STOREWM
-       for( i=0; i<lgth1-1; i++ )
-       {
-               WMMTX[i][lgth2-1] += fpenalty * ( fgcp1[lgth1-1] + ogcp1[i+1] );
-               fprintf( stderr, "fgcp1[lgth1-1] + ogcp1[i+1] = %f\n", fgcp1[lgth1-1] + ogcp1[i+1] );
-       }
-       for( j=0; j<lgth2-1; j++ )
-       {
-               WMMTX[lgth1-1][j] += fpenalty * ( fgcp2[lgth2-1] + ogcp2[j+1] );
-               fprintf( stderr, "fgcp2[lgth2-1] + ogcp2[j+1] = %f\n", fgcp2[lgth2-1] + ogcp2[j+1] );
-       }
-#endif
-
-
-
-
-
-
-       for( j=lgth2-1; j>0; --j )
-       {
-               m[j-1] = currentw[j] + fpenalty * fgcp2[lgth2-2];
-//             m[j-1] = currentw[j];
-               mp[j] = lgth1-1;
-       }
-
-//     for( j=0; j<lgth2; j++ ) m[j] = 0.0;
-       // m[lgth2-1] ha irunoka?
-
-
-//     for( i=lgth1-2; i>=imid; i-- )
-       firstm = -9999999.9;
-       firstmp = lgth1-1;
-       for( i=lgth1-2; i>-1; i-- )
-       {
-               wtmp = previousw;
-               previousw = currentw;
-               currentw = wtmp;
-               previousw[lgth2-1] = initverticalw[i+1];
-//             match_calc( currentw, seq1, seq2, i, lgth2 );
-               match_calc( currentw, cpmx1+ist, cpmx2+jst, i, lgth2, floatwork, intwork, 0 );
-
-               currentw[lgth2-1] = initverticalw[i];
-
-//             m[lgth2] = fpenalty * fgcp1[i];
-//             WMMTX2[i][lgth2] += m[lgth2];
-//             fprintf( stderr, "m[] = %f\n", m[lgth2] );
-
-               mi = previousw[lgth2-1] + fpenalty * fgcp2[lgth2-2];
-//             mi = previousw[lgth2-1];
-               mpi = lgth2 - 1;
-
-               mjpt = m + lgth2 - 2;
-               prept = previousw + lgth2 - 1;
-               curpt = currentw + lgth2 - 2;
-               mpjpt = mp + lgth2 - 2;
-
-
-               for( j=lgth2-2; j>-1; j-- )
-               {
-                       wm = *prept;
-                       ijpi = i+1;
-                       ijpj = j+1;
-
-                       g = mi + fpenalty * ogcp2[j+1];
-//                     g = mi + fpenalty;
-                       if( g > wm )
-                       {
-                               wm = g;
-                               ijpj = mpi;
-                               ijpi = i+1;
-                       }
-
-                       g = *prept + fpenalty * fgcp2[j];
-//                     g = *prept;
-                       if( g >= mi )
-                       {
-//                             fprintf( stderr, "i,j=%d,%d - renewed! mpi = %d\n", i, j, j+1 );
-                               mi = g;
-                               mpi = j + 1;
-                       }
-
-#if USE_PENALTY_EX
-                       mi += fpenalty_ex;
-#endif
-
-//                     fprintf( stderr, "i,j=%d,%d *mpjpt = %d\n", i, j, *mpjpt );
-                       g = *mjpt + fpenalty * ogcp1[i+1];
-//                     g = *mjpt + fpenalty;
-                       if( g > wm )
-                       {
-                               wm = g;
-                               ijpi = *mpjpt;
-                               ijpj = j+1;
-                       }
-
-//                     if( i == imid )fprintf( stderr, "i,j=%d,%d \n", i, j );
-                       g = *prept + fpenalty * fgcp1[i];
-//                     g = *prept;
-                       if( g >= *mjpt )
-                       {
-                               *mjpt = g;
-                               *mpjpt = i + 1;
-                       }
-
-#if USE_PENALTY_EX
-                       m[j] += fpenalty_ex;
-#endif
-
-                       if( i == jumpi || i == imid - 1 )
-                       {
-                               jumpforwi[j] = ijpi; //muda
-                               jumpforwj[j] = ijpj; //muda
-//                             fprintf( stderr, "jumpfori[%d] = %d\n", j, ijpi );
-//                             fprintf( stderr, "jumpforj[%d] = %d\n", j, ijpj );
-                       }
-                       if( i == imid ) // muda
-                       {
-                               midw[j] += wm;
-//                             midm[j+1] += *mjpt + fpenalty; //??????
-                               midm[j+1] += *mjpt; //??????
-                       }
-                       if( i == imid - 1 )
-                       {
-//                             midn[j] += mi + fpenalty;  //????
-                               midn[j] += mi;  //????
-                       }
-#if STOREWM
-                       WMMTX[i][j] += wm;
-//                     WMMTX2[i][j+1] += *mjpt + fpenalty;
-                       WMMTX2[i][j+1] += *mjpt;
-#endif
-                       *curpt += wm;
-
-                       mjpt--;
-                       prept--;
-                       mpjpt--;
-                       curpt--;
-               }
-//             fprintf( stderr, "adding *mjpt (=%f) to WMMTX2[%d][%d]\n", *mjpt, i, j+1 );
-               g = *prept + fpenalty * fgcp1[i];
-               if( firstm < g ) 
-               {
-                       firstm = g;
-                       firstmp = i + 1;
-               }
-#if STOREWM
-               WMMTX2[i][j+1] += firstm;
-#endif
-               if( i == imid ) midm[j+1] += firstm;
-
-               if( i == imid - 1 )     
-               {
-                       maxwm = midw[1];
-                       jmid = 0;
-//                     if( depth == 1 ) fprintf( stderr, "maxwm!! = %f\n", maxwm );
-                       for( j=2; j<lgth2-1; j++ )
-                       {
-                               wm = midw[j];
-                               if( wm > maxwm )
-                               {
-                                       jmid = j;
-                                       maxwm = wm;
-                               }
-//                             if( depth == 1 ) fprintf( stderr, "maxwm!! = %f\n", maxwm );
-                       }
-                       for( j=0; j<lgth2+1; j++ )
-                       {
-                               wm = midm[j];
-                               if( wm > maxwm )
-                               {
-                                       jmid = j;
-                                       maxwm = wm;
-                               }
-//                             if( depth == 1 ) fprintf( stderr, "maxwm!! = %f\n", maxwm );
-                       }
-
-//                     if( depth == 1 ) fprintf( stderr, "maxwm!! = %f\n", maxwm );
-
-
-//                     fprintf( stderr, "### imid=%d, jmid=%d\n", imid, jmid );
-                       wm = midw[jmid];
-                       jumpi = imid-1;
-                       jumpj = jmid-1;
-                       if( midn[jmid-1] > wm )
-                       {
-                               jumpi = imid-1;
-                               jumpj = jumpbacki[jmid];
-                               wm = midn[jmid-1];
-//                             fprintf( stderr, "rejump (n)\n" );
-                       }
-                       if( midm[jmid] > wm )
-                       {
-                               jumpi = jumpbackj[jmid];
-                               jumpj = jmid-1;
-                               wm = midm[jmid];
-//                             fprintf( stderr, "rejump (m) jumpi=%d\n", jumpi );
-                       }
-
-
-//                     fprintf( stderr, "--> imid=%d, jmid=%d\n", imid, jmid );
-//                     fprintf( stderr, "--> jumpi=%d, jumpj=%d\n", jumpi, jumpj );
-#if STOREWM
-                       fprintf( stderr, "imid = %d\n", imid );
-                       fprintf( stderr, "midn = \n" );
-                       for( j=0; j<lgth2; j++ )
-                       {
-                               fprintf( stderr, "% 7.1f ", midn[j] );
-                       }
-                       fprintf( stderr, "\n" );
-                       fprintf( stderr, "midw = \n" );
-                       for( j=0; j<lgth2; j++ )
-                       {
-                               fprintf( stderr, "% 7.1f ", midw[j] );
-                       }
-                       fprintf( stderr, "\n" );
-                       fprintf( stderr, "midm = \n" );
-                       for( j=0; j<lgth2; j++ )
-                       {
-                               fprintf( stderr, "% 7.1f ", midm[j] );
-                       }
-                       fprintf( stderr, "\n" );
-#endif
-//                     fprintf( stderr, "maxwm = %f\n", maxwm );
-               }
-               if( i == jumpi ) //saki?
-               {
-//                     fprintf( stderr, "imid, jumpi = %d,%d\n", imid, jumpi );
-//                     fprintf( stderr, "jmid, jumpj = %d,%d\n", jmid, jumpj );
-                       if( jmid == 0 )
-                       {
-//                             fprintf( stderr, "CHUI2!\n" );
-                               jumpj = 0; jmid = 1;
-                               jumpi = firstmp - 1;
-                               imid = firstmp;
-                       }
-                       else if( jmid == lgth2 )
-                       {
-//                             fprintf( stderr, "CHUI1!\n" );
-                               jumpi=0; jumpj=0;
-                               imid=jumpforwi[0]; jmid=lgth2-1;
-                       }
-                       else
-                       {
-                               imid = jumpforwi[jumpj];
-                               jmid = jumpforwj[jumpj];
-                       }
-#if 0
-                       fprintf( stderr, "jumpi -> %d\n", jumpi );
-                       fprintf( stderr, "jumpj -> %d\n", jumpj );
-                       fprintf( stderr, "imid -> %d\n", imid );
-                       fprintf( stderr, "jmid -> %d\n", jmid );
-#endif
-
-#if STOREWM
-                       break;
-#else
-                       break;
-#endif
-               }
-       }
-#if 0
-               jumpi=0; jumpj=0;
-               imid=lgth1-1; jmid=lgth2-1;
-       }
-#endif
-
-//     fprintf( stderr, "imid = %d, but jumpi = %d\n", imid, jumpi );
-//     fprintf( stderr, "jmid = %d, but jumpj = %d\n", jmid, jumpj );
-
-//     for( j=0; j<lgth2; j++ ) midw[j] += currentw[j];
-//     for( j=0; j<lgth2; j++ ) midm[j] += m[j+1];
-//     for( j=0; j<lgth2; j++ ) midw[j] += WMMTX[imid][j];
-//     for( j=0; j<lgth2; j++ ) midw[j] += WMMTX[imid][j];
-
-
-#if STOREWM
-       fprintf( stderr, "WMMTX = \n" );
-    for( i=0; i<lgth1; i++ )
-    {
-        fprintf( stderr, "%d ", i );
-        for( j=0; j<lgth2; j++ )
-        {
-            fprintf( stderr, "% 7.2f ", WMMTX[i][j] );
-        }
-        fprintf( stderr, "\n" );
-    }
-       fprintf( stderr, "WMMTX2 = (p = %f)\n", fpenalty );
-    for( i=0; i<lgth1; i++ )
-    {
-        fprintf( stderr, "%d ", i );
-        for( j=0; j<lgth2+1; j++ )
-        {
-            fprintf( stderr, "% 7.2f ", WMMTX2[i][j] );
-        }
-        fprintf( stderr, "\n" );
-    }
-
-       fprintf( stderr, "jumpbacki = \n" );
-       for( j=0; j<lgth2; j++ )
-       {
-               fprintf( stderr, "% 7d ", jumpbacki[j] );
-       }
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "jumpbackj = \n" );
-       for( j=0; j<lgth2; j++ )
-       {
-               fprintf( stderr, "% 7d ", jumpbackj[j] );
-       }
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "jumpforwi = \n" );
-       for( j=0; j<lgth2; j++ )
-       {
-               fprintf( stderr, "% 7d ", jumpforwi[j] );
-       }
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "jumpforwj = \n" );
-       for( j=0; j<lgth2; j++ )
-       {
-               fprintf( stderr, "% 7d ", jumpforwj[j] );
-       }
-       fprintf( stderr, "\n" );
-
-
-#endif
-
-
-//     Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
-
-#if 0 // irukamo
-       resultlen = strlen( mseq1[0] );
-       if( alloclen < resultlen || resultlen > N )
-       {
-               fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
-               ErrorExit( "LENGTH OVER!\n" );
-       }
-#endif
-
-
-
-#if 0
-       fprintf( stderr, "jumpi = %d, imid = %d\n", jumpi, imid );
-       fprintf( stderr, "jumpj = %d, jmid = %d\n", jumpj, jmid );
-
-       fprintf( stderr, "imid = %d\n", imid );
-       fprintf( stderr, "jmid = %d\n", jmid );
-#endif
-
-
-       FreeFloatVec( w1 );
-       FreeFloatVec( w2 );
-       FreeFloatVec( initverticalw );
-       FreeFloatVec( lastverticalw );
-       FreeFloatVec( midw );
-       FreeFloatVec( midm );
-       FreeFloatVec( midn );
-
-       FreeIntVec( jumpbacki );
-       FreeIntVec( jumpbackj );
-       FreeIntVec( jumpforwi );
-       FreeIntVec( jumpforwj );
-       FreeIntVec( jumpdummi );
-       FreeIntVec( jumpdummj );
-
-       FreeFloatVec( m );
-       FreeIntVec( mp );
-
-       FreeFloatMtx( floatwork );
-       FreeIntMtx( intwork );
-
-#if STOREWM
-       FreeFloatMtx( WMMTX );
-       FreeFloatMtx( WMMTX2 );
-#endif
-
-//     fprintf( stderr, "==== calling myself (first)\n" );
-
-//     fprintf( stderr, "jumpi = %d\n", jumpi );
-       value = MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist, ist+jumpi, jst, jst+jumpj, alloclen, aseq1, aseq2, depth, gapinfo );      
-       for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
-       for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
-
-//     fprintf( stderr, "====(f) aseq1[0] (%d) = %s (%d-%d)\n", depth, aseq1[0], ist, ien );
-//     fprintf( stderr, "====(f) aseq2[0] (%d) = %s (%d-%d)\n", depth, aseq2[0], jst, jen );
-
-       len = strlen( mseq1[0] );
-//     fprintf( stderr, "len = %d\n", len );
-       l = jmid - jumpj - 1;
-//     fprintf( stderr, "l=%d\n", l );
-       if( l > 0 )
-       {
-               for( i=0; i<l; i++ ) gaps[i] = '-'; gaps[i] = 0;
-               for( i=0; i<icyc; i++ ) 
-               {
-                       strcat( mseq1[i], gaps );
-                       mseq1[i][len+l] = 0;
-               }
-               for( j=0; j<jcyc; j++ )
-               {
-                       strncat( mseq2[j], seq2[j]+jst+jumpj+1, l );
-                       mseq2[j][len+l] = 0;
-               }
-//             fprintf( stderr, "penalizing (2) .. %f(%d), %f(%d)\n", ogcp2[jumpj+1], jumpj+1, fgcp2[jmid-1], jmid-1 );
-               value += fpenalty * ( ogcp2[jumpj+1] + fgcp2[jmid-1] );
-//             value += fpenalty;
-       }
-       len = strlen( mseq1[0] );
-       l = imid - jumpi - 1;
-//     fprintf( stderr, "l=%d\n", l );
-       if( l > 0 )
-       {
-               for( i=0; i<l; i++ ) gaps[i] = '-'; gaps[i] = 0;
-               for( i=0; i<icyc; i++ )
-               {
-                       strncat( mseq1[i], seq1[i]+ist+jumpi+1, l );
-                       mseq1[i][len+l] = 0;
-               }
-               for( j=0; j<jcyc; j++ ) 
-               {
-                       strcat( mseq2[j], gaps );
-                       mseq2[j][len+l] = 0;
-               }
-
-//             for( i=0; i<lgth1; i++ ) fprintf( stderr, "ogcp1[%d] = %f\n", i, ogcp1[i] );
-//             for( i=0; i<lgth1; i++ ) fprintf( stderr, "fgcp1[%d] = %f\n", i, fgcp1[i] );
-
-
-//             fprintf( stderr, "penalizing (1) .. ogcp1[%d] = %f, fgcp1[%d] = %f\n", jumpi+1, ogcp1[jumpi+1], imid-1, fgcp1[imid-1] );
-               value += fpenalty * ( ogcp1[jumpi+1] + fgcp1[imid-1] );
-//             value += fpenalty;
-       }
-#if 0
-       for( i=0; i<icyc; i++ ) fprintf( stderr, "after gapfill mseq1[%d]=%s\n", i, mseq1[i] );
-       for( i=0; i<jcyc; i++ ) fprintf( stderr, "after gapfill mseq2[%d]=%s\n", i, mseq2[i] );
-#endif
-
-//     fprintf( stderr, "==== calling myself (second)\n" );
-
-       value += MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist+imid, ien, jst+jmid, jen, alloclen, aseq1, aseq2, depth, gapinfo );       
-
-
-
-#if DEBUG
-       if( value - maxwm > 1 || maxwm - value > 1 )
-       {
-               fprintf( stderr, "WARNING value  = %f, but maxwm = %f penalty = %f\n", value, maxwm, fpenalty );
-               for( i=0; i<icyc; i++ )
-               {
-                       fprintf( stderr, ">1-%d\n%s\n", i, mseq1[i] );
-                       fprintf( stderr, "%s\n", aseq1[i] );
-               }
-               for( i=0; i<jcyc; i++ )
-               {
-                       fprintf( stderr, ">2-%d\n%s\n", i, mseq2[i] );
-                       fprintf( stderr, "%s\n", aseq2[i] );
-               }
-
-//             exit( 1 );
-       }
-       else
-       {
-               fprintf( stderr, "value = %.0f, maxwm = %.0f -> ok\n", value, maxwm );
-       }
-#endif
-
-       for( i=0; i<icyc; i++ ) strcat( mseq1[i], aseq1[i] );
-       for( i=0; i<jcyc; i++ ) strcat( mseq2[i], aseq2[i] );
-
-//     fprintf( stderr, "====(s) aseq1[0] (%d) = %s (%d-%d)\n", depth, aseq1[0], ist, ien );
-//     fprintf( stderr, "====(s) aseq2[0] (%d) = %s (%d-%d)\n", depth, aseq2[0], jst, jen );
-
-       free( gaps );
-       FreeCharMtx( aseq1 );
-       FreeCharMtx( aseq2 );
-       
-       return( value );
-}
-
-
-
-float MSalignmm( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen )
-/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
-{
-//     int k;
-       int i, j;
-       int ll1, ll2;
-       int lgth1, lgth2;
-       float wm;   /* int ?????? */
-       char **mseq1;
-       char **mseq2;
-       char **mseq;
-       float *ogcp1;
-       float *ogcp2;
-       float *fgcp1;
-       float *fgcp2;
-       float **cpmx1;
-       float **cpmx2;
-       float **gapinfo;
-
-#if 0
-       fprintf( stderr, "eff in SA+++align\n" );
-       for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
-#endif
-
-       lgth1 = strlen( seq1[0] );
-       lgth2 = strlen( seq2[0] );
-
-       ll1 = ( (int)(1.3*lgth1) ) + 100;
-       ll2 = ( (int)(1.3*lgth2) ) + 100;
-
-       mseq1 = AllocateCharMtx( icyc, ll1+ll2 );
-       mseq2 = AllocateCharMtx( jcyc, ll1+ll2 );
-
-       gapinfo = AllocateFloatMtx( 4, 0 );
-       ogcp1 = AllocateFloatVec( ll1+2 );
-       ogcp2 = AllocateFloatVec( ll2+2 );
-       fgcp1 = AllocateFloatVec( ll1+2 );
-       fgcp2 = AllocateFloatVec( ll2+2 );
-
-
-       cpmx1 = AllocateFloatMtx( ll1+2, 27 );
-       cpmx2 = AllocateFloatMtx( ll2+2, 27 );
-
-       for( i=0; i<icyc; i++ ) 
-       {
-               seq1[i][lgth1] = 0;
-       }
-       for( j=0; j<jcyc; j++ )
-       {
-               seq2[j][lgth2] = 0;
-       }
-
-       MScpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
-       MScpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
-
-
-#if 1
-
-       OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
-       OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
-       FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
-       FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
-
-#if 1
-       for( i=0; i<lgth1; i++ ) 
-       {
-               ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] );
-               fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] );
-//             fprintf( stderr, "fgcp1[%d] = %f\n", i, fgcp1[i] );
-       }
-       for( i=0; i<lgth2; i++ ) 
-       {
-               ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] );
-               fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] );
-//             fprintf( stderr, "fgcp2[%d] = %f\n", i, fgcp2[i] );
-       }
-#else
-       for( i=0; i<lgth1; i++ ) 
-       {
-               ogcp1[i] = 0.5;
-               fgcp1[i] = 0.5;
-       }
-       for( i=0; i<lgth2; i++ ) 
-       {
-               ogcp2[i] = 0.5;
-               fgcp2[i] = 0.5;
-       }
-#endif
-
-       gapinfo[0] = ogcp1;
-       gapinfo[1] = fgcp1;
-       gapinfo[2] = ogcp2;
-       gapinfo[3] = fgcp2;
-#endif
-
-#if 0
-       fprintf( stdout, "in MSalignmm.c\n" );
-       for( i=0; i<icyc; i++ )
-       {
-               fprintf( stdout, ">%d of GROUP1\n", i );
-               fprintf( stdout, "%s\n", seq1[i] );
-       }
-       for( i=0; i<jcyc; i++ )
-       {
-               fprintf( stdout, ">%d of GROUP2\n", i );
-               fprintf( stdout, "%s\n", seq2[i] );
-       }
-       fflush( stdout );
-#endif
-
-       wm = MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, 0, lgth1-1, 0, lgth2-1, alloclen, mseq1, mseq2, 0, gapinfo );
-
-//     fprintf( stderr, "wm = %f\n", wm );
-
-       for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
-       for( i=0; i<jcyc; i++ ) strcpy( seq2[i], mseq2[i] );
-
-
-       FreeFloatVec( ogcp1 );
-       FreeFloatVec( ogcp2 );
-       FreeFloatVec( fgcp1 );
-       FreeFloatVec( fgcp2 );
-       FreeFloatMtx( cpmx1 );
-       FreeFloatMtx( cpmx2 );
-       free( (void *)gapinfo );
-
-       FreeCharMtx( mseq1 );
-       FreeCharMtx( mseq2 );
-
-       return( wm );
-}