JWS-112 Bumping version of Mafft to version 7.310.
[jabaws.git] / binaries / src / mafft / core / SAalignmm.c
index 9fc05df..c7c5c47 100644 (file)
@@ -3,20 +3,22 @@
 
 #define DEBUG 0
 
-static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+static void match_calc( double *match, double **cpmx1, double **cpmx2, int i1, int lgth2, double **doublework, int **intwork, int initialize )
 {
        int j, k, l;
-       float scarr[26];
-       float **cpmxpd = floatwork;
+//     double scarr[26];
+       double **cpmxpd = doublework;
        int **cpmxpdn = intwork;
        int count = 0;
+       double *scarr;
+       scarr = calloc( nalphabets, sizeof( double ) );
 
        if( initialize )
        {
                for( j=0; j<lgth2; j++ )
                {
                        count = 0;
-                       for( l=0; l<26; l++ )
+                       for( l=0; l<nalphabets; l++ )
                        {
                                if( cpmx2[l][j] )
                                {
@@ -29,10 +31,10 @@ static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int
                }
        }
 
-       for( l=0; l<26; l++ )
+       for( l=0; l<nalphabets; l++ )
        {
                scarr[l] = 0.0;
-               for( k=0; k<26; k++ )
+               for( k=0; k<nalphabets; k++ )
                        scarr[l] += n_dis[k][l] * cpmx1[k][i1];
        }
        for( j=0; j<lgth2; j++ )
@@ -41,18 +43,19 @@ static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int
                for( k=0; cpmxpdn[k][j] > -1;  k++ )
                        match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
        } 
+       free( scarr );
 }
 
-static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+static double Atracking( double *lasthorizontalw, double *lastverticalw, 
                                                char **seq1, char **seq2, 
                         char **mseq1, char **mseq2, 
-                        float **cpmx1, float **cpmx2, 
+                        double **cpmx1, double **cpmx2, 
                         int **ijp, int icyc, int jcyc )
 {
        int i, j, k, l, iin, jin, ifi, jfi, lgth1, lgth2;
 //     char gap[] = "-";
        char *gap;
-       float wm;
+       double wm;
        gap = newgapstr;
        lgth1 = strlen( seq1[0] );
        lgth2 = strlen( seq2[0] );
@@ -153,31 +156,31 @@ static float Atracking( float *lasthorizontalw, float *lastverticalw,
 }
 
 
-float Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen )
+double Aalign( 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 */
 {
        register int i, j;
        int lasti;                      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
        int lgth1, lgth2;
        int resultlen;
-       float wm = 0.0;   /* int ?????? */
-       float g;
-       float x;
-       static TLS float mi, *m;
+       double wm = 0.0;   /* int ?????? */
+       double g;
+       double x;
+       static TLS double mi, *m;
        static TLS int **ijp;
        static TLS int mpi, *mp;
-       static TLS float *currentw;
-       static TLS float *previousw;
-       static TLS float *match;
-       static TLS float *initverticalw;    /* kufuu sureba iranai */
-       static TLS float *lastverticalw;    /* kufuu sureba iranai */
+       static TLS double *currentw;
+       static TLS double *previousw;
+       static TLS double *match;
+       static TLS double *initverticalw;    /* kufuu sureba iranai */
+       static TLS double *lastverticalw;    /* kufuu sureba iranai */
        static TLS char **mseq1;
        static TLS char **mseq2;
        static TLS char **mseq;
-       static TLS float **cpmx1;
-       static TLS float **cpmx2;
+       static TLS double **cpmx1;
+       static TLS double **cpmx2;
        static TLS int **intwork;
-       static TLS float **floatwork;
+       static TLS double **doublework;
        static TLS int orlgth1 = 0, orlgth2 = 0;
 
 #if DEBUG
@@ -213,7 +216,7 @@ float Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, in
                        FreeFloatMtx( cpmx1 );
                        FreeFloatMtx( cpmx2 );
 
-                       FreeFloatMtx( floatwork );
+                       FreeFloatMtx( doublework );
                        FreeIntMtx( intwork );
                }
 
@@ -234,11 +237,11 @@ float Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, in
 
                mseq = AllocateCharMtx( njob, ll1+ll2 );
 
-               cpmx1 = AllocateFloatMtx( 26, ll1+2 );
-               cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+               cpmx1 = AllocateFloatMtx( nalphabets, ll1+2 );
+               cpmx2 = AllocateFloatMtx( nalphabets, ll2+2 );
 
-               floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
-               intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+               doublework = AllocateFloatMtx( nalphabets, MAX( ll1, ll2 )+2 ); 
+               intwork = AllocateIntMtx( nalphabets, MAX( ll1, ll2 )+2 ); 
 
                fprintf( stderr, "succeeded\n" );
 
@@ -276,8 +279,8 @@ float Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, in
        cpmx_calc( seq1, cpmx1, eff1, strlen( seq1[0] ), icyc );
        cpmx_calc( seq2, cpmx2, eff2, strlen( seq2[0] ), jcyc );
 
-       match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
-       match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+       match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, doublework, intwork, 1 );
+       match_calc( currentw, cpmx1, cpmx2, 0, lgth2, doublework, intwork, 1 );
 
        if( outgap == 1 )
        {
@@ -303,10 +306,10 @@ float Aalign( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, in
        for( i=1; i<lasti; i++ )
        {
 
-               floatncpy( previousw, currentw, lgth2+1 );
+               doublencpy( previousw, currentw, lgth2+1 );
                previousw[0] = initverticalw[i-1];
 
-               match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+               match_calc( currentw, cpmx1, cpmx2, i, lgth2, doublework, intwork, 0 );
                currentw[0] = initverticalw[i];
 
                mi = previousw[0] + penalty * 0.5; mpi = 0;