[llvm-commits] [test-suite] r65043 [1/2] - in /test-suite/trunk/MultiSource/Benchmarks: ./ mafft/

Torok Edwin edwintorok at gmail.com
Thu Feb 19 04:38:03 PST 2009


Author: edwin
Date: Thu Feb 19 06:37:59 2009
New Revision: 65043

URL: http://llvm.org/viewvc/llvm-project?rev=65043&view=rev
Log:
Add mafft to testsuite (PR3533).
Also enable PAQ8p and mafft in Makefile.

Added:
    test-suite/trunk/MultiSource/Benchmarks/mafft/
    test-suite/trunk/MultiSource/Benchmarks/mafft/Calignm1.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/DNA.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/Falign.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Galign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Halignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/JTT.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Lalign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Lalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/MSalign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/MSalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Makefile
    test-suite/trunk/MultiSource/Benchmarks/mafft/Qalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Ralignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/SAalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/Salignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/constants.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/defs.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/dp.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/fft.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/fft.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/fftFunctions.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/functions.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/genGalign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/genalign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/io.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/license
    test-suite/trunk/MultiSource/Benchmarks/mafft/miyata.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/miyata5.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln9.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/pairlocalalign.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/partQalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/partSalignmm.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/pyruvate_decarboxylase.fasta
    test-suite/trunk/MultiSource/Benchmarks/mafft/readme
    test-suite/trunk/MultiSource/Benchmarks/mafft/rna.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/share.h
    test-suite/trunk/MultiSource/Benchmarks/mafft/suboptalign11.c
    test-suite/trunk/MultiSource/Benchmarks/mafft/tddis.c
Modified:
    test-suite/trunk/MultiSource/Benchmarks/Makefile

Modified: test-suite/trunk/MultiSource/Benchmarks/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Makefile?rev=65043&r1=65042&r2=65043&view=diff

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Makefile (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Makefile Thu Feb 19 06:37:59 2009
@@ -5,6 +5,6 @@
                  McCat Olden OptimizerEval Ptrdist llubenchmark \
                  sim FreeBench MallocBench Prolangs-C Prolangs-C++ SciMark2-C\
 		 mediabench ASCI_Purple MiBench Trimaran VersaBench tramp3d-v4 NPB-serial\
-		 BitBench ASC_Sequoia
+		 BitBench ASC_Sequoia PAQ8p mafft
 
 include $(LEVEL)/Makefile.programs

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Calignm1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Calignm1.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Calignm1.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Calignm1.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,598 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+
+void tracking( char **nseq, char **aseq, char *seq, int **ijp, int icyc )
+{
+	int i, k, l;
+	int iin, ifi, jin, jfi;
+	int lgth = strlen( aseq[0] );
+	int lgth1 = strlen( seq );
+	char gap[] = "-";
+	
+	for( i=0; i<=icyc+1; i++ )
+	{
+		nseq[i] += lgth+lgth1;
+		*nseq[i] = 0;
+	}
+
+	iin = lgth; jin = lgth1;
+	for( k=0; k<=lgth+lgth1; )
+	{
+		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;
+			/*
+			if( ifi < 0 ) jfi = -1;  
+			if( jfi < 0 ) ifi = -1;
+			*/
+		}
+		for( l=1; l<iin-ifi; l++ )
+		{
+			for( i=0; i<icyc+1; i++ ) 
+				*--nseq[i] = aseq[i][iin-l];
+			*--nseq[icyc+1] = *gap;
+			k++;
+		}
+		for( l=1; l<jin-jfi; l++ )
+		{
+			for( i=0; i<icyc+1; i++ ) 
+				*--nseq[i] = *gap;
+			nseq[icyc+1]--;
+			*nseq[icyc+1] = seq[jin-l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc+1; i++ ) 
+			*--nseq[i] = aseq[i][ifi];
+		*--nseq[icyc+1] = seq[jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+}
+
+
+char **Calignm1( float *wm, char **aseq, char *seq, double *effarr, int icyc, int ex )
+{
+	register int i, j, k, l;
+	float tmpfloat;
+	int inttmp;
+	static float mi, *m;
+	static int mpi, *mp;
+	static float ***g;
+	int gb1, gc1;
+	static int **ijp;
+	static float **v, **w;
+	static float *gvsa;
+	static char **mseq;
+	static char **nseq;
+	static float **scmx;
+	float wmax;
+	int lgth, lgth1;
+	static int orlgth = 0, orlgth1 = 0;
+	float x;
+	float efficient;
+	float *AllocateFloatVec( int );
+	float totaleff;
+	static float **gl;
+	static float **gs;
+	float **AllocateFloatTri( int );
+	void FreeFloatTri( float ** );
+
+#if DEBUG
+	FILE *fp;
+#endif
+
+
+	totaleff = 0.0;
+	for( i=0; i<icyc+1; i++ ) totaleff += effarr[i];
+	lgth = strlen( aseq[0] );
+	lgth1 = strlen( seq );
+
+
+#if DEBUG
+	fprintf( stdout, "effarr in Calignm1 s = \n", ex  );
+	for( i=0; i<icyc+1; i++ ) 
+		fprintf( stdout, " %f", effarr[i] );
+	printf( "\n" );
+#endif
+
+	if( orlgth > 0 && orlgth1 > 0 ) for( i=0; i<njob+1; i++ ) nseq[i] = mseq[i];
+/* 
+ *     allocate
+ */
+
+	if( lgth > orlgth || lgth1 > orlgth1 )
+	{
+		int ll1, ll2;
+
+		if( orlgth > 0 && orlgth1 > 0 )
+		{	
+			FreeFloatMtx( v );
+
+			FreeFloatCub( g );
+			FreeFloatTri( gl );
+			FreeFloatTri( gs );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+#if 0
+			FreeCharMtx( nseq );
+#endif
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( gvsa );
+			FreeFloatMtx( scmx );
+		}
+
+		ll1 = MAX( (int)(1.1*lgth), orlgth );
+		ll2 = MAX( (int)(1.1*lgth1), orlgth1 );
+		ll1 = MAX( ll1, ll2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		v = AllocateFloatMtx( ll1+2, ll2+2 );
+
+		g = AllocateFloatCub( ll1+2, 3, 3 );
+
+		gl = AllocateFloatTri( MAX( ll1, ll2 ) + 3 );
+		gs = AllocateFloatTri( MAX( ll1, ll2 ) + 3 );
+
+		m = AllocateFloatVec( ll1+2 );
+		mp = AllocateIntVec( ll1+2 );
+
+		mseq = AllocateCharMtx( njob+1, 1 );
+		nseq = AllocateCharMtx( njob+1, ll1+ll2 );
+		for( i=0; i<njob+1; i++ ) mseq[i] = nseq[i];
+
+		gvsa = AllocateFloatVec( ll1+2 );
+
+		scmx = AllocateFloatMtx( 26, ll1+2 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		orlgth = ll1;
+		orlgth1 = ll2;
+#if DEBUG
+		fprintf( stderr, "orlgth   ==  %d\n", orlgth );
+#endif
+	}
+
+	if( orlgth > commonAlloc1 || orlgth1 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( commonAlloc1, orlgth );
+		ll2 = MAX( commonAlloc2, orlgth1 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+
+	ijp = commonIP;
+
+	scmx_calc( icyc, aseq, effarr, scmx );
+
+	for( i=0; i<lgth; i++ )
+	{
+		float scarr[26];
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( k=0; k<26; k++ )
+				scarr[l] += n_dis[k][l] * scmx[k][i];
+		}
+		for( j=0; j<lgth1; j++ )
+		{
+			v[i][j] = scarr[(int)amino_n[(int)seq[j]]];
+		}
+		gvsa[i] = scarr[24];
+	}
+	for( i=0; i<lgth+1; i++ ) v[i][lgth1] = 0.0;
+	for( j=0; j<lgth1+1; j++ ) v[lgth][j] = 0.0;
+	gvsa[lgth] = 0.0;
+
+	for( j=0; j<lgth+1; j++ ) for( k=0; k<3; k++ ) for( l=0; l<3; l++ )
+		g[j][k][l] = 0;
+
+		
+	for( i=0; i<icyc+1; i++ )
+	{
+		efficient = (float)effarr[i];
+
+		gc1 = 0; /* 1? */
+		for( j=0; j<lgth+1; j++ ) 
+		{
+			gb1 = gc1;
+
+			gc1 = ( aseq[i][j] == '-' );
+			if( j == lgth )  gc1 = 0; /*  0? */
+							/* continue; */
+
+			g[j][0][0] += ( !gb1 *  gc1 ) * efficient * penalty;
+			g[j][1][0] += ( 0 ) * efficient * penalty;
+			g[j][2][0] += ( 0 ) * efficient * penalty;
+			g[j][0][1] += ( gb1 * !gc1 + !gb1 * !gc1 ) * efficient * penalty;
+			g[j][1][1] += ( 0 ) * efficient * penalty;
+			g[j][0][2] += ( !gb1 ) * efficient * penalty;  /* ??? */
+			g[j][2][2] += ( 0 ) * efficient * penalty;
+		}
+	}
+
+	for( i=0; i<lgth+2; i++ ) for( j=0; j<=i+1; j++ ) 
+	{
+		gs[i][j] = gl[i][j] = 0.0;
+	}
+
+	for( i=0; i<icyc+1; i++ )
+	{
+		efficient = (float)effarr[i];
+		inttmp = 0;
+		for( j=0; j<lgth+1; j++ ) 
+		{
+			if( aseq[i][j] == '-' )
+			{
+				inttmp++;
+				gs[j][inttmp] += (float)efficient * penalty;
+
+				if( aseq[i][j+1] != '-' )
+					gl[j][inttmp] += (float)efficient * penalty;
+			}
+			else inttmp = 0;
+		}
+
+	}
+	/*
+
+	for( i=0; i<lgth+1; i++ ) 
+	{	
+		fprintf( stderr, "gl[%d][] = ", i );
+		fprintf( stderr, "\n" );
+		for( j=0; j<=i+1; j++ ) 
+			fprintf( stderr, " %.0f", i, j, gl[i][j] );
+		fprintf( stderr, "\n" );
+	}
+	*/
+
+	for( i=0; i<lgth+1; i++ ) 
+	{
+		for( j=1; j<=i; j++ ) 
+			gs[i][j+1] += gs[i][j];
+		for( j=i; j>0; j-- )
+			gl[i][j] += gl[i][j+1];
+	}
+		
+/*
+	for( i=0; i<lgth+1; i++ ) 
+	{	
+	j = 5;
+		fprintf( stderr, "gs[%d][%d] = %f, gl[%d][%d] = %f\n", i, j, gs[i][j], i, j, gl[i][j] );
+	}
+
+		
+*/
+
+/*
+	printf( "%d\n", lgth  );	
+	for( i=0; i<lgth; i++ )
+	{
+		printf( "%f %f %f %f %f %f %f\n", g[i][0][0], g[i][1][0], g[i][2][0], g[i][0][1], g[i][1][1], g[i][0][2], g[i][2][2] );
+	}
+	printf( "\n\n\n\n\n" );	
+*/
+/*
+	for( i=0; i<lgth; i++ ) for( j=0; j<3; j++ ) for( k=0; k<3; k++ )
+	{
+		g[i][j][k] /= ( (float)icyc + 1.0 );
+	}
+*/
+
+/*
+fp = fopen( "gapp", "a" );
+fprintf( fp, "gapmatrix g[i][][] except for %d\n", ex+1 );
+for( i=0; i<100; i++ ) 
+{
+	fprintf( fp, "site No.%#3d  ", i+1 );
+	fprintf( fp, "00:%#5d ", -(int)g[i][0][0] );
+	fprintf( fp, "10:%#5d ", -(int)g[i][1][0] );
+	fprintf( fp, "20:%#5d ", -(int)g[i][2][0] );
+	fprintf( fp, "01:%#5d ", -(int)g[i][0][1] );
+	fprintf( fp, "11:%#5d ", -(int)g[i][1][1] );
+	fprintf( fp, "02:%#5d ", -(int)g[i][0][2] );
+	fprintf( fp, "22:%#5d ", -(int)g[i][2][2] );
+	fprintf( fp, "\n" );
+}
+fprintf( fp, "\n" );
+fclose ( fp );
+*/
+		
+	w = v;
+
+	w[0][0] += /* scmx[24][0] * penalty */ g[0][0][0];  /* [0][0] ? */
+	w[1][0] += g[0][0][1] + g[1][1][0] + gs[1][2] + gvsa[0];  /*  ??? */
+	tmpfloat = 0.0;
+	for( i=2; i<lgth+2; i++ ) 
+	{
+		tmpfloat += g[i-1][1][1] + gl[i-2][i-1] + gvsa[i-1];
+		w[i][0] += g[0][0][1] + gvsa[0] + tmpfloat + g[i][1][0] + gs[i][i+1];
+	}
+
+	w[0][1] += penalty * totaleff + n_dis[24][0] * totaleff;
+	tmpfloat = 0.0;
+	for( j=2; j<lgth1+1; j++ ) 
+	{
+		tmpfloat += n_dis[24][0] * totaleff;
+		w[0][j] += penalty * totaleff + tmpfloat;
+	}
+
+	for( j=0; j<lgth1+1; ++j ) 
+	{
+		m[j] = 0; mp[j] = 0;
+	}
+	for( i=1; i<lgth+1; i++ )
+	{
+		mi = 0; mpi = 0;
+		for( j=1; j<lgth1+1; j++ )
+		{
+			if( j > 1 )
+			{
+				x = w[i-1][j-2] + g[i-0][0][2] + n_dis[24][0] * totaleff;
+				mi += g[i-1][2][2] + n_dis[24][0] * totaleff;
+				if( mi < x )
+				{
+					mi = x;
+					mpi = j-2;
+				}
+			}
+			else 
+			{
+				mi = w[i-1][0] + g[i-0][0][2]/* + n_dis[24][0] * totaleff */;  /* 0.0? */
+				/*
+				fprintf( stderr, " i == %d j == 1, w[i][0] == %f, mi == %f, g[i][0][2] == %f\n", i, w[i][0], mi, g[i][0][2] );
+				*/
+			/*
+				mi = 0.0 + g[i-0][0][2];  * 0.0? *
+			*/
+				mpi = 0;
+			}
+
+			if( i > 1 )
+			{
+				x = w[i-2][j-1] + g[i-1][0][1] + gvsa[i-1];
+				m[j] += g[i-1][1][1] + gl[i-2][i-mp[j]-2] + gvsa[i-1];      /* ??? */
+				if( m[j] < x )
+				{
+					m[j] = x;
+					mp[j] = i-2;
+				}
+
+			}
+			else
+			{
+				m[j] = w[0][j-1]+ g[i][0][1]/* + gvsa[1] */;  /* 0.0? */
+				mp[j] = 0;
+			}
+
+			wmax = w[i-1][j-1] + g[i][0][0];
+			/*
+			ip[i][j]=i-1;
+			jp[i][j]=j-1;
+			*/
+			ijp[i][j] = 0;
+
+			x = mi + g[i][2][0];
+			if( x > wmax )
+			{
+				wmax = x;
+				/*
+				ip[i][j] = i-1;
+				jp[i][j] = mpi;
+				*/
+				ijp[i][j] = -( j - mpi );    /* ijp[][] < 0 -> j ni gap */
+			}
+
+			x = m[j] + g[i][1][0] + gs[i][i-mp[j]];
+			if( x > wmax )
+			{
+				wmax = x;
+				/*
+				ip[i][j] = mp[j];
+				jp[i][j] = j-1;
+				*/
+				ijp[i][j] = +( i - mp[j] );
+			}
+			w[i][j] += wmax;
+		}
+	}
+	if( cnst )
+	{
+		w[lgth][lgth1] = w[lgth-1][lgth1-1] + g[lgth][0][0];
+		/*
+		ip[lgth][lgth1] = lgth-1;
+		jp[lgth][lgth1] = lgth1-1;
+		*/
+		ijp[lgth][lgth1] = 0;
+	}
+
+	*wm = w[lgth][lgth1];
+
+	for( i=0; i<lgth+1; i++ ) 
+	{
+	/*
+		ip[i][0] = -1; jp[i][0] = -1;
+	*/
+		ijp[i][0] = i + 1;
+	}
+	for( j=0; j<lgth1+1; j++ ) 
+	{
+	/*
+		ip[0][j] = -1; jp[0][j] = -1;
+	*/
+		ijp[0][j] = -( j + 1 );
+	}
+	/*
+	ip[lgth][lgth1]=iin; jp[lgth][lgth1]=jin;
+	ip[lgth+1][lgth1+1]=lgth; jp[lgth+1][lgth1+1]=lgth1;
+	*/
+	/*
+	tracking( nseq, aseq, seq, ip, jp, icyc );
+	*/
+	tracking( nseq, aseq, seq, ijp, icyc );
+/*
+fp = fopen( "matrx", "a" );
+fprintf( fp, "matrix v\n" );
+fprintf( fp, "%#5d", 0 );
+for( j=0; j<20; j++ ) fprintf( fp, "%#5d", j );
+fprintf( fp, "\n" );
+for( i=0; i<lgth+1; i++ ) 
+{
+	fprintf( fp, "%#5d", i );
+	for( j=0; j<20; j++ ) 
+	{
+		fprintf( fp, "%#5d", (int)( w[i][j]/(icyc+1) ) );
+	}
+	fprintf( fp, "\n" );
+}
+fclose( fp );
+*/
+#if DEBUG
+	printf( "seq1[0] = %s\n", nseq[0] );
+	printf( "seq2[0] = %s\n", nseq[icyc+1] );
+#endif
+	*wm = w[lgth][lgth1];
+	return( nseq );
+}
+
+double Cscore_m_1( char **seq, int locnjob, int ex, double **eff )
+{
+    int i, k;
+    int len = strlen( seq[0] );
+    int gb1, gb2, gc1, gc2;
+    int cob;
+    int nglen;
+    double score;
+	double pen;
+	double tmpscore;
+	int *glen1, *glen2;
+
+	int tmp1, tmp2;
+
+
+	glen1 = AllocateIntVec( locnjob );
+	glen2 = AllocateIntVec( locnjob );
+    score = 0.0;
+    nglen = 0;
+	/*
+	printf( "in Cscore_m_1\n" );
+	for( i=0; i<locnjob; i++ ) 
+	{
+		if( i == ex ) continue;
+		fprintf( stdout, "%d-%d:%f\n", ex, i, eff[ex][i] );
+	}
+	*/
+   	for( k=0; k<len; k++ )
+    {
+
+		tmpscore = pen = 0;
+   		for( i=0; i<locnjob; i++ )
+        {
+ 	 		double efficient = eff[ex][i];
+        	if( i == ex ) continue;
+			if( k > 0 )
+			{
+         		 gb1 = ( seq[i][k-1] == '-' );
+           		 gb2 = ( seq[ex][k-1] == '-' );
+			}
+			else
+			{
+				gb1 = 0; 
+				gb2 = 0;
+			}
+
+			if( gb1 ) glen1[i]++; else glen1[i] = 0;
+			if( gb2 ) glen2[i]++; else glen2[i] = 0;
+
+            gc1 = ( seq[i][k] == '-' );
+            gc2 = ( seq[ex][k] == '-' );
+
+			if( glen1[i] >= glen2[i] ) tmp1 = 1; else tmp1 = 0;
+			if( glen1[i] <= glen2[i] ) tmp2 = 1; else tmp2 = 0;
+            cob =
+                   !gb1  *  gc1
+                 * !gb2  * !gc2
+
+                 + !gb1  * !gc1
+                 * !gb2  *  gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+
+                 +  gb1  * !gc1
+                 *  gb2  *  gc2      * tmp1
+
+                 +  gb1  *  gc1
+                 *  gb2  * !gc2      * tmp2
+                 ;
+
+            pen += (double)cob * penalty * efficient;
+            tmpscore += (double)amino_dis[(int)seq[i][k]][(int)seq[ex][k]] * efficient;
+            /*
+            nglen += ( !gc1 * !gc2 );
+            */
+			/*
+			if( k == 0 )
+			{
+				printf( "%c<->%c * %f = %f\n", seq[ex][k], seq[i][k], efficient, amino_dis[seq[i][k]][seq[ex][k]] * efficient );
+			}
+			*/
+        }
+		score += tmpscore;
+		score += pen;
+		/*
+        if( 1 ) fprintf( stdout, "%c   %f    ", seq[ex][k], score / (locnjob-1) );
+        if( 1 ) fprintf( stdout, "penalty  %f\n", (double)pen / (locnjob - 1 ) );
+		*/
+    }
+	/*
+    fprintf( stdout, "in Cscore_m_1 %f\n", score );
+	*/
+	/*
+	fprintf( stdout, "%s\n", seq[ex] );
+	*/
+	free( glen1 );
+	free( glen2 );
+    return( (double)score /*/ nglen + 400.0*/ );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/DNA.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/DNA.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/DNA.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/DNA.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,210 @@
+#define DEFAULTGOP_N -1530
+#define DEFAULTGEP_N  0
+#define DEFAULTOFS_N -123 
+#define DEFAULTPAMN  200
+
+#define DEFAULTRNAGOP_N -1530
+#define DEFAULTRNAGEP_N 0
+#define DEFAULTRNATHR_N 0
+
+//  -h 0.11150 -> all positive
+
+double ribosum4[4][4] = 
+{
+//   a       g       c       t     
+{    2.22,  -1.46,  -1.86,  -1.39, }, // a
+{   -1.46,   1.03,  -2.48,  -1.74, }, // g
+{   -1.86,  -2.48,   1.16,  -1.05, }, // c
+{   -1.39,  -1.74,  -1.05,   1.65, }, // t
+};
+
+double ribosum16[16][16] = 
+{
+//   aa      ag      ac      at      ga      gg      gc      gt      ca      cg      cc      ct      ta      tg      tc      tt    
+{   -2.49,  -8.24,  -7.04,  -4.32,  -6.86,  -8.39,  -5.03,  -5.84,  -8.84,  -4.68, -14.37, -12.64,  -4.01,  -6.16, -11.32,  -9.05, }, // aa
+{   -8.24,  -0.80,  -8.89,  -5.13,  -8.61,  -5.38,  -5.77,  -6.60, -10.41,  -4.57, -14.53, -10.14,  -5.43,  -5.94,  -8.87, -11.07, }, // ag
+{   -7.04,  -8.89,  -2.11,  -2.04,  -9.73, -11.05,  -3.81,  -4.72,  -9.37,  -5.86,  -9.08, -10.45,  -5.33,  -6.93,  -8.67,  -7.83, }, // ac
+{   -4.32,  -5.13,  -2.04,   4.49,  -5.33,  -5.61,   2.70,   0.59,  -5.56,   1.67,  -6.71,  -5.17,   1.61,  -0.51,  -4.81,  -2.98, }, // at
+{   -6.86,  -8.61,  -9.73,  -5.33,  -1.05,  -8.67,  -4.88,  -6.10,  -7.98,  -6.00, -12.43,  -7.71,  -5.85,  -7.55,  -6.63, -11.54, }, // ga
+{   -8.39,  -5.38, -11.05,  -5.61,  -8.67,  -1.98,  -4.13,  -5.77, -11.36,  -4.66, -12.58, -13.69,  -5.75,  -4.27, -12.01, -10.79, }, // gg
+{   -5.03,  -5.77,  -3.81,   2.70,  -4.88,  -4.13,   5.62,   1.21,  -5.95,   2.11,  -3.70,  -5.84,   1.60,  -0.08,  -4.49,  -3.90, }, // gc
+{   -5.84,  -6.60,  -4.72,   0.59,  -6.10,  -5.77,   1.21,   3.47,  -7.93,  -0.27,  -7.88,  -5.61,  -0.57,  -2.09,  -5.30,  -4.45, }, // gt
+{   -8.84, -10.41,  -9.37,  -5.56,  -7.98, -11.36,  -5.95,  -7.93,  -5.13,  -3.57, -10.45,  -8.49,  -2.42,  -5.63,  -7.08,  -8.39, }, // ca
+{   -4.68,  -4.57,  -5.86,   1.67,  -6.00,  -4.66,   2.11,  -0.27,  -3.57,   5.36,  -5.71,  -4.96,   2.75,   1.32,  -4.91,  -3.67, }, // cg
+{  -14.37, -14.53,  -9.08,  -6.71, -12.43, -12.58,  -3.70,  -7.88, -10.45,  -5.71,  -3.59,  -5.77,  -6.88,  -8.41,  -7.40,  -5.41, }, // cc
+{  -12.64, -10.14, -10.45,  -5.17,  -7.71, -13.69,  -5.84,  -5.61,  -8.49,  -4.96,  -5.77,  -2.28,  -4.72,  -7.36,  -3.83,  -5.21, }, // ct
+{   -4.01,  -5.43,  -5.33,   1.61,  -5.85,  -5.75,   1.60,  -0.57,  -2.42,   2.75,  -6.88,  -4.72,   4.97,   1.14,  -2.98,  -3.39, }, // ta
+{   -6.16,  -5.94,  -6.93,  -0.51,  -7.55,  -4.27,  -0.08,  -2.09,  -5.63,   1.32,  -8.41,  -7.36,   1.14,   3.36,  -4.76,  -4.28, }, // tg
+{  -11.32,  -8.87,  -8.67,  -4.81,  -6.63, -12.01,  -4.49,  -5.30,  -7.08,  -4.91,  -7.40,  -3.83,  -2.98,  -4.76,  -3.21,  -5.97, }, // tc
+{   -9.05, -11.07,  -7.83,  -2.98, -11.54, -10.79,  -3.90,  -4.45,  -8.39,  -3.67,  -5.41,  -5.21,  -3.39,  -4.28,  -5.97,  -0.02, }, // tt
+};
+
+int locpenaltyn = -1750;
+char locaminon[] = "agctuAGCTUnNbdhkmnrsvwyx-O";
+char locgrpn[] = 
+{
+	0, 1, 2, 3, 3, 0, 1, 2, 3, 3,
+	4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 
+	5, 5, 5, 5, 5, 5 
+};
+int exgpn = +00;
+int locn_disn[26][26] = 
+/* u ha constants.c no nakade shori */
+/* 0 - 4 dake yomareru.             */
+        {
+		{
+  1000,   600,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+   600,  1000,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,  1000,   600,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,   600,  1000,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,   500,   500,     0,     0,     0,   500,   500,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,  -500,
+		},
+
+		{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -500,
+		},
+
+		{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -500,
+		},
+
+		{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -500,
+		},
+
+		{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -500,
+		},
+
+		{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,
+		},
+
+		{
+ -500, -500, -500, -500, -500, -500, -500, -500, -500, -500,
+ -500, -500, -500, -500, -500, -500, -500, -500, -500, -500,
+ -500, -500, -500, -500,    0,  500,
+		},
+     };

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Falign.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Falign.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Falign.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Falign.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,2981 @@
+#include "mltaln.h"
+
+#if 0
+static FILE *fftfp;
+#endif
+static int n20or4or2;
+
+#define KEIKA 0
+#define RND   0
+#define DEBUG 0
+
+#if RND // by D.Mathog
+static void generateRndSeq( char *seq, int len )
+{
+	while( len-- )
+#if 1
+		*seq++ = (int)( rnd() * n20or4or2 );
+#else
+		*seq++ = (int)1;
+#endif
+}
+#endif
+
+static void vec_init( Fukusosuu *result, int nlen )
+{
+	while( nlen-- )
+	{
+		result->R = result->I = 0.0;
+		result++;
+	}
+}
+
+#if 0 // by D.Mathog
+static void vec_init2( Fukusosuu **result, char *seq, double eff, int st, int ed )
+{
+	int i;
+	for( i=st; i<ed; i++ )
+		result[(int)*seq++][i].R += eff;
+}
+#endif
+
+static void seq_vec_2( Fukusosuu *result, double *score, double incr, char *seq )
+{
+	static int n;
+	for( ; *seq; result++ )
+	{
+		n = amino_n[(int)*seq++];
+		if( n < 20 && n >= 0 ) result->R += incr * score[n];
+#if 0
+		fprintf( stderr, "n=%d, score=%f, inc=%f R=%f\n",n,  score[n], incr * score[n], result->R );
+#endif
+	}
+}
+
+static void seq_vec_3( Fukusosuu **result, double incr, char *seq )
+{
+	int i;
+	int n;
+	for( i=0; *seq; i++ )
+	{
+		n = amino_n[(int)*seq++];
+		if( n < n20or4or2 && n >= 0 ) result[n][i].R += incr;
+	}
+}
+
+static void seq_vec_5( Fukusosuu *result, double *score1, double *score2, double incr, char *seq )
+{
+	int n;
+	for( ; *seq; result++ )
+	{
+		n = amino_n[(int)*seq++];
+		if( n > 20 ) continue;
+		result->R += incr * score1[n];
+		result->I += incr * score2[n];
+#if 0
+		fprintf( stderr, "n=%d, score=%f, inc=%f R=%f\n",n,  score[n], incr * score[n], result->R );
+#endif
+	}
+}
+
+
+static void seq_vec_4( Fukusosuu *result, double incr, char *seq )
+{
+	char s;
+	for( ; *seq; result++ )
+	{
+		s = *seq++;
+		if( s == 'a' )
+			result->R += incr;
+		else if( s == 't' )
+			result->R -= incr;
+		else if( s == 'g' )
+			result->I += incr;
+		else if( s == 'c' )
+			result->I -= incr;
+	}
+}
+
+#if 0 // by D.Mathog
+static void seq_vec( Fukusosuu *result, char query, double incr, char *seq )
+{
+#if 0
+	int bk = nlen;
+#endif
+	while( *seq )
+	{
+		if( *seq++ == query ) result->R += incr;
+		result++;
+#if 0
+fprintf( stderr, "i = %d result->R = %f\n", bk-nlen, (result-1)->R );
+#endif
+	}
+}
+
+static int checkRepeat( int num, int *cutpos )
+{
+	int tmp, buf;
+
+	buf = *cutpos;
+	while( num-- )
+	{
+		if( ( tmp = *cutpos++ ) < buf ) return( 1 );
+		buf = tmp;
+	}
+	return( 0 );
+}
+
+static int segcmp( void *ptr1, void *ptr2 )
+{
+	int diff;
+	Segment **seg1 = (Segment **)ptr1;
+	Segment **seg2 = (Segment **)ptr2;
+#if 0
+	return( (*seg1)->center - (*seg2)->center );
+#else
+	diff = (*seg1)->center - (*seg2)->center;
+	if( diff ) return( diff );
+
+	diff = (*seg1)->start - (*seg2)->start;
+	if( diff ) return( diff );
+
+	diff = (*seg1)->end - (*seg2)->end;
+	if( diff ) return( diff );
+
+	fprintf( stderr, "USE STABLE SORT !!\n" );
+	exit( 1 );
+	return( 0 );
+#endif
+}
+#endif
+
+
+static void mymergesort( int first, int last, Segment **seg )
+{
+	int middle;
+	static int i, j, k, p;
+	static int allo = 0;
+	static Segment **work = NULL;
+	if( last > allo )
+	{
+		allo = last;
+		if( work ) free( work );
+		work = (Segment **)calloc( allo / 2 + 1, sizeof( Segment *) );
+	}
+
+	if( first < last )
+	{
+		middle = ( first + last ) / 2;
+		mymergesort( first, middle, seg );
+		mymergesort( middle+1, last, seg );
+		p = 0;
+		for( i=first; i<=middle; i++ ) work[p++] = seg[i];
+		i = middle + 1; j = 0; k = first;
+		while( i <= last && j < p )
+		{
+			if( work[j]->center <= seg[i]->center ) 
+				seg[k++] = work[j++];
+			else
+				seg[k++] = seg[i++];
+		}
+		while( j < p ) seg[k++] = work[j++];
+	}
+}
+
+
+double Fgetlag( char  **seq1, char  **seq2, 
+			    double *eff1, double *eff2, 
+			    int    clus1, int    clus2,
+			    int alloclen )
+{
+	int i, j, k, l, m;
+	int nlen, nlen2, nlen4;
+	static int crossscoresize = 0;
+	static char **tmpseq1 = NULL;
+	static char **tmpseq2 = NULL;
+	static char **tmpptr1 = NULL;
+	static char **tmpptr2 = NULL;
+	static char **tmpres1 = NULL;
+	static char **tmpres2 = NULL;
+	static char **result1 = NULL;
+	static char **result2 = NULL;
+#if RND
+	static char **rndseq1 = NULL;
+	static char **rndseq2 = NULL;
+#endif
+	static Fukusosuu **seqVector1 = NULL;
+	static Fukusosuu **seqVector2 = NULL;
+	static Fukusosuu **naiseki = NULL;   
+	static Fukusosuu *naisekiNoWa = NULL; 
+	static double *soukan = NULL;
+	static double **crossscore = NULL;
+	int nlentmp;
+	static int *kouho = NULL;
+	static Segment *segment = NULL;
+	static Segment *segment1 = NULL;
+	static Segment *segment2 = NULL;
+	static Segment **sortedseg1 = NULL;
+	static Segment **sortedseg2 = NULL;
+	static int *cut1 = NULL;
+	static int *cut2 = NULL;
+	static int localalloclen = 0;
+	int lag;
+	int tmpint;
+	int count, count0;
+	int len1, len2;
+	int totallen;
+	float dumfl = 0.0;
+
+	len1 = strlen( seq1[0] );
+	len2 = strlen( seq2[0] );
+	nlentmp = MAX( len1, len2 );
+
+	nlen = 1;
+	while( nlentmp >= nlen ) nlen <<= 1;
+#if 0
+	fprintf( stderr, "###   nlen    = %d\n", nlen );
+#endif
+
+	nlen2 = nlen/2; nlen4 = nlen2 / 2;
+
+#if DEBUG
+	fprintf( stderr, "len1 = %d, len2 = %d\n", len1, len2 );
+	fprintf( stderr, "nlentmp = %d, nlen = %d\n", nlentmp, nlen );
+#endif
+
+	if( !localalloclen )
+	{
+		kouho = AllocateIntVec( NKOUHO );
+		cut1 = AllocateIntVec( MAXSEG );
+		cut2 = AllocateIntVec( MAXSEG );
+		tmpptr1 = AllocateCharMtx( njob, 0 );
+		tmpptr2 = AllocateCharMtx( njob, 0 );
+		result1 = AllocateCharMtx( njob, alloclen );
+		result2 = AllocateCharMtx( njob, alloclen );
+		tmpres1 = AllocateCharMtx( njob, alloclen );
+		tmpres2 = AllocateCharMtx( njob, alloclen );
+//		crossscore = AllocateDoubleMtx( MAXSEG, MAXSEG );
+		segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment1 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment2 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		sortedseg1 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		sortedseg2 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		if( !( segment && segment1 && segment2 && sortedseg1 && sortedseg2 ) )
+			ErrorExit( "Allocation error\n" );
+
+		if     ( scoremtx == -1 ) n20or4or2 = 4;
+		else if( fftscore == 1  ) n20or4or2 = 2;
+		else                      n20or4or2 = 20;
+	}
+	if( localalloclen < nlen )
+	{
+		if( localalloclen )
+		{
+#if 1
+			FreeFukusosuuMtx ( seqVector1 );
+			FreeFukusosuuMtx ( seqVector2 );
+			FreeFukusosuuVec( naisekiNoWa );
+			FreeFukusosuuMtx( naiseki );
+			FreeDoubleVec( soukan );
+			FreeCharMtx( tmpseq1 );
+			FreeCharMtx( tmpseq2 );
+#endif
+#if RND
+			FreeCharMtx( rndseq1 );
+			FreeCharMtx( rndseq2 );
+#endif
+		}
+
+
+		tmpseq1 = AllocateCharMtx( njob, nlen );
+		tmpseq2 = AllocateCharMtx( njob, nlen );
+		naisekiNoWa = AllocateFukusosuuVec( nlen );
+		naiseki = AllocateFukusosuuMtx( n20or4or2, nlen );
+		seqVector1 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
+		seqVector2 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
+		soukan = AllocateDoubleVec( nlen+1 );
+
+#if RND
+		rndseq1 = AllocateCharMtx( njob, nlen );
+		rndseq2 = AllocateCharMtx( njob, nlen );
+		for( i=0; i<njob; i++ )
+		{
+			generateRndSeq( rndseq1[i], nlen );
+			generateRndSeq( rndseq2[i], nlen );
+		}
+#endif
+		localalloclen = nlen;
+	}
+	
+	for( j=0; j<clus1; j++ ) strcpy( tmpseq1[j], seq1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( tmpseq2[j], seq2[j] );
+
+#if 0
+fftfp = fopen( "input_of_Falign", "w" );
+fprintf( fftfp, "nlen = %d\n", nlen );
+fprintf( fftfp, "seq1: ( %d sequences ) \n", clus1 );
+for( i=0; i<clus1; i++ )
+	fprintf( fftfp, "%s\n", seq1[i] );
+fprintf( fftfp, "seq2: ( %d sequences ) \n", clus2 );
+for( i=0; i<clus2; i++ )
+	fprintf( fftfp, "%s\n", seq2[i] );
+fclose( fftfp );
+system( "less input_of_Falign < /dev/tty > /dev/tty" );
+#endif
+
+	if( fftkeika ) fprintf( stderr,  " FFT ... " );
+
+	for( j=0; j<n20or4or2; j++ ) vec_init( seqVector1[j], nlen );
+	if( fftscore && scoremtx != -1 )
+	{
+		for( i=0; i<clus1; i++ )
+		{
+			seq_vec_2( seqVector1[0], polarity, eff1[i], tmpseq1[i] );
+			seq_vec_2( seqVector1[1], volume,   eff1[i], tmpseq1[i] );
+		}
+	}
+	else
+	{
+#if 0
+		for( i=0; i<clus1; i++ ) for( j=0; j<n20or4or2; j++ ) 
+			seq_vec( seqVector1[j], amino[j], eff1[i], tmpseq1[i] );
+#else
+		for( i=0; i<clus1; i++ )
+			seq_vec_3( seqVector1, eff1[i], tmpseq1[i] );
+#endif
+	}
+#if RND
+	for( i=0; i<clus1; i++ )
+	{
+		vec_init2( seqVector1, rndseq1[i], eff1[i], len1, nlen );
+	}
+#endif
+#if 0
+fftfp = fopen( "seqVec", "w" );
+fprintf( fftfp, "before transform\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "nlen=%d\n", nlen );
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector1[k][l].R, seqVector1[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec < /dev/tty > /dev/tty" );
+#endif
+
+	for( j=0; j<n20or4or2; j++ ) vec_init( seqVector2[j], nlen );
+	if( fftscore && scoremtx != -1 )
+	{
+		for( i=0; i<clus2; i++ )
+		{
+			seq_vec_2( seqVector2[0], polarity, eff2[i], tmpseq2[i] );
+			seq_vec_2( seqVector2[1], volume,   eff2[i], tmpseq2[i] );
+		}
+	}
+	else
+	{
+#if 0
+		for( i=0; i<clus2; i++ ) for( j=0; j<n20or4or2; j++ ) 
+			seq_vec( seqVector2[j], amino[j], eff2[i], tmpseq2[i] );
+#else
+		for( i=0; i<clus2; i++ )
+			seq_vec_3( seqVector2, eff2[i], tmpseq2[i] );
+#endif
+	}
+#if RND
+	for( i=0; i<clus2; i++ )
+	{
+		vec_init2( seqVector2, rndseq2[i], eff2[i], len2, nlen );
+	}
+#endif
+
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "before fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+	for( j=0; j<n20or4or2; j++ )
+	{
+		fft( nlen, seqVector2[j], (j==0) );
+		fft( nlen, seqVector1[j], 0 );
+	}
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "#after fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "#%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+	for( k=0; k<n20or4or2; k++ ) 
+	{
+		for( l=0; l<nlen; l++ ) 
+			calcNaiseki( naiseki[k]+l, seqVector1[k]+l, seqVector2[k]+l );
+	}
+	for( l=0; l<nlen; l++ ) 
+	{
+		naisekiNoWa[l].R = 0.0;
+		naisekiNoWa[l].I = 0.0;
+		for( k=0; k<n20or4or2; k++ ) 
+		{
+			naisekiNoWa[l].R += naiseki[k][l].R;
+			naisekiNoWa[l].I += naiseki[k][l].I;
+		}
+	}
+
+#if 0
+fftfp = fopen( "naisekiNoWa", "w" );
+fprintf( fftfp, "#Before fft\n" );
+for( l=0; l<nlen; l++ )
+	fprintf( fftfp, "%d  %f %f\n", l, naisekiNoWa[l].R, naisekiNoWa[l].I ); 
+fclose( fftfp );
+system( "less naisekiNoWa < /dev/tty > /dev/tty " );
+#endif
+
+	fft( -nlen, naisekiNoWa, 0 );
+
+	for( m=0; m<=nlen2; m++ ) 
+		soukan[m] = naisekiNoWa[nlen2-m].R;
+	for( m=nlen2+1; m<nlen; m++ ) 
+		soukan[m] = naisekiNoWa[nlen+nlen2-m].R;
+
+#if 0
+fftfp = fopen( "naisekiNoWa", "w" );
+fprintf( fftfp, "#After fft\n" );
+for( l=0; l<nlen; l++ )
+	fprintf( fftfp, "%d  %f\n", l, naisekiNoWa[l].R ); 
+fclose( fftfp );
+fftfp = fopen( "list.plot", "w"  );
+fprintf( fftfp, "plot 'naisekiNoWa'\npause -1" );
+fclose( fftfp );
+system( "/usr/bin/gnuplot list.plot &" );
+#endif
+#if 0
+fprintf( stderr, "frt write start\n" );
+fftfp = fopen( "frt", "w" );
+for( l=0; l<nlen; l++ )
+	fprintf( fftfp, "%d  %f\n", l-nlen2, soukan[l] ); 
+fclose( fftfp );
+system( "less frt < /dev/tty > /dev/tty" );
+#if 0
+fftfp = fopen( "list.plot", "w"  );
+fprintf( fftfp, "plot 'frt'\n pause +1" );
+fclose( fftfp );
+system( "/usr/bin/gnuplot list.plot" );
+#endif
+#endif
+
+
+	getKouho( kouho, NKOUHO, soukan, nlen );
+
+#if 0
+	for( i=0; i<NKOUHO; i++ )
+	{
+		fprintf( stdout, "kouho[%d] = %d\n", i, kouho[i] );
+	}
+#endif
+
+#if KEIKA
+	fprintf( stderr, "Searching anchors ... " );
+#endif
+	count = 0;
+
+
+
+#define CAND 0
+#if CAND
+	fftfp = fopen( "cand", "w" );
+	fclose( fftfp );
+#endif
+
+	for( k=0; k<NKOUHO; k++ ) 
+	{
+
+		lag = kouho[k];
+		zurasu2( lag, clus1, clus2, seq1, seq2, tmpptr1, tmpptr2 );
+#if CAND
+		fftfp = fopen( "cand", "a" );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr1[0] );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr2[0] );
+		fprintf( fftfp, ">\n", k+1, lag );
+		fclose( fftfp );
+#endif
+		tmpint = alignableReagion( clus1, clus2, tmpptr1, tmpptr2, eff1, eff2, segment+count );
+		
+		if( count+tmpint > MAXSEG -3 ) ErrorExit( "TOO MANY SEGMENTS.\n" );
+
+
+		if( tmpint == 0 ) break; // 060430 iinoka ?
+		while( tmpint-- > 0 )
+		{
+			if( lag > 0 )
+			{
+				segment1[count].start  = segment[count].start ;
+				segment1[count].end    = segment[count].end   ;
+				segment1[count].center = segment[count].center;
+				segment1[count].score  = segment[count].score;
+
+				segment2[count].start  = segment[count].start  + lag;
+				segment2[count].end    = segment[count].end    + lag;
+				segment2[count].center = segment[count].center + lag;
+				segment2[count].score  = segment[count].score       ;
+			}
+			else
+			{
+				segment1[count].start  = segment[count].start  - lag;
+				segment1[count].end    = segment[count].end    - lag;
+				segment1[count].center = segment[count].center - lag;
+				segment1[count].score  = segment[count].score       ;
+
+				segment2[count].start  = segment[count].start ;
+				segment2[count].end    = segment[count].end   ;
+				segment2[count].center = segment[count].center;
+				segment2[count].score  = segment[count].score ;
+			}
+#if 0
+			fprintf( stderr, "Goukaku=%dko\n", tmpint ); 
+			fprintf( stderr, "in 1 %d\n", segment1[count].center );
+			fprintf( stderr, "in 2 %d\n", segment2[count].center );
+#endif
+			segment1[count].pair = &segment2[count];
+			segment2[count].pair = &segment1[count];
+			count++;
+#if 0
+			fprintf( stderr, "count=%d\n", count );
+#endif
+		}
+	}
+
+#if 1
+	fprintf( stderr, "done. (%d anchors)\r", count );
+#endif
+	if( !count && fftNoAnchStop )
+		ErrorExit( "Cannot detect anchor!" );
+#if 0
+	fprintf( stdout, "RESULT before sort:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stdout, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( stdout, "%d score = %f\n", segment2[l].center, segment1[l].score );
+	}
+	exit( 1 );
+#endif
+
+#if KEIKA
+	fprintf( stderr, "Aligning anchors ... " );
+#endif
+	for( i=0; i<count; i++ )
+	{
+		sortedseg1[i] = &segment1[i];
+		sortedseg2[i] = &segment2[i];
+	}
+
+	{
+		mymergesort( 0, count-1, sortedseg1 ); 
+		mymergesort( 0, count-1, sortedseg2 ); 
+		for( i=0; i<count; i++ ) sortedseg1[i]->number = i;
+		for( i=0; i<count; i++ ) sortedseg2[i]->number = i;
+
+		if( crossscoresize < count+2 )
+		{
+			crossscoresize = count+2;
+			fprintf( stderr, "####################################################################################################################################allocating crossscore, size = %d\n", crossscoresize );
+			if( crossscore ) FreeDoubleMtx( crossscore );
+			crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
+		}
+
+		for( i=0; i<count+2; i++ ) for( j=0; j<count+2; j++ )
+			crossscore[i][j] = 0.0;
+		for( i=0; i<count; i++ )
+		{
+			crossscore[segment1[i].number+1][segment1[i].pair->number+1] = segment1[i].score;
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+
+#if DEBUG
+		fprintf( stderr, "AFTER SORT\n" );
+		for( i=0; i<count; i++ ) fprintf( stderr, "%d, %d\n", segment1[i].start, segment2[i].start );
+#endif
+
+		crossscore[0][0] = 10000000.0;
+		cut1[0] = 0; 
+		cut2[0] = 0;
+		crossscore[count+1][count+1] = 10000000.0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+		count0 = count;
+
+		blockAlign2( cut1, cut2, sortedseg1, sortedseg2, crossscore, &count );
+	}
+	if( fftkeika )
+	{
+		if( count0 > count )
+		{
+			fprintf( stderr, "REPEAT!? \n" ); 
+			if( fftRepeatStop ) exit( 1 );
+		}
+#if KEIKA
+		else 
+			fprintf( stderr, "done\n" );
+			fprintf( stderr, "done. (%d anchors)\n", count );
+#endif
+	}
+
+#if 0
+	fftfp = fopen( "fft", "a" );
+	fprintf( fftfp, "RESULT after sort:\n" );
+	for( l=0; l<count; l++ )
+	{
+		fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( fftfp, "%d\n", segment2[l].center );
+	}
+	fclose( fftfp );
+#endif
+
+#if 0
+	fftfp = fopen( "fft", "a" );
+	fprintf( fftfp, "RESULT after sort:\n" );
+	for( l=0; l<count; l++ )
+	{
+		fprintf( fftfp, "cut : %d %d\n", cut1[l], cut2[l] );
+	}
+	fclose( fftfp );
+#endif
+
+#if KEIKA
+	fprintf( trap_g, "Devided to %d segments\n", count-1 );
+	fprintf( trap_g, "%d  %d forg\n", MIN( clus1, clus2 ), count-1 );
+#endif
+
+	totallen = 0;
+	for( j=0; j<clus1; j++ ) result1[j][0] = 0;
+	for( j=0; j<clus2; j++ ) result2[j][0] = 0;
+	for( i=0; i<count-1; i++ )
+	{
+#if DEBUG
+		fprintf( stderr, "DP %03d / %03d %4d to ", i+1, count-1, totallen );
+#else
+#if KEIKA
+		fprintf( stderr, "DP %03d / %03d\r", i+1, count-1 );
+#endif
+#endif
+		for( j=0; j<clus1; j++ )
+		{
+			strncpy( tmpres1[j], seq1[j]+cut1[i], cut1[i+1]-cut1[i] );
+			tmpres1[j][cut1[i+1]-cut1[i]] = 0;
+		}
+		for( j=0; j<clus2; j++ )
+		{
+			strncpy( tmpres2[j], seq2[j]+cut2[i], cut2[i+1]-cut2[i] );
+			tmpres2[j][cut2[i+1]-cut2[i]] = 0;
+		}
+		switch( alg )
+		{
+			case( 'a' ):
+				Aalign( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen );
+				break;
+			case( 'M' ):
+					MSalignmm( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL );
+				break;
+			case( 'A' ):
+				if( clus1 == 1 && clus2 == 1 )
+					G__align11( tmpres1, tmpres2, alloclen );
+				else
+					A__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL );
+				break;
+			case( 'H' ):
+				if( clus1 == 1 && clus2 == 1 )
+					G__align11( tmpres1, tmpres2, alloclen );
+				else
+					H__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL );
+				break;
+			case( 'Q' ):
+				if( clus1 == 1 && clus2 == 1 )
+					G__align11( tmpres1, tmpres2, alloclen );
+				else
+					Q__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL );
+				break;
+			default:
+				fprintf( stderr, "alg = %c\n", alg );
+				ErrorExit( "ERROR IN SOURCE FILE Falign.c" );
+				break;
+		}
+
+		nlen = strlen( tmpres1[0] );
+		if( totallen + nlen > alloclen ) ErrorExit( "LENGTH OVER in Falign\n " );
+		for( j=0; j<clus1; j++ ) strcat( result1[j], tmpres1[j] );
+		for( j=0; j<clus2; j++ ) strcat( result2[j], tmpres2[j] );
+		totallen += nlen;
+#if 0
+		fprintf( stderr, "%4d\r", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+	}
+#if KEIKA
+	fprintf( stderr, "DP ... done   \n" );
+#endif
+
+	for( j=0; j<clus1; j++ ) strcpy( seq1[j], result1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( seq2[j], result2[j] );
+#if 0
+	for( j=0; j<clus1; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result1[j] );
+	}
+	fprintf( stderr, "- - - - - - - - - - -\n" );
+	for( j=0; j<clus2; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result2[j] );
+	}
+#endif
+	return( 0.0 );
+}
+float Falign( char  **seq1, char  **seq2, 
+			  double *eff1, double *eff2, 
+			  int    clus1, int    clus2,
+			  int alloclen, int *fftlog )
+{
+	int i, j, k, l, m, maxk;
+	int nlen, nlen2, nlen4;
+	static int prevalloclen = 0;
+	static int crossscoresize = 0;
+	static char **tmpseq1 = NULL;
+	static char **tmpseq2 = NULL;
+	static char **tmpptr1 = NULL;
+	static char **tmpptr2 = NULL;
+	static char **tmpres1 = NULL;
+	static char **tmpres2 = NULL;
+	static char **result1 = NULL;
+	static char **result2 = NULL;
+#if RND
+	static char **rndseq1 = NULL;
+	static char **rndseq2 = NULL;
+#endif
+	static Fukusosuu **seqVector1 = NULL;
+	static Fukusosuu **seqVector2 = NULL;
+	static Fukusosuu **naiseki = NULL;   
+	static Fukusosuu *naisekiNoWa = NULL; 
+	static double *soukan = NULL;
+	static double **crossscore = NULL;
+	int nlentmp;
+	static int *kouho = NULL;
+	static Segment *segment = NULL;
+	static Segment *segment1 = NULL;
+	static Segment *segment2 = NULL;
+	static Segment **sortedseg1 = NULL;
+	static Segment **sortedseg2 = NULL;
+	static int *cut1 = NULL;
+	static int *cut2 = NULL;
+	static char *sgap1, *egap1, *sgap2, *egap2;
+	static int localalloclen = 0;
+	int lag;
+	int tmpint;
+	int count, count0;
+	int len1, len2;
+	int totallen;
+	float totalscore;
+	float dumfl = 0.0;
+
+
+	len1 = strlen( seq1[0] );
+	len2 = strlen( seq2[0] );
+	nlentmp = MAX( len1, len2 );
+
+	nlen = 1;
+	while( nlentmp >= nlen ) nlen <<= 1;
+#if 0
+	fprintf( stderr, "###   nlen    = %d\n", nlen );
+#endif
+
+	nlen2 = nlen/2; nlen4 = nlen2 / 2;
+
+#if DEBUG
+	fprintf( stderr, "len1 = %d, len2 = %d\n", len1, len2 );
+	fprintf( stderr, "nlentmp = %d, nlen = %d\n", nlentmp, nlen );
+#endif
+
+	if( prevalloclen != alloclen ) // Falign_noudp mo kaeru
+	{
+		if( prevalloclen )
+		{
+			FreeCharMtx( result1 );
+			FreeCharMtx( result2 );
+			FreeCharMtx( tmpres1 );
+			FreeCharMtx( tmpres2 );
+		}
+//		fprintf( stderr, "\n\n\nreallocating ...\n" ); 
+		result1 = AllocateCharMtx( njob, alloclen );
+		result2 = AllocateCharMtx( njob, alloclen );
+		tmpres1 = AllocateCharMtx( njob, alloclen );
+		tmpres2 = AllocateCharMtx( njob, alloclen );
+		prevalloclen = alloclen;
+	}
+	if( !localalloclen )
+	{
+		sgap1 = AllocateCharVec( njob );
+		egap1 = AllocateCharVec( njob );
+		sgap2 = AllocateCharVec( njob );
+		egap2 = AllocateCharVec( njob );
+		kouho = AllocateIntVec( NKOUHO );
+		cut1 = AllocateIntVec( MAXSEG );
+		cut2 = AllocateIntVec( MAXSEG );
+		tmpptr1 = AllocateCharMtx( njob, 0 );
+		tmpptr2 = AllocateCharMtx( njob, 0 );
+//		crossscore = AllocateDoubleMtx( MAXSEG, MAXSEG );
+		segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment1 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment2 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		sortedseg1 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		sortedseg2 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		if( !( segment && segment1 && segment2 && sortedseg1 && sortedseg2 ) )
+			ErrorExit( "Allocation error\n" );
+
+		if     ( scoremtx == -1 ) n20or4or2 = 1;
+		else if( fftscore )       n20or4or2 = 1;
+		else                      n20or4or2 = 20;
+	}
+	if( localalloclen < nlen )
+	{
+		if( localalloclen )
+		{
+#if 1
+			if( !kobetsubunkatsu )
+			{
+				FreeFukusosuuMtx ( seqVector1 );
+				FreeFukusosuuMtx ( seqVector2 );
+				FreeFukusosuuVec( naisekiNoWa );
+				FreeFukusosuuMtx( naiseki );
+				FreeDoubleVec( soukan );
+			}
+			FreeCharMtx( tmpseq1 );
+			FreeCharMtx( tmpseq2 );
+#endif
+#if RND
+			FreeCharMtx( rndseq1 );
+			FreeCharMtx( rndseq2 );
+#endif
+		}
+
+		tmpseq1 = AllocateCharMtx( njob, nlen );
+		tmpseq2 = AllocateCharMtx( njob, nlen );
+		if( !kobetsubunkatsu )
+		{
+			naisekiNoWa = AllocateFukusosuuVec( nlen );
+			naiseki = AllocateFukusosuuMtx( n20or4or2, nlen );
+			seqVector1 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
+			seqVector2 = AllocateFukusosuuMtx( n20or4or2+1, nlen+1 );
+			soukan = AllocateDoubleVec( nlen+1 );
+		}
+#if RND
+		rndseq1 = AllocateCharMtx( njob, nlen );
+		rndseq2 = AllocateCharMtx( njob, nlen );
+		for( i=0; i<njob; i++ )
+		{
+			generateRndSeq( rndseq1[i], nlen );
+			generateRndSeq( rndseq2[i], nlen );
+		}
+#endif
+		localalloclen = nlen;
+	}
+	
+	for( j=0; j<clus1; j++ ) strcpy( tmpseq1[j], seq1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( tmpseq2[j], seq2[j] );
+
+#if 0
+fftfp = fopen( "input_of_Falign", "w" );
+fprintf( fftfp, "nlen = %d\n", nlen );
+fprintf( fftfp, "seq1: ( %d sequences ) \n", clus1 );
+for( i=0; i<clus1; i++ )
+	fprintf( fftfp, "%s\n", seq1[i] );
+fprintf( fftfp, "seq2: ( %d sequences ) \n", clus2 );
+for( i=0; i<clus2; i++ )
+	fprintf( fftfp, "%s\n", seq2[i] );
+fclose( fftfp );
+system( "less input_of_Falign < /dev/tty > /dev/tty" );
+#endif
+	if( !kobetsubunkatsu )
+	{
+		if( fftkeika ) fprintf( stderr,  " FFT ... " );
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector1[j], nlen );
+		if( fftscore && scoremtx != -1 )
+		{
+			for( i=0; i<clus1; i++ )
+			{
+#if 1
+				seq_vec_5( seqVector1[0], polarity, volume, eff1[i], tmpseq1[i] );
+#else
+				seq_vec_2( seqVector1[0], polarity, eff1[i], tmpseq1[i] );
+				seq_vec_2( seqVector1[1], volume,   eff1[i], tmpseq1[i] );
+#endif
+			}
+		}
+		else
+		{
+#if 0
+			for( i=0; i<clus1; i++ ) for( j=0; j<n20or4or2; j++ ) 
+				seq_vec( seqVector1[j], amino[j], eff1[i], tmpseq1[i] );
+#else
+			for( i=0; i<clus1; i++ )
+				seq_vec_3( seqVector1, eff1[i], tmpseq1[i] );
+#endif
+		}
+#if RND
+		for( i=0; i<clus1; i++ )
+		{
+			vec_init2( seqVector1, rndseq1[i], eff1[i], len1, nlen );
+		}
+#endif
+#if 0
+fftfp = fopen( "seqVec", "w" );
+fprintf( fftfp, "before transform\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "nlen=%d\n", nlen );
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector1[k][l].R, seqVector1[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector2[j], nlen );
+		if( fftscore && scoremtx != -1 )
+		{
+			for( i=0; i<clus2; i++ )
+			{
+#if 1
+				seq_vec_5( seqVector2[0], polarity, volume, eff2[i], tmpseq2[i] );
+#else
+				seq_vec_2( seqVector2[0], polarity, eff2[i], tmpseq2[i] );
+				seq_vec_2( seqVector2[1], volume,   eff2[i], tmpseq2[i] );
+#endif
+			}
+		}
+		else
+		{
+#if 0
+			for( i=0; i<clus2; i++ ) for( j=0; j<n20or4or2; j++ ) 
+				seq_vec( seqVector2[j], amino[j], eff2[i], tmpseq2[i] );
+#else
+			for( i=0; i<clus2; i++ )
+				seq_vec_3( seqVector2, eff2[i], tmpseq2[i] );
+#endif
+		}
+#if RND
+		for( i=0; i<clus2; i++ )
+		{
+			vec_init2( seqVector2, rndseq2[i], eff2[i], len2, nlen );
+		}
+#endif
+
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "before fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ )
+		{
+			fft( nlen, seqVector2[j], (j==0) );
+			fft( nlen, seqVector1[j], 0 );
+		}
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "#after fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "#%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+	   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( k=0; k<n20or4or2; k++ ) 
+		{
+			for( l=0; l<nlen; l++ ) 
+				calcNaiseki( naiseki[k]+l, seqVector1[k]+l, seqVector2[k]+l );
+		}
+		for( l=0; l<nlen; l++ ) 
+		{
+			naisekiNoWa[l].R = 0.0;
+			naisekiNoWa[l].I = 0.0;
+			for( k=0; k<n20or4or2; k++ ) 
+			{
+				naisekiNoWa[l].R += naiseki[k][l].R;
+				naisekiNoWa[l].I += naiseki[k][l].I;
+			}
+		}
+	
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#Before fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f %f\n", l, naisekiNoWa[l].R, naisekiNoWa[l].I ); 
+	fclose( fftfp );
+	system( "less naisekiNoWa < /dev/tty > /dev/tty " );
+#endif
+
+		fft( -nlen, naisekiNoWa, 0 );
+	
+		for( m=0; m<=nlen2; m++ ) 
+			soukan[m] = naisekiNoWa[nlen2-m].R;
+		for( m=nlen2+1; m<nlen; m++ ) 
+			soukan[m] = naisekiNoWa[nlen+nlen2-m].R;
+
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#After fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f\n", l, naisekiNoWa[l].R ); 
+	fclose( fftfp );
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'naisekiNoWa'\npause -1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot &" );
+#endif
+#if 0
+	fprintf( stderr, "soukan\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( stderr, "%d  %f\n", l-nlen2, soukan[l] ); 
+#if 0
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'frt'\n pause +1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot" );
+#endif
+#endif
+
+
+		getKouho( kouho, NKOUHO, soukan, nlen );
+
+#if 0
+		for( i=0; i<NKOUHO; i++ )
+		{
+			fprintf( stderr, "kouho[%d] = %d\n", i, kouho[i] );
+		}
+#endif
+	}
+
+#if KEIKA
+	fprintf( stderr, "Searching anchors ... " );
+#endif
+	count = 0;
+
+
+
+#define CAND 0
+#if CAND
+	fftfp = fopen( "cand", "w" );
+	fclose( fftfp );
+#endif
+	if( kobetsubunkatsu )
+	{
+		maxk = 1;
+		kouho[0] = 0;
+	}
+	else
+	{
+		maxk = NKOUHO;
+	}
+
+	for( k=0; k<maxk; k++ ) 
+	{
+		lag = kouho[k];
+		if( lag <= -len1 || len2 <= lag ) continue;
+		zurasu2( lag, clus1, clus2, seq1, seq2, tmpptr1, tmpptr2 );
+#if CAND
+		fftfp = fopen( "cand", "a" );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr1[0] );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr2[0] );
+		fprintf( fftfp, ">\n", k+1, lag );
+		fclose( fftfp );
+#endif
+
+//		fprintf( stderr, "lag = %d\n", lag );
+		tmpint = alignableReagion( clus1, clus2, tmpptr1, tmpptr2, eff1, eff2, segment+count );
+
+//		if( lag == -50 ) exit( 1 );
+		
+		if( count+tmpint > MAXSEG -3 ) ErrorExit( "TOO MANY SEGMENTS.\n" );
+
+
+		if( tmpint == 0 ) break; // 060430 iinoka ?
+		while( tmpint-- > 0 )
+		{
+#if 0
+			if( segment[count].end - segment[count].start < fftWinSize )
+			{
+				count++;
+				continue;
+			}
+#endif
+			if( lag > 0 )
+			{
+				segment1[count].start  = segment[count].start ;
+				segment1[count].end    = segment[count].end   ;
+				segment1[count].center = segment[count].center;
+				segment1[count].score  = segment[count].score;
+
+				segment2[count].start  = segment[count].start  + lag;
+				segment2[count].end    = segment[count].end    + lag;
+				segment2[count].center = segment[count].center + lag;
+				segment2[count].score  = segment[count].score       ;
+			}
+			else
+			{
+				segment1[count].start  = segment[count].start  - lag;
+				segment1[count].end    = segment[count].end    - lag;
+				segment1[count].center = segment[count].center - lag;
+				segment1[count].score  = segment[count].score       ;
+
+				segment2[count].start  = segment[count].start ;
+				segment2[count].end    = segment[count].end   ;
+				segment2[count].center = segment[count].center;
+				segment2[count].score  = segment[count].score ;
+			}
+#if 0
+			fprintf( stderr, "in 1 %d\n", segment1[count].center );
+			fprintf( stderr, "in 2 %d\n", segment2[count].center );
+#endif
+			segment1[count].pair = &segment2[count];
+			segment2[count].pair = &segment1[count];
+			count++;
+		}
+	}
+#if 0
+	if( !kobetsubunkatsu && fftkeika )
+		fprintf( stderr, "%d anchors found\r", count );
+#endif
+	if( !count && fftNoAnchStop )
+		ErrorExit( "Cannot detect anchor!" );
+#if 0
+	fprintf( stderr, "RESULT before sort:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( stderr, "%d score = %f\n", segment2[l].center, segment1[l].score );
+	}
+#endif
+
+#if KEIKA
+	fprintf( stderr, "done. (%d anchors)\n", count );
+	fprintf( stderr, "Aligning anchors ... " );
+#endif
+	for( i=0; i<count; i++ )
+	{
+		sortedseg1[i] = &segment1[i];
+		sortedseg2[i] = &segment2[i];
+	}
+#if 0
+	tmpsort( count, sortedseg1 ); 
+	tmpsort( count, sortedseg2 ); 
+	qsort( sortedseg1, count, sizeof( Segment * ), segcmp );
+	qsort( sortedseg2, count, sizeof( Segment * ), segcmp );
+#else
+	mymergesort( 0, count-1, sortedseg1 ); 
+	mymergesort( 0, count-1, sortedseg2 ); 
+#endif
+	for( i=0; i<count; i++ ) sortedseg1[i]->number = i;
+	for( i=0; i<count; i++ ) sortedseg2[i]->number = i;
+
+
+	if( kobetsubunkatsu )
+	{
+		for( i=0; i<count; i++ )
+	    {
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+		cut1[0] = 0;
+		cut2[0] = 0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+	}
+	else
+	{
+		if( crossscoresize < count+2 )
+		{
+			crossscoresize = count+2;
+#if 1
+			if( fftkeika ) fprintf( stderr, "######allocating crossscore, size = %d\n", crossscoresize );
+#endif
+			if( crossscore ) FreeDoubleMtx( crossscore );
+			crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
+		}
+		for( i=0; i<count+2; i++ ) for( j=0; j<count+2; j++ )
+			crossscore[i][j] = 0.0;
+		for( i=0; i<count; i++ )
+		{
+			crossscore[segment1[i].number+1][segment1[i].pair->number+1] = segment1[i].score;
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+
+#if 0
+		fprintf( stderr, "AFTER SORT\n" );
+		for( i=0; i<count+1; i++ ) fprintf( stderr, "%d, %d\n", cut1[i], cut2[i] );
+		fprintf( stderr, "crossscore = \n" );
+		for( i=0; i<count+1; i++ )
+		{
+			for( j=0; j<count+1; j++ )
+				fprintf( stderr, "%.0f ", crossscore[i][j] );
+			fprintf( stderr, "\n" );
+		}
+#endif
+
+		crossscore[0][0] = 10000000.0;
+		cut1[0] = 0; 
+		cut2[0] = 0;
+		crossscore[count+1][count+1] = 10000000.0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+		count0 = count;
+	
+		blockAlign2( cut1, cut2, sortedseg1, sortedseg2, crossscore, &count );
+
+//		if( count-count0 )
+//			fprintf( stderr, "%d unused anchors\n", count0-count );
+
+		if( !kobetsubunkatsu && fftkeika )
+			fprintf( stderr, "%d anchors found\n", count );
+		if( fftkeika )
+		{
+			if( count0 > count )
+			{
+#if 0
+				fprintf( stderr, "\7 REPEAT!? \n" ); 
+#else
+				fprintf( stderr, "REPEAT!? \n" ); 
+#endif
+				if( fftRepeatStop ) exit( 1 );
+			}
+#if KEIKA
+			else fprintf( stderr, "done\n" );
+#endif
+		}
+	}
+
+#if 0
+	fftfp = fopen( "fft", "a" );
+	fprintf( fftfp, "RESULT after sort:\n" );
+	for( l=0; l<count; l++ )
+	{
+		fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( fftfp, "%d\n", segment2[l].center );
+	}
+	fclose( fftfp );
+#endif
+
+#if 0
+	fprintf( stderr, "RESULT after blckalign:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut : %d %d\n", cut1[l], cut2[l] );
+	}
+#endif
+
+#if 0
+	fprintf( trap_g, "Devided to %d segments\n", count-1 );
+	fprintf( trap_g, "%d  %d forg\n", MIN( clus1, clus2 ), count-1 );
+#endif
+
+	totallen = 0;
+	for( j=0; j<clus1; j++ ) result1[j][0] = 0;
+	for( j=0; j<clus2; j++ ) result2[j][0] = 0;
+	totalscore = 0.0;
+	*fftlog = -1;
+	for( i=0; i<count-1; i++ )
+	{
+		*fftlog += 1;
+
+		if( cut1[i] ) // chuui
+		{
+//			getkyokaigap( sgap1, tmpres1, nlen-1, clus1 );
+//			getkyokaigap( sgap2, tmpres2, nlen-1, clus2 );
+			getkyokaigap( sgap1, tmpres1, nlen-1, clus1 );
+			getkyokaigap( sgap2, tmpres2, nlen-1, clus2 );
+		}
+		else
+		{
+			for( j=0; j<clus1; j++ ) sgap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) sgap2[j] = 'o';
+		}
+		if( cut1[i+1] != len1 ) // chuui
+		{       
+			getkyokaigap( egap1, seq1, cut1[i+1], clus1 );
+			getkyokaigap( egap2, seq2, cut2[i+1], clus2 );
+		}       
+		else    
+		{       
+			for( j=0; j<clus1; j++ ) egap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) egap2[j] = 'o';
+		}
+#if 0
+		{
+			fprintf( stderr, "kyokkaigap1(%d)=", cut1[i]-1 );
+			for( j=0; j<clus1; j++ )
+				fprintf( stderr, "%c", sgap1[j] );
+			fprintf( stderr, "=kyokkaigap1-start\n" );
+		}
+		{
+			fprintf( stderr, "kyokkaigap2(%d)=", cut2[i]-1 );
+			for( j=0; j<clus2; j++ )
+				fprintf( stderr, "%c", sgap2[j] );
+			fprintf( stderr, "=kyokkaigap2-start\n" );
+		}
+		{
+			fprintf( stderr, "kyokkaigap1(%d)=", cut1[i]-1 );
+			for( j=0; j<clus1; j++ )
+				fprintf( stderr, "%c", egap1[j] );
+			fprintf( stderr, "=kyokkaigap1-end\n" );
+		}
+		{
+			fprintf( stderr, "kyokkaigap2(%d)=", cut2[i]-1 );
+			for( j=0; j<clus2; j++ )
+				fprintf( stderr, "%c", egap2[j] );
+			fprintf( stderr, "=kyokkaigap2-end\n" );
+		}
+#endif
+
+#if DEBUG
+		fprintf( stderr, "DP %03d / %03d %4d to ", i+1, count-1, totallen );
+#else
+#if KEIKA
+		fprintf( stderr, "DP %03d / %03d\r", i+1, count-1 );
+#endif
+#endif
+		for( j=0; j<clus1; j++ )
+		{
+			strncpy( tmpres1[j], seq1[j]+cut1[i], cut1[i+1]-cut1[i] );
+			tmpres1[j][cut1[i+1]-cut1[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus1, tmpres1 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus1, tmpres1 );
+		for( j=0; j<clus2; j++ )
+		{
+			strncpy( tmpres2[j], seq2[j]+cut2[i], cut2[i+1]-cut2[i] );
+			tmpres2[j][cut2[i+1]-cut2[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus2, tmpres2 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus2, tmpres2 );
+
+		if( constraint )
+		{
+			fprintf( stderr, "Not supported\n" );
+			exit( 1 );
+		}
+#if 0
+		fprintf( stderr, "i=%d, before alignment", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+
+#if 0
+		fprintf( stdout, "writing input\n" );
+		for( j=0; j<clus1; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP1\n", j );
+			fprintf( stdout, "%s\n", tmpres1[j] );
+		}
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP2\n", j );
+			fprintf( stdout, "%s\n", tmpres2[j] );
+		}
+		fflush( stdout );
+#endif
+		switch( alg )
+		{
+			case( 'a' ):
+				totalscore += Aalign( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen );
+				break;
+			case( 'M' ):
+					totalscore += MSalignmm( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, sgap1, sgap2, egap1, egap2 );
+				break;
+			case( 'A' ):
+				if( clus1 == 1 && clus2 == 1 )
+				{
+					totalscore += G__align11( tmpres1, tmpres2, alloclen );
+				}
+				else
+					totalscore += A__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, sgap1, sgap2, egap1, egap2 );
+				break;
+			case( 'H' ):
+				if( clus1 == 1 && clus2 == 1 )
+				{
+					totalscore += G__align11( tmpres1, tmpres2, alloclen );
+				}
+				else
+					totalscore += H__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, sgap1, sgap2, egap1, egap2 );
+				break;
+			case( 'Q' ):
+				if( clus1 == 1 && clus2 == 1 )
+				{
+					totalscore += G__align11( tmpres1, tmpres2, alloclen );
+				}
+				else
+					totalscore += Q__align( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, NULL, &dumfl, sgap1, sgap2, egap1, egap2 );
+				break;
+			default:
+				fprintf( stderr, "alg = %c\n", alg );
+				ErrorExit( "ERROR IN SOURCE FILE Falign.c" );
+				break;
+		}
+
+		nlen = strlen( tmpres1[0] );
+		if( totallen + nlen > alloclen )
+		{
+			fprintf( stderr, "totallen=%d +  nlen=%d > alloclen = %d\n", totallen, nlen, alloclen );
+			ErrorExit( "LENGTH OVER in Falign\n " );
+		}
+		for( j=0; j<clus1; j++ ) strcat( result1[j], tmpres1[j] );
+		for( j=0; j<clus2; j++ ) strcat( result2[j], tmpres2[j] );
+		totallen += nlen;
+#if 0
+		fprintf( stderr, "i=%d", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+	}
+#if KEIKA
+	fprintf( stderr, "DP ... done   \n" );
+#endif
+
+	for( j=0; j<clus1; j++ ) strcpy( seq1[j], result1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( seq2[j], result2[j] );
+#if 0
+	for( j=0; j<clus1; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result1[j] );
+	}
+	fprintf( stderr, "- - - - - - - - - - -\n" );
+	for( j=0; j<clus2; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result2[j] );
+	}
+#endif
+	return( totalscore );
+}
+
+
+
+
+
+
+
+
+float Falign_noudp( char  **seq1, char  **seq2, 
+			  double *eff1, double *eff2, 
+			  int    clus1, int    clus2,
+			  int alloclen, int *fftlog )
+{
+	int i, j, k, l, m, maxk;
+	int nlen, nlen2, nlen4;
+	static int prevalloclen = 0;
+//	static int crossscoresize = 0;
+	static char **tmpseq1 = NULL;
+	static char **tmpseq2 = NULL;
+	static char **tmpptr1 = NULL;
+	static char **tmpptr2 = NULL;
+	static char **tmpres1 = NULL;
+	static char **tmpres2 = NULL;
+	static char **result1 = NULL;
+	static char **result2 = NULL;
+#if RND
+	static char **rndseq1 = NULL;
+	static char **rndseq2 = NULL;
+#endif
+	static Fukusosuu **seqVector1 = NULL;
+	static Fukusosuu **seqVector2 = NULL;
+	static Fukusosuu **naiseki = NULL;   
+	static Fukusosuu *naisekiNoWa = NULL; 
+	static double *soukan = NULL;
+	int nlentmp;
+	static int *kouho = NULL;
+	static Segment *segment = NULL;
+	static Segment *segment1 = NULL;
+	static Segment *segment2 = NULL;
+	static Segment **sortedseg1 = NULL;
+	static Segment **sortedseg2 = NULL;
+	static int *cut1 = NULL;
+	static int *cut2 = NULL;
+	static char *sgap1, *egap1, *sgap2, *egap2;
+	static int localalloclen = 0;
+	int lag;
+	int tmpint;
+	int count, count0;
+	int len1, len2;
+	int totallen;
+	float totalscore;
+	int nkouho;
+//	float dumfl = 0.0;
+
+
+	len1 = strlen( seq1[0] );
+	len2 = strlen( seq2[0] );
+	nlentmp = MAX( len1, len2 );
+
+	nlen = 1;
+	while( nlentmp >= nlen ) nlen <<= 1;
+#if 0
+	fprintf( stderr, "###   nlen    = %d\n", nlen );
+#endif
+
+	nlen2 = nlen/2; nlen4 = nlen2 / 2;
+
+#if 0
+	fprintf( stderr, "len1 = %d, len2 = %d\n", len1, len2 );
+	fprintf( stderr, "nlentmp = %d, nlen = %d\n", nlentmp, nlen );
+#endif
+
+	if( prevalloclen != alloclen ) // Falign_noudp mo kaeru
+	{
+		if( prevalloclen )
+		{
+			FreeCharMtx( result1 );
+			FreeCharMtx( result2 );
+			FreeCharMtx( tmpres1 );
+			FreeCharMtx( tmpres2 );
+		}
+//		fprintf( stderr, "\n\n\nreallocating ...\n" ); 
+		result1 = AllocateCharMtx( njob, alloclen );
+		result2 = AllocateCharMtx( njob, alloclen );
+		tmpres1 = AllocateCharMtx( njob, alloclen );
+		tmpres2 = AllocateCharMtx( njob, alloclen );
+		prevalloclen = alloclen;
+	}
+
+	if( !localalloclen )
+	{
+		sgap1 = AllocateCharVec( njob );
+		egap1 = AllocateCharVec( njob );
+		sgap2 = AllocateCharVec( njob );
+		egap2 = AllocateCharVec( njob );
+		kouho = AllocateIntVec( NKOUHO_LONG );
+		cut1 = AllocateIntVec( MAXSEG );
+		cut2 = AllocateIntVec( MAXSEG );
+		tmpptr1 = AllocateCharMtx( njob, 0 );
+		tmpptr2 = AllocateCharMtx( njob, 0 );
+		segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment1 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment2 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		sortedseg1 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		sortedseg2 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		if( !( segment && segment1 && segment2 && sortedseg1 && sortedseg2 ) )
+			ErrorExit( "Allocation error\n" );
+
+		if     ( scoremtx == -1 ) n20or4or2 = 1;
+		else if( fftscore )       n20or4or2 = 1;
+		else                      n20or4or2 = 20;
+	}
+	if( localalloclen < nlen )
+	{
+		if( localalloclen )
+		{
+#if 1
+			if( !kobetsubunkatsu )
+			{
+				FreeFukusosuuMtx ( seqVector1 );
+				FreeFukusosuuMtx ( seqVector2 );
+				FreeFukusosuuVec( naisekiNoWa );
+				FreeFukusosuuMtx( naiseki );
+				FreeDoubleVec( soukan );
+			}
+			FreeCharMtx( tmpseq1 );
+			FreeCharMtx( tmpseq2 );
+#endif
+#if RND
+			FreeCharMtx( rndseq1 );
+			FreeCharMtx( rndseq2 );
+#endif
+		}
+
+
+		tmpseq1 = AllocateCharMtx( njob, nlen );
+		tmpseq2 = AllocateCharMtx( njob, nlen );
+		if( !kobetsubunkatsu )
+		{
+			naisekiNoWa = AllocateFukusosuuVec( nlen );
+			naiseki = AllocateFukusosuuMtx( n20or4or2, nlen );
+			seqVector1 = AllocateFukusosuuMtx( n20or4or2, nlen+1 );
+			seqVector2 = AllocateFukusosuuMtx( n20or4or2, nlen+1 );
+			soukan = AllocateDoubleVec( nlen+1 );
+		}
+#if RND
+		rndseq1 = AllocateCharMtx( njob, nlen );
+		rndseq2 = AllocateCharMtx( njob, nlen );
+		for( i=0; i<njob; i++ )
+		{
+			generateRndSeq( rndseq1[i], nlen );
+			generateRndSeq( rndseq2[i], nlen );
+		}
+#endif
+		localalloclen = nlen;
+	}
+	
+	for( j=0; j<clus1; j++ ) strcpy( tmpseq1[j], seq1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( tmpseq2[j], seq2[j] );
+
+#if 0
+fftfp = fopen( "input_of_Falign", "w" );
+fprintf( fftfp, "nlen = %d\n", nlen );
+fprintf( fftfp, "seq1: ( %d sequences ) \n", clus1 );
+for( i=0; i<clus1; i++ )
+	fprintf( fftfp, "%s\n", seq1[i] );
+fprintf( fftfp, "seq2: ( %d sequences ) \n", clus2 );
+for( i=0; i<clus2; i++ )
+	fprintf( fftfp, "%s\n", seq2[i] );
+fclose( fftfp );
+system( "less input_of_Falign < /dev/tty > /dev/tty" );
+#endif
+	if( !kobetsubunkatsu )
+	{
+		fprintf( stderr,  " FFT ... " );
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector1[j], nlen );
+		if( scoremtx == -1 )
+		{
+			for( i=0; i<clus1; i++ )
+				seq_vec_4( seqVector1[0], eff1[i], tmpseq1[i] );
+		}
+		else if( fftscore )
+		{
+			for( i=0; i<clus1; i++ )
+			{
+#if 0
+				seq_vec_2( seqVector1[0], polarity, eff1[i], tmpseq1[i] );
+				seq_vec_2( seqVector1[1], volume,   eff1[i], tmpseq1[i] );
+#else
+				seq_vec_5( seqVector1[0], polarity, volume, eff1[i], tmpseq1[i] );
+#endif
+			}
+		}
+		else
+		{
+			for( i=0; i<clus1; i++ )
+				seq_vec_3( seqVector1, eff1[i], tmpseq1[i] );
+		}
+#if RND
+		for( i=0; i<clus1; i++ )
+		{
+			vec_init2( seqVector1, rndseq1[i], eff1[i], len1, nlen );
+		}
+#endif
+#if 0
+fftfp = fopen( "seqVec", "w" );
+fprintf( fftfp, "before transform\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "nlen=%d\n", nlen );
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector1[k][l].R, seqVector1[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector2[j], nlen );
+		if( scoremtx == -1 )
+		{
+			for( i=0; i<clus2; i++ )
+				seq_vec_4( seqVector2[0], eff2[i], tmpseq2[i] );
+		}
+		else if( fftscore )
+		{
+			for( i=0; i<clus2; i++ )
+			{
+#if 0
+				seq_vec_2( seqVector2[0], polarity, eff2[i], tmpseq2[i] );
+				seq_vec_2( seqVector2[1], volume,   eff2[i], tmpseq2[i] );
+#else
+				seq_vec_5( seqVector2[0], polarity, volume, eff2[i], tmpseq2[i] );
+#endif
+			}
+		}
+		else
+		{
+			for( i=0; i<clus2; i++ )
+				seq_vec_3( seqVector2, eff2[i], tmpseq2[i] );
+		}
+#if RND
+		for( i=0; i<clus2; i++ )
+		{
+			vec_init2( seqVector2, rndseq2[i], eff2[i], len2, nlen );
+		}
+#endif
+
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "before fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ )
+		{
+			fft( nlen, seqVector2[j], (j==0) );
+			fft( nlen, seqVector1[j], 0 );
+		}
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "#after fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "#%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+	   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( k=0; k<n20or4or2; k++ ) 
+		{
+			for( l=0; l<nlen; l++ ) 
+				calcNaiseki( naiseki[k]+l, seqVector1[k]+l, seqVector2[k]+l );
+		}
+		for( l=0; l<nlen; l++ ) 
+		{
+			naisekiNoWa[l].R = 0.0;
+			naisekiNoWa[l].I = 0.0;
+			for( k=0; k<n20or4or2; k++ ) 
+			{
+				naisekiNoWa[l].R += naiseki[k][l].R;
+				naisekiNoWa[l].I += naiseki[k][l].I;
+			}
+		}
+	
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#Before fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f %f\n", l, naisekiNoWa[l].R, naisekiNoWa[l].I ); 
+	fclose( fftfp );
+	system( "less naisekiNoWa < /dev/tty > /dev/tty " );
+#endif
+
+		fft( -nlen, naisekiNoWa, 0 );
+	
+		for( m=0; m<=nlen2; m++ ) 
+			soukan[m] = naisekiNoWa[nlen2-m].R;
+		for( m=nlen2+1; m<nlen; m++ ) 
+			soukan[m] = naisekiNoWa[nlen+nlen2-m].R;
+
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#After fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f\n", l, naisekiNoWa[l].R ); 
+	fclose( fftfp );
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'naisekiNoWa'\npause -1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot &" );
+#endif
+#if 0
+	fprintf( stderr, "soukan\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( stderr, "%d  %f\n", l-nlen2, soukan[l] ); 
+#if 0
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'frt'\n pause +1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot" );
+#endif
+#endif
+
+
+		nkouho = getKouho( kouho, NKOUHO_LONG, soukan, nlen );
+
+#if 0
+		for( i=0; i<nkouho; i++ )
+		{
+			fprintf( stderr, "kouho[%d] = %d\n", i, kouho[i] );
+		}
+#endif
+	}
+
+#if KEIKA
+	fprintf( stderr, "Searching anchors ... " );
+#endif
+	count = 0;
+
+
+
+#define CAND 0
+#if CAND
+	fftfp = fopen( "cand", "w" );
+	fclose( fftfp );
+#endif
+	if( kobetsubunkatsu )
+	{
+		maxk = 1;
+		kouho[0] = 0;
+	}
+	else
+	{
+		maxk = nkouho;
+	}
+
+	for( k=0; k<maxk; k++ ) 
+	{
+		lag = kouho[k];
+		if( lag <= -len1 || len2 <= lag ) continue;
+//		fprintf( stderr, "k=%d, lag=%d\n", k, lag );
+		zurasu2( lag, clus1, clus2, seq1, seq2, tmpptr1, tmpptr2 );
+#if CAND
+		fftfp = fopen( "cand", "a" );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr1[0] );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr2[0] );
+		fprintf( fftfp, ">\n", k+1, lag );
+		fclose( fftfp );
+#endif
+
+//		fprintf( stderr, "lag = %d\n", lag );
+		tmpint = alignableReagion( clus1, clus2, tmpptr1, tmpptr2, eff1, eff2, segment+count );
+//		fprintf( stderr, "lag = %d, %d found\n", lag, tmpint );
+
+//		if( lag == -50 ) exit( 1 );
+		
+		if( count+tmpint > MAXSEG -3 ) ErrorExit( "TOO MANY SEGMENTS.\n" );
+
+//		fprintf( stderr, "##### k=%d / %d\n", k, maxk );
+		if( tmpint == 0 ) break; // 060430 iinoka ?
+		while( tmpint-- > 0 )
+		{
+#if 0
+			if( segment[count].end - segment[count].start < fftWinSize )
+			{
+				count++;
+				continue;
+			}
+#endif
+			if( lag > 0 )
+			{
+				segment1[count].start  = segment[count].start ;
+				segment1[count].end    = segment[count].end   ;
+				segment1[count].center = segment[count].center;
+				segment1[count].score  = segment[count].score;
+
+				segment2[count].start  = segment[count].start  + lag;
+				segment2[count].end    = segment[count].end    + lag;
+				segment2[count].center = segment[count].center + lag;
+				segment2[count].score  = segment[count].score       ;
+			}
+			else
+			{
+				segment1[count].start  = segment[count].start  - lag;
+				segment1[count].end    = segment[count].end    - lag;
+				segment1[count].center = segment[count].center - lag;
+				segment1[count].score  = segment[count].score       ;
+
+				segment2[count].start  = segment[count].start ;
+				segment2[count].end    = segment[count].end   ;
+				segment2[count].center = segment[count].center;
+				segment2[count].score  = segment[count].score ;
+			}
+#if 0
+			fprintf( stderr, "##### k=%d / %d\n", k, maxk );
+			fprintf( stderr, "anchor %d, score = %f\n", count, segment1[count].score );
+			fprintf( stderr, "in 1 %d\n", segment1[count].center );
+			fprintf( stderr, "in 2 %d\n", segment2[count].center );
+#endif
+			segment1[count].pair = &segment2[count];
+			segment2[count].pair = &segment1[count];
+			count++;
+#if 0
+			fprintf( stderr, "count=%d\n", count );
+#endif
+		}
+	}
+#if 1
+	if( !kobetsubunkatsu )
+		fprintf( stderr, "done. (%d anchors) ", count );
+#endif
+	if( !count && fftNoAnchStop )
+		ErrorExit( "Cannot detect anchor!" );
+#if 0
+	fprintf( stderr, "RESULT before sort:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( stderr, "%d score = %f\n", segment2[l].center, segment1[l].score );
+	}
+#endif
+
+	for( i=0; i<count; i++ )
+	{
+		sortedseg1[i] = &segment1[i];
+		sortedseg2[i] = &segment2[i];
+	}
+#if 0
+	tmpsort( count, sortedseg1 ); 
+	tmpsort( count, sortedseg2 ); 
+	qsort( sortedseg1, count, sizeof( Segment * ), segcmp );
+	qsort( sortedseg2, count, sizeof( Segment * ), segcmp );
+#else
+	mymergesort( 0, count-1, sortedseg1 ); 
+	mymergesort( 0, count-1, sortedseg2 ); 
+#endif
+	for( i=0; i<count; i++ ) sortedseg1[i]->number = i;
+	for( i=0; i<count; i++ ) sortedseg2[i]->number = i;
+
+
+
+	if( kobetsubunkatsu )
+	{
+		for( i=0; i<count; i++ )
+	    {
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+		cut1[0] = 0;
+		cut2[0] = 0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+	}
+	else
+	{
+		cut1[0] = 0; 
+		cut2[0] = 0;
+		count0 = 0;
+		for( i=0; i<count; i++ )
+		{
+//			fprintf( stderr, "i=%d, %d-%d ?\n", i, sortedseg1[i]->center, sortedseg1[i]->pair->center );
+			if( sortedseg1[i]->center > cut1[count0]
+			 && sortedseg1[i]->pair->center > cut2[count0] )
+			{
+				count0++;
+				cut1[count0] = sortedseg1[i]->center;
+				cut2[count0] = sortedseg1[i]->pair->center;
+			}
+			else
+			{
+				if( i && sortedseg1[i]->score > sortedseg1[i-1]->score )
+				{
+					if( sortedseg1[i]->center > cut1[count0-1]
+					 && sortedseg1[i]->pair->center > cut2[count0-1] )
+					{
+						cut1[count0] = sortedseg1[i]->center;
+						cut2[count0] = sortedseg1[i]->pair->center;
+					}
+					else
+					{
+//						count0--;
+					}
+				}
+			}
+		}
+//		if( count-count0 )
+//			fprintf( stderr, "%d anchors unused\n", count-count0 );
+		cut1[count0+1] = len1;
+		cut2[count0+1] = len2;
+		count = count0 + 2;
+		count0 = count;
+
+	}
+
+//	exit( 0 );
+
+#if 0
+	fftfp = fopen( "fft", "a" );
+	fprintf( fftfp, "RESULT after sort:\n" );
+	for( l=0; l<count; l++ )
+	{
+		fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( fftfp, "%d\n", segment2[l].center );
+	}
+	fclose( fftfp );
+#endif
+
+#if 0
+	fprintf( stderr, "RESULT after blckalign:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut : %d %d\n", cut1[l], cut2[l] );
+	}
+#endif
+
+#if 0
+	fprintf( trap_g, "Devided to %d segments\n", count-1 );
+	fprintf( trap_g, "%d  %d forg\n", MIN( clus1, clus2 ), count-1 );
+#endif
+
+	totallen = 0;
+	for( j=0; j<clus1; j++ ) result1[j][0] = 0;
+	for( j=0; j<clus2; j++ ) result2[j][0] = 0;
+	totalscore = 0.0;
+	*fftlog = -1;
+	for( i=0; i<count-1; i++ )
+	{
+		*fftlog += 1;
+
+		if( cut1[i] )
+		{
+//			getkyokaigap( sgap1, seq1, cut1[i]-1, clus1 );
+//			getkyokaigap( sgap2, seq2, cut2[i]-1, clus2 );
+			getkyokaigap( sgap1, tmpres1, nlen-1, clus1 );
+			getkyokaigap( sgap2, tmpres2, nlen-1, clus2 );
+		}
+		else
+		{
+			for( j=0; j<clus1; j++ ) sgap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) sgap2[j] = 'o';
+		}
+		if( cut1[i+1] != len1 )
+		{       
+			getkyokaigap( egap1, seq1, cut1[i+1], clus1 );
+			getkyokaigap( egap2, seq2, cut2[i+1], clus2 );
+		}       
+		else    
+		{       
+			for( j=0; j<clus1; j++ ) egap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) egap2[j] = 'o';
+		}
+#if DEBUG
+		fprintf( stderr, "DP %03d / %03d %4d to ", i+1, count-1, totallen );
+#else
+#if 1
+		fprintf( stderr, "DP %05d / %05d \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i+1, count-1 );
+#endif
+#endif
+		for( j=0; j<clus1; j++ )
+		{
+			strncpy( tmpres1[j], seq1[j]+cut1[i], cut1[i+1]-cut1[i] );
+			tmpres1[j][cut1[i+1]-cut1[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus1, tmpres1 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus1, tmpres1 );
+		for( j=0; j<clus2; j++ )
+		{
+//			fprintf( stderr, "### cut2[i+1]-cut2[i] = %d\n", cut2[i+1]-cut2[i] );
+			if( cut2[i+1]-cut2[i] <= 0 )
+				fprintf( stderr, "### cut2[i+1]=%d, cut2[i]=%d\n", cut2[i+1], cut2[i] );
+			strncpy( tmpres2[j], seq2[j]+cut2[i], cut2[i+1]-cut2[i] );
+			tmpres2[j][cut2[i+1]-cut2[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus2, tmpres2 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus2, tmpres2 );
+
+		if( constraint )
+		{
+			fprintf( stderr, "Not supported\n" );
+			exit( 1 );
+		}
+#if 0
+		fprintf( stderr, "i=%d, before alignment", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+
+#if 0
+		fprintf( stdout, "writing input\n" );
+		for( j=0; j<clus1; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP1\n", j );
+			fprintf( stdout, "%s\n", tmpres1[j] );
+		}
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP2\n", j );
+			fprintf( stdout, "%s\n", tmpres2[j] );
+		}
+		fflush( stdout );
+#endif
+		switch( alg )
+		{
+			case( 'M' ):
+					totalscore += MSalignmm( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, sgap1, sgap2, egap1, egap2 );
+				break;
+			default:
+				fprintf( stderr, "alg = %c\n", alg );
+				ErrorExit( "ERROR IN SOURCE FILE Falign.c" );
+				break;
+		}
+
+		nlen = strlen( tmpres1[0] );
+		if( totallen + nlen > alloclen )
+		{
+			fprintf( stderr, "totallen=%d +  nlen=%d > alloclen = %d\n", totallen, nlen, alloclen );
+			ErrorExit( "LENGTH OVER in Falign\n " );
+		}
+		for( j=0; j<clus1; j++ ) strcat( result1[j], tmpres1[j] );
+		for( j=0; j<clus2; j++ ) strcat( result2[j], tmpres2[j] );
+		totallen += nlen;
+#if 0
+		fprintf( stderr, "i=%d", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+	}
+#if KEIKA
+	fprintf( stderr, "DP ... done   \n" );
+#endif
+
+	for( j=0; j<clus1; j++ ) strcpy( seq1[j], result1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( seq2[j], result2[j] );
+#if 0
+	for( j=0; j<clus1; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result1[j] );
+	}
+	fprintf( stderr, "- - - - - - - - - - -\n" );
+	for( j=0; j<clus2; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result2[j] );
+	}
+#endif
+	return( totalscore );
+}
+
+float Falign_udpari_long( char  **seq1, char  **seq2, 
+			  double *eff1, double *eff2, 
+			  int    clus1, int    clus2,
+			  int alloclen, int *fftlog )
+{
+	int i, j, k, l, m, maxk;
+	int nlen, nlen2, nlen4;
+	static int prevalloclen = 0;
+	static int crossscoresize = 0;
+	static char **tmpseq1 = NULL;
+	static char **tmpseq2 = NULL;
+	static char **tmpptr1 = NULL;
+	static char **tmpptr2 = NULL;
+	static char **tmpres1 = NULL;
+	static char **tmpres2 = NULL;
+	static char **result1 = NULL;
+	static char **result2 = NULL;
+#if RND
+	static char **rndseq1 = NULL;
+	static char **rndseq2 = NULL;
+#endif
+	static Fukusosuu **seqVector1 = NULL;
+	static Fukusosuu **seqVector2 = NULL;
+	static Fukusosuu **naiseki = NULL;   
+	static Fukusosuu *naisekiNoWa = NULL; 
+	static double *soukan = NULL;
+	static double **crossscore = NULL;
+	int nlentmp;
+	static int *kouho = NULL;
+	static Segment *segment = NULL;
+	static Segment *segment1 = NULL;
+	static Segment *segment2 = NULL;
+	static Segment **sortedseg1 = NULL;
+	static Segment **sortedseg2 = NULL;
+	static int *cut1 = NULL;
+	static int *cut2 = NULL;
+	static char *sgap1, *egap1, *sgap2, *egap2;
+	static int localalloclen = 0;
+	int lag;
+	int tmpint;
+	int count, count0;
+	int len1, len2;
+	int totallen;
+	float totalscore;
+	int nkouho;
+//	float dumfl = 0.0;
+
+
+	len1 = strlen( seq1[0] );
+	len2 = strlen( seq2[0] );
+	nlentmp = MAX( len1, len2 );
+
+	nlen = 1;
+	while( nlentmp >= nlen ) nlen <<= 1;
+#if 0
+	fprintf( stderr, "###   nlen    = %d\n", nlen );
+#endif
+
+	nlen2 = nlen/2; nlen4 = nlen2 / 2;
+
+#if 0
+	fprintf( stderr, "len1 = %d, len2 = %d\n", len1, len2 );
+	fprintf( stderr, "nlentmp = %d, nlen = %d\n", nlentmp, nlen );
+#endif
+
+	if( prevalloclen != alloclen ) // Falign_noudp mo kaeru
+	{
+		if( prevalloclen )
+		{
+			FreeCharMtx( result1 );
+			FreeCharMtx( result2 );
+			FreeCharMtx( tmpres1 );
+			FreeCharMtx( tmpres2 );
+		}
+//		fprintf( stderr, "\n\n\nreallocating ...\n" ); 
+		result1 = AllocateCharMtx( njob, alloclen );
+		result2 = AllocateCharMtx( njob, alloclen );
+		tmpres1 = AllocateCharMtx( njob, alloclen );
+		tmpres2 = AllocateCharMtx( njob, alloclen );
+		prevalloclen = alloclen;
+	}
+
+	if( !localalloclen )
+	{
+		sgap1 = AllocateCharVec( njob );
+		egap1 = AllocateCharVec( njob );
+		sgap2 = AllocateCharVec( njob );
+		egap2 = AllocateCharVec( njob );
+		kouho = AllocateIntVec( NKOUHO_LONG );
+		cut1 = AllocateIntVec( MAXSEG );
+		cut2 = AllocateIntVec( MAXSEG );
+		tmpptr1 = AllocateCharMtx( njob, 0 );
+		tmpptr2 = AllocateCharMtx( njob, 0 );
+		segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment1 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		segment2 = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
+		sortedseg1 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		sortedseg2 = (Segment **)calloc( MAXSEG, sizeof( Segment * ) );
+		if( !( segment && segment1 && segment2 && sortedseg1 && sortedseg2 ) )
+			ErrorExit( "Allocation error\n" );
+
+		if     ( scoremtx == -1 ) n20or4or2 = 1;
+		else if( fftscore )       n20or4or2 = 1;
+		else                      n20or4or2 = 20;
+	}
+	if( localalloclen < nlen )
+	{
+		if( localalloclen )
+		{
+#if 1
+			if( !kobetsubunkatsu )
+			{
+				FreeFukusosuuMtx ( seqVector1 );
+				FreeFukusosuuMtx ( seqVector2 );
+				FreeFukusosuuVec( naisekiNoWa );
+				FreeFukusosuuMtx( naiseki );
+				FreeDoubleVec( soukan );
+			}
+			FreeCharMtx( tmpseq1 );
+			FreeCharMtx( tmpseq2 );
+#endif
+#if RND
+			FreeCharMtx( rndseq1 );
+			FreeCharMtx( rndseq2 );
+#endif
+		}
+
+
+		tmpseq1 = AllocateCharMtx( njob, nlen );
+		tmpseq2 = AllocateCharMtx( njob, nlen );
+		if( !kobetsubunkatsu )
+		{
+			naisekiNoWa = AllocateFukusosuuVec( nlen );
+			naiseki = AllocateFukusosuuMtx( n20or4or2, nlen );
+			seqVector1 = AllocateFukusosuuMtx( n20or4or2, nlen+1 );
+			seqVector2 = AllocateFukusosuuMtx( n20or4or2, nlen+1 );
+			soukan = AllocateDoubleVec( nlen+1 );
+		}
+#if RND
+		rndseq1 = AllocateCharMtx( njob, nlen );
+		rndseq2 = AllocateCharMtx( njob, nlen );
+		for( i=0; i<njob; i++ )
+		{
+			generateRndSeq( rndseq1[i], nlen );
+			generateRndSeq( rndseq2[i], nlen );
+		}
+#endif
+		localalloclen = nlen;
+	}
+	
+	for( j=0; j<clus1; j++ ) strcpy( tmpseq1[j], seq1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( tmpseq2[j], seq2[j] );
+
+#if 0
+fftfp = fopen( "input_of_Falign", "w" );
+fprintf( fftfp, "nlen = %d\n", nlen );
+fprintf( fftfp, "seq1: ( %d sequences ) \n", clus1 );
+for( i=0; i<clus1; i++ )
+	fprintf( fftfp, "%s\n", seq1[i] );
+fprintf( fftfp, "seq2: ( %d sequences ) \n", clus2 );
+for( i=0; i<clus2; i++ )
+	fprintf( fftfp, "%s\n", seq2[i] );
+fclose( fftfp );
+system( "less input_of_Falign < /dev/tty > /dev/tty" );
+#endif
+	if( !kobetsubunkatsu )
+	{
+		fprintf( stderr,  " FFT ... " );
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector1[j], nlen );
+		if( scoremtx == -1 )
+		{
+			for( i=0; i<clus1; i++ )
+				seq_vec_4( seqVector1[0], eff1[i], tmpseq1[i] );
+		}
+		else if( fftscore )
+		{
+			for( i=0; i<clus1; i++ )
+			{
+#if 0
+				seq_vec_2( seqVector1[0], polarity, eff1[i], tmpseq1[i] );
+				seq_vec_2( seqVector1[1], volume,   eff1[i], tmpseq1[i] );
+#else
+				seq_vec_5( seqVector1[0], polarity, volume, eff1[i], tmpseq1[i] );
+#endif
+			}
+		}
+		else
+		{
+			for( i=0; i<clus1; i++ )
+				seq_vec_3( seqVector1, eff1[i], tmpseq1[i] );
+		}
+#if RND
+		for( i=0; i<clus1; i++ )
+		{
+			vec_init2( seqVector1, rndseq1[i], eff1[i], len1, nlen );
+		}
+#endif
+#if 0
+fftfp = fopen( "seqVec", "w" );
+fprintf( fftfp, "before transform\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "nlen=%d\n", nlen );
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector1[k][l].R, seqVector1[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ ) vec_init( seqVector2[j], nlen );
+		if( scoremtx == -1 )
+		{
+			for( i=0; i<clus2; i++ )
+				seq_vec_4( seqVector2[0], eff2[i], tmpseq2[i] );
+		}
+		else if( fftscore )
+		{
+			for( i=0; i<clus2; i++ )
+			{
+#if 0
+				seq_vec_2( seqVector2[0], polarity, eff2[i], tmpseq2[i] );
+				seq_vec_2( seqVector2[1], volume,   eff2[i], tmpseq2[i] );
+#else
+				seq_vec_5( seqVector2[0], polarity, volume, eff2[i], tmpseq2[i] );
+#endif
+			}
+		}
+		else
+		{
+			for( i=0; i<clus2; i++ )
+				seq_vec_3( seqVector2, eff2[i], tmpseq2[i] );
+		}
+#if RND
+		for( i=0; i<clus2; i++ )
+		{
+			vec_init2( seqVector2, rndseq2[i], eff2[i], len2, nlen );
+		}
+#endif
+
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "before fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( j=0; j<n20or4or2; j++ )
+		{
+			fft( nlen, seqVector2[j], (j==0) );
+			fft( nlen, seqVector1[j], 0 );
+		}
+#if 0
+fftfp = fopen( "seqVec2", "w" );
+fprintf( fftfp, "#after fft\n" );
+for( k=0; k<n20or4or2; k++ ) 
+{
+   fprintf( fftfp, "#%c\n", amino[k] );
+   for( l=0; l<nlen; l++ )
+	   fprintf( fftfp, "%f %f\n", seqVector2[k][l].R, seqVector2[k][l].I );
+}
+fclose( fftfp );
+system( "less seqVec2 < /dev/tty > /dev/tty" );
+#endif
+
+		for( k=0; k<n20or4or2; k++ ) 
+		{
+			for( l=0; l<nlen; l++ ) 
+				calcNaiseki( naiseki[k]+l, seqVector1[k]+l, seqVector2[k]+l );
+		}
+		for( l=0; l<nlen; l++ ) 
+		{
+			naisekiNoWa[l].R = 0.0;
+			naisekiNoWa[l].I = 0.0;
+			for( k=0; k<n20or4or2; k++ ) 
+			{
+				naisekiNoWa[l].R += naiseki[k][l].R;
+				naisekiNoWa[l].I += naiseki[k][l].I;
+			}
+		}
+	
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#Before fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f %f\n", l, naisekiNoWa[l].R, naisekiNoWa[l].I ); 
+	fclose( fftfp );
+	system( "less naisekiNoWa < /dev/tty > /dev/tty " );
+#endif
+
+		fft( -nlen, naisekiNoWa, 0 );
+	
+		for( m=0; m<=nlen2; m++ ) 
+			soukan[m] = naisekiNoWa[nlen2-m].R;
+		for( m=nlen2+1; m<nlen; m++ ) 
+			soukan[m] = naisekiNoWa[nlen+nlen2-m].R;
+
+#if 0
+	fftfp = fopen( "naisekiNoWa", "w" );
+	fprintf( fftfp, "#After fft\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( fftfp, "%d  %f\n", l, naisekiNoWa[l].R ); 
+	fclose( fftfp );
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'naisekiNoWa'\npause -1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot &" );
+#endif
+#if 0
+	fprintf( stderr, "soukan\n" );
+	for( l=0; l<nlen; l++ )
+		fprintf( stderr, "%d  %f\n", l-nlen2, soukan[l] ); 
+#if 0
+	fftfp = fopen( "list.plot", "w"  );
+	fprintf( fftfp, "plot 'frt'\n pause +1" );
+	fclose( fftfp );
+	system( "/usr/bin/gnuplot list.plot" );
+#endif
+#endif
+
+
+		nkouho = getKouho( kouho, NKOUHO_LONG, soukan, nlen );
+
+#if 0
+		for( i=0; i<nkouho; i++ )
+		{
+			fprintf( stderr, "kouho[%d] = %d\n", i, kouho[i] );
+		}
+#endif
+	}
+
+#if KEIKA
+	fprintf( stderr, "Searching anchors ... " );
+#endif
+	count = 0;
+
+
+
+#define CAND 0
+#if CAND
+	fftfp = fopen( "cand", "w" );
+	fclose( fftfp );
+#endif
+	if( kobetsubunkatsu )
+	{
+		maxk = 1;
+		kouho[0] = 0;
+	}
+	else
+	{
+		maxk = nkouho;
+	}
+
+	for( k=0; k<maxk; k++ ) 
+	{
+		lag = kouho[k];
+		if( lag <= -len1 || len2 <= lag ) continue;
+//		fprintf( stderr, "k=%d, lag=%d\n", k, lag );
+		zurasu2( lag, clus1, clus2, seq1, seq2, tmpptr1, tmpptr2 );
+#if CAND
+		fftfp = fopen( "cand", "a" );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr1[0] );
+		fprintf( fftfp, ">Candidate No.%d lag = %d\n", k+1, lag );
+		fprintf( fftfp, "%s\n", tmpptr2[0] );
+		fprintf( fftfp, ">\n", k+1, lag );
+		fclose( fftfp );
+#endif
+
+//		fprintf( stderr, "lag = %d\n", lag );
+		tmpint = alignableReagion( clus1, clus2, tmpptr1, tmpptr2, eff1, eff2, segment+count );
+//		fprintf( stderr, "lag = %d, %d found\n", lag, tmpint );
+
+//		if( lag == -50 ) exit( 1 );
+		
+		if( count+tmpint > MAXSEG -3 ) ErrorExit( "TOO MANY SEGMENTS.\n" );
+
+//		fprintf( stderr, "##### k=%d / %d\n", k, maxk );
+		if( tmpint == 0 ) break; // 060430 iinoka ?
+		while( tmpint-- > 0 )
+		{
+#if 0
+			if( segment[count].end - segment[count].start < fftWinSize )
+			{
+				count++;
+				continue;
+			}
+#endif
+			if( lag > 0 )
+			{
+				segment1[count].start  = segment[count].start ;
+				segment1[count].end    = segment[count].end   ;
+				segment1[count].center = segment[count].center;
+				segment1[count].score  = segment[count].score;
+
+				segment2[count].start  = segment[count].start  + lag;
+				segment2[count].end    = segment[count].end    + lag;
+				segment2[count].center = segment[count].center + lag;
+				segment2[count].score  = segment[count].score       ;
+			}
+			else
+			{
+				segment1[count].start  = segment[count].start  - lag;
+				segment1[count].end    = segment[count].end    - lag;
+				segment1[count].center = segment[count].center - lag;
+				segment1[count].score  = segment[count].score       ;
+
+				segment2[count].start  = segment[count].start ;
+				segment2[count].end    = segment[count].end   ;
+				segment2[count].center = segment[count].center;
+				segment2[count].score  = segment[count].score ;
+			}
+#if 0
+			fprintf( stderr, "##### k=%d / %d\n", k, maxk );
+			fprintf( stderr, "anchor %d, score = %f\n", count, segment1[count].score );
+			fprintf( stderr, "in 1 %d\n", segment1[count].center );
+			fprintf( stderr, "in 2 %d\n", segment2[count].center );
+#endif
+			segment1[count].pair = &segment2[count];
+			segment2[count].pair = &segment1[count];
+			count++;
+#if 0
+			fprintf( stderr, "count=%d\n", count );
+#endif
+		}
+	}
+#if 1
+	if( !kobetsubunkatsu )
+		fprintf( stderr, "done. (%d anchors) ", count );
+#endif
+	if( !count && fftNoAnchStop )
+		ErrorExit( "Cannot detect anchor!" );
+#if 0
+	fprintf( stderr, "RESULT before sort:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( stderr, "%d score = %f\n", segment2[l].center, segment1[l].score );
+	}
+#endif
+
+	for( i=0; i<count; i++ )
+	{
+		sortedseg1[i] = &segment1[i];
+		sortedseg2[i] = &segment2[i];
+	}
+#if 0
+	tmpsort( count, sortedseg1 ); 
+	tmpsort( count, sortedseg2 ); 
+	qsort( sortedseg1, count, sizeof( Segment * ), segcmp );
+	qsort( sortedseg2, count, sizeof( Segment * ), segcmp );
+#else
+	mymergesort( 0, count-1, sortedseg1 ); 
+	mymergesort( 0, count-1, sortedseg2 ); 
+#endif
+	for( i=0; i<count; i++ ) sortedseg1[i]->number = i;
+	for( i=0; i<count; i++ ) sortedseg2[i]->number = i;
+
+
+
+	if( kobetsubunkatsu )
+	{
+		for( i=0; i<count; i++ )
+	    {
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+		cut1[0] = 0;
+		cut2[0] = 0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+	}
+#if 1
+
+	else
+	{
+		if( crossscoresize < count+2 )
+		{
+			crossscoresize = count+2;
+#if 1
+			if( fftkeika ) fprintf( stderr, "######allocating crossscore, size = %d\n", crossscoresize );
+#endif
+			if( crossscore ) FreeDoubleMtx( crossscore );
+			crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
+		}
+		for( i=0; i<count+2; i++ ) for( j=0; j<count+2; j++ )
+			crossscore[i][j] = 0.0;
+		for( i=0; i<count; i++ )
+		{
+			crossscore[segment1[i].number+1][segment1[i].pair->number+1] = segment1[i].score;
+			cut1[i+1] = sortedseg1[i]->center;
+			cut2[i+1] = sortedseg2[i]->center;
+		}
+
+#if 0
+		fprintf( stderr, "AFTER SORT\n" );
+		for( i=0; i<count+1; i++ ) fprintf( stderr, "%d, %d\n", cut1[i], cut2[i] );
+		fprintf( stderr, "crossscore = \n" );
+		for( i=0; i<count+1; i++ )
+		{
+			for( j=0; j<count+1; j++ )
+				fprintf( stderr, "%.0f ", crossscore[i][j] );
+			fprintf( stderr, "\n" );
+		}
+#endif
+
+		crossscore[0][0] = 10000000.0;
+		cut1[0] = 0; 
+		cut2[0] = 0;
+		crossscore[count+1][count+1] = 10000000.0;
+		cut1[count+1] = len1;
+		cut2[count+1] = len2;
+		count += 2;
+		count0 = count;
+	
+//		fprintf( stderr, "\n\n\ncalling blockAlign2\n\n\n\n" );
+		blockAlign2( cut1, cut2, sortedseg1, sortedseg2, crossscore, &count );
+
+//		if( count-count0 )
+//			fprintf( stderr, "%d unused anchors\n", count0-count );
+
+		if( !kobetsubunkatsu && fftkeika )
+			fprintf( stderr, "%d anchors found\n", count );
+		if( fftkeika )
+		{
+			if( count0 > count )
+			{
+#if 0
+				fprintf( stderr, "\7 REPEAT!? \n" ); 
+#else
+				fprintf( stderr, "REPEAT!? \n" ); 
+#endif
+				if( fftRepeatStop ) exit( 1 );
+			}
+#if KEIKA
+			else fprintf( stderr, "done\n" );
+#endif
+		}
+	}
+
+
+#else
+	else
+	{
+		cut1[0] = 0; 
+		cut2[0] = 0;
+		count0 = 0;
+		for( i=0; i<count; i++ )
+		{
+//			fprintf( stderr, "i=%d, %d-%d ?\n", i, sortedseg1[i]->center, sortedseg1[i]->pair->center );
+			if( sortedseg1[i]->center > cut1[count0]
+			 && sortedseg1[i]->pair->center > cut2[count0] )
+			{
+				count0++;
+				cut1[count0] = sortedseg1[i]->center;
+				cut2[count0] = sortedseg1[i]->pair->center;
+			}
+			else
+			{
+				if( i && sortedseg1[i]->score > sortedseg1[i-1]->score )
+				{
+					if( sortedseg1[i]->center > cut1[count0-1]
+					 && sortedseg1[i]->pair->center > cut2[count0-1] )
+					{
+						cut1[count0] = sortedseg1[i]->center;
+						cut2[count0] = sortedseg1[i]->pair->center;
+					}
+					else
+					{
+//						count0--;
+					}
+				}
+			}
+		}
+//		if( count-count0 )
+//			fprintf( stderr, "%d anchors unused\n", count-count0 );
+		cut1[count0+1] = len1;
+		cut2[count0+1] = len2;
+		count = count0 + 2;
+		count0 = count;
+
+	}
+#endif
+
+//	exit( 0 );
+
+#if 0
+	fftfp = fopen( "fft", "a" );
+	fprintf( fftfp, "RESULT after sort:\n" );
+	for( l=0; l<count; l++ )
+	{
+		fprintf( fftfp, "cut[%d]=%d, ", l, segment1[l].center );
+		fprintf( fftfp, "%d\n", segment2[l].center );
+	}
+	fclose( fftfp );
+#endif
+
+#if 0
+	fprintf( stderr, "RESULT after blckalign:\n" );
+	for( l=0; l<count+1; l++ )
+	{
+		fprintf( stderr, "cut : %d %d\n", cut1[l], cut2[l] );
+	}
+#endif
+
+#if 0
+	fprintf( trap_g, "Devided to %d segments\n", count-1 );
+	fprintf( trap_g, "%d  %d forg\n", MIN( clus1, clus2 ), count-1 );
+#endif
+
+	totallen = 0;
+	for( j=0; j<clus1; j++ ) result1[j][0] = 0;
+	for( j=0; j<clus2; j++ ) result2[j][0] = 0;
+	totalscore = 0.0;
+	*fftlog = -1;
+	for( i=0; i<count-1; i++ )
+	{
+		*fftlog += 1;
+
+		if( cut1[i] )
+		{
+//			getkyokaigap( sgap1, seq1, cut1[i]-1, clus1 );
+//			getkyokaigap( sgap2, seq2, cut2[i]-1, clus2 );
+			getkyokaigap( sgap1, tmpres1, nlen-1, clus1 );
+			getkyokaigap( sgap2, tmpres2, nlen-1, clus2 );
+		}
+		else
+		{
+			for( j=0; j<clus1; j++ ) sgap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) sgap2[j] = 'o';
+		}
+		if( cut1[i+1] != len1 )
+		{       
+			getkyokaigap( egap1, seq1, cut1[i+1], clus1 );
+			getkyokaigap( egap2, seq2, cut2[i+1], clus2 );
+		}       
+		else    
+		{       
+			for( j=0; j<clus1; j++ ) egap1[j] = 'o';
+			for( j=0; j<clus2; j++ ) egap2[j] = 'o';
+		}
+#if DEBUG
+		fprintf( stderr, "DP %03d / %03d %4d to ", i+1, count-1, totallen );
+#else
+#if 1
+		fprintf( stderr, "DP %05d / %05d \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i+1, count-1 );
+#endif
+#endif
+		for( j=0; j<clus1; j++ )
+		{
+			strncpy( tmpres1[j], seq1[j]+cut1[i], cut1[i+1]-cut1[i] );
+			tmpres1[j][cut1[i+1]-cut1[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus1, tmpres1 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus1, tmpres1 );
+		for( j=0; j<clus2; j++ )
+		{
+//			fprintf( stderr, "### cut2[i+1]-cut2[i] = %d\n", cut2[i+1]-cut2[i] );
+			if( cut2[i+1]-cut2[i] <= 0 )
+				fprintf( stderr, "### cut2[i+1]=%d, cut2[i]=%d\n", cut2[i+1], cut2[i] );
+			strncpy( tmpres2[j], seq2[j]+cut2[i], cut2[i+1]-cut2[i] );
+			tmpres2[j][cut2[i+1]-cut2[i]] = 0;
+		}
+		if( kobetsubunkatsu && fftkeika ) commongappick( clus2, tmpres2 ); //dvtditr $B$K8F$P$l$?$H$-(B fftkeika=1
+//		if( kobetsubunkatsu ) commongappick( clus2, tmpres2 );
+
+		if( constraint )
+		{
+			fprintf( stderr, "Not supported\n" );
+			exit( 1 );
+		}
+#if 0
+		fprintf( stderr, "i=%d, before alignment", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+
+#if 0
+		fprintf( stdout, "writing input\n" );
+		for( j=0; j<clus1; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP1\n", j );
+			fprintf( stdout, "%s\n", tmpres1[j] );
+		}
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stdout, ">%d of GROUP2\n", j );
+			fprintf( stdout, "%s\n", tmpres2[j] );
+		}
+		fflush( stdout );
+#endif
+		switch( alg )
+		{
+			case( 'M' ):
+					totalscore += MSalignmm( tmpres1, tmpres2, eff1, eff2, clus1, clus2, alloclen, sgap1, sgap2, egap1, egap2 );
+				break;
+			default:
+				fprintf( stderr, "alg = %c\n", alg );
+				ErrorExit( "ERROR IN SOURCE FILE Falign.c" );
+				break;
+		}
+
+		nlen = strlen( tmpres1[0] );
+		if( totallen + nlen > alloclen )
+		{
+			fprintf( stderr, "totallen=%d +  nlen=%d > alloclen = %d\n", totallen, nlen, alloclen );
+			ErrorExit( "LENGTH OVER in Falign\n " );
+		}
+		for( j=0; j<clus1; j++ ) strcat( result1[j], tmpres1[j] );
+		for( j=0; j<clus2; j++ ) strcat( result2[j], tmpres2[j] );
+		totallen += nlen;
+#if 0
+		fprintf( stderr, "i=%d", i );
+		fprintf( stderr, "%4d\n", totallen );
+		fprintf( stderr, "\n\n" );
+		for( j=0; j<clus1; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres1[j] );
+		}
+		fprintf( stderr, "-------\n" );
+		for( j=0; j<clus2; j++ ) 
+		{
+			fprintf( stderr, "%s\n", tmpres2[j] );
+		}
+#endif
+	}
+#if KEIKA
+	fprintf( stderr, "DP ... done   \n" );
+#endif
+
+	for( j=0; j<clus1; j++ ) strcpy( seq1[j], result1[j] );
+	for( j=0; j<clus2; j++ ) strcpy( seq2[j], result2[j] );
+#if 0
+	for( j=0; j<clus1; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result1[j] );
+	}
+	fprintf( stderr, "- - - - - - - - - - -\n" );
+	for( j=0; j<clus2; j++ ) 
+	{
+		fprintf( stderr, "%s\n", result2[j] );
+	}
+#endif
+	return( totalscore );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Galign11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Galign11.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Galign11.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Galign11.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,658 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  1
+
+
+#if 1
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 ) 
+{
+	char *seq2 = s2[0];
+	int *intptr = amino_dis[(int)s1[0][i1]];
+
+	while( lgth2-- )
+		*match++ = intptr[(int)*seq2++];
+}
+static void match_calc_mtx( int mtx[0x80][0x80], float *match, char **s1, char **s2, int i1, int lgth2 ) 
+{
+	char *seq2 = s2[0];
+	int *intptr = mtx[(int)s1[0][i1]];
+
+	while( lgth2-- )
+		*match++ = intptr[(int)*seq2++];
+}
+#else
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 )
+{
+	int j;
+
+	for( j=0; j<lgth2; j++ )
+		match[j] = amino_dis[(*s1)[i1]][(*s2)[j]];
+}
+#endif
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        int **ijp )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, limk;
+	char gap[] = "-";
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+	iin = lgth1; jin = lgth2;
+	limk = lgth1+lgth2 + 1;
+	for( k=0; k<limk; 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 ) 
+		{
+			*--mseq1[0] = seq1[0][ifi+l];
+			*--mseq2[0] = *gap;
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--mseq1[0] = *gap;
+			*--mseq2[0] = seq2[0][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--mseq1[0] = seq1[0][ifi];
+		*--mseq2[0] = seq2[0][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+
+float G__align11( char **seq1, char **seq2, int alloclen )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti;                      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+
+	wm = 0.0;
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+
+	if( lgth1 <= 0 || lgth2 <= 0 )
+	{
+		fprintf( stderr, "WARNING (g11): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc( initverticalw, seq2, seq1, 0, lgth1 );
+
+
+	match_calc( currentw, seq1, seq2, 0, lgth2 );
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += fpenalty;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += fpenalty;
+		}
+	}
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1]; mp[j] = 0;
+	}
+
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0;               // lgth2==0 no toki error
+	else
+		lastverticalw[0] = currentw[lgth2-1]; // lgth2==0 no toki error
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, seq1, seq2, i, lgth2 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0]; mpi = 0;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		for( j=1; j<lgth2+1; j++ )
+		{
+			wm = *prept;
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+fpenalty) > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			if( (g=*prept) >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt + fpenalty) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			if( (g=*prept) >= *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++;
+		}
+		lastverticalw[i] = currentw[lgth2-1]; // lgth2==0 no toki error
+	}
+
+	Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, ijp );
+
+	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" );
+	}
+
+
+	strcpy( seq1[0], mseq1[0] );
+	strcpy( seq2[0], mseq2[0] );
+#if 0
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+	fprintf( stderr, "wm = %f\n", wm );
+#endif
+
+	return( wm );
+}
+
+float G__align11_noalign( int scoremtx[0x80][0x80], int penal, int penal_ex, char **seq1, char **seq2, int alloclen )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti;                      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+//	int resultlen;
+	float wm;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+	float fpenalty = (float)penal;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penal_ex;
+#endif
+#if 1
+	float *wtmp;
+	float *mjpt, *prept, *curpt;
+//	int *mpjpt;
+#endif
+	static float mi, *m;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+
+	wm = 0.0;
+
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+
+	if( lgth1 <= 0 || lgth2 <= 0 )
+	{
+		fprintf( stderr, "WARNING (g11): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+
+
+
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+
+
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+
+
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc_mtx( scoremtx, initverticalw, seq2, seq1, 0, lgth1 );
+
+
+	match_calc_mtx( scoremtx, currentw, seq1, seq2, 0, lgth2 );
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += fpenalty;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += fpenalty;
+		}
+	}
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1];
+	}
+
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0;               // lgth2==0 no toki error
+	else
+		lastverticalw[0] = currentw[lgth2-1]; // lgth2==0 no toki error
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc_mtx( scoremtx, currentw, seq1, seq2, i, lgth2 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0];
+
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		for( j=1; j<lgth2+1; j++ )
+		{
+			wm = *prept;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+fpenalty) > wm )
+			{
+				wm = g;
+			}
+			if( (g=*prept) >= mi )
+			{
+				mi = g;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt + fpenalty) > wm )
+			{
+				wm = g;
+			}
+			if( (g=*prept) >= *mjpt )
+			{
+				*mjpt = g;
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+			*curpt++ += wm;
+			mjpt++;
+			prept++;
+		}
+		lastverticalw[i] = currentw[lgth2-1]; // lgth2==0 no toki error
+	}
+
+#if 0
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+	fprintf( stderr, "wm = %f\n", wm );
+#endif
+
+	return( wm );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Halignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Halignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Halignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Halignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1419 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+static float **impmtx = NULL;
+
+#if 0 // by D.Mathog
+static float countnocountxx( Gappat *pat1, float diaf1, Gappat *pat2, int offset1, int offset2 )
+{
+//	return( 0.0 );
+	float gclose;
+	float gmatch;
+	Gappat *pat1bk = pat1;
+	Gappat *pat2bk = pat2;
+
+	gmatch = 0.0;
+	for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
+	{
+		if( pat2->len + offset2 == offset1 )
+		{
+			gmatch = diaf1 * pat2->freq;
+		}
+	}
+	for( pat1=pat1bk+1; pat1->len != 0; pat1++ ) // excl. len=0
+	{
+		for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
+		{
+			if( pat1->len + offset1 == pat2->len + offset2 )
+			{
+				gmatch += pat1->freq * pat2->freq;
+//				if( r ) fprintf( stderr, "match1!!, len=%d, gmatch=%f * %f\n", pat2->len, pat1->freq, pat2->freq );
+			}
+		}
+	}
+	return( gmatch );
+}
+#endif
+
+static float countnocountmatchx( Gappat *pat1, Gappat *pat2, int offset1, int offset2, int r )
+{
+	Gappat *pat1bk = pat1;
+	Gappat *pat2bk = pat2;
+	float val = 0.0;
+	// pat1[][0] ha total gap.
+	for( pat1=pat1bk+1; pat1->len != 0; pat1++ )
+	{
+		for( pat2=pat2bk+1; pat2->len != 0; pat2++ )
+		{
+			if( pat1->len + offset1 == pat2->len + offset2 )
+			{
+				val += pat1->freq * pat2->freq;
+				if( r ) fprintf( stderr, "y %d-%d, len=%d,%d, val = %f\n", (int)(pat1-pat1bk), (int)(pat2-pat2bk), pat1->len, pat2->len, val ); // 070405
+//				if( r ) fprintf( stderr, "y %d-%d, len=%d,%d, val = %f\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len, val );
+			}
+		} 
+	}
+	if( r ) fprintf( stderr, "nocountmatch=%f\n", val );
+	return( val );
+}
+
+#if 0 // by D.Mathog
+static float countnocountmatch( Gappat *pat1, Gappat *pat2, int r )
+{
+//	return( 0.0 );
+	Gappat *pat1bk = pat1;
+	Gappat *pat2bk = pat2;
+	float val = 0.0;
+	// pat1[][0] ha total gap.
+	for( pat1=pat1bk+1; pat1->len != 0; pat1++ )
+	{
+//		if( r ) fprintf( stderr, "b %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
+		for( pat2=pat2bk+1; pat2->len != 0; pat2++ )
+		{
+			if( pat1->len == pat2->len )
+			{
+//				if( r ) fprintf( stderr, " x%d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
+				val += pat1->freq * pat2->freq;
+//				if( r ) fprintf( stderr, "y %d-%d, val = %f\n", pat1-pat1bk, pat2-pat2bk,val );
+//				if( r ) fprintf( stderr, "z tsugi, %d-%d, len=%d,%d\n", pat1-pat1bk+1, pat2-pat2bk+1, (pat1+1)->len, (pat2+1)->len );
+			}
+//			if( r ) fprintf( stderr, "a %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
+		} 
+	}
+//	fprintf( stderr, "nocountmatch=%f\n", val );
+	return( val );
+}
+#endif
+
+static float countnocountx( Gappat *pat1, float diaf1, Gappat *pat2, int offset1, int r )
+{
+//	return( 0.0 );
+	float gmatch;
+	Gappat *pat1bk = pat1;
+	Gappat *pat2bk = pat2;
+
+	gmatch = 0.0;
+	for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
+	{
+		if( pat2->len == offset1 )
+		{
+			gmatch = diaf1 * pat2->freq;
+//			if( r ) fprintf( stderr, "match0!!, len=%d, gmatch=%f * %f\n", pat2->len, diaf1, pat2->freq );
+		}
+	}
+	for( pat1=pat1bk+1; pat1->len != 0; pat1++ ) // excl. len=0
+	{
+		for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
+		{
+			if( pat1->len + offset1 == pat2->len )
+			{
+				gmatch += pat1->freq * pat2->freq;
+//				if( r ) fprintf( stderr, "match1!!, len=%d, gmatch=%f * %f\n", pat2->len, pat1->freq, pat2->freq );
+			}
+		}
+	}
+	return( gmatch );
+}
+
+#if 0 // by D.Mathog
+static float countnocount( Gappat *pat1, Gappat *pat2, int offset1, int offset2 ) //osoi
+{
+//	return( 0.0 );
+	Gappat *pat1bk = pat1;
+	Gappat *pat2bk = pat2;
+	float val = 0.0;
+	// pat1[][0] ha total gap.
+	for( pat1=pat1bk+1; pat1->len != -1; pat1++ )
+	{
+		for( pat2=pat2bk+1; pat2->len != -1; pat2++ )
+		{
+			if( pat1->len+offset1 == pat2->len+offset2 )
+			{
+				val += pat1->freq * pat2->freq;
+			}
+		} 
+	}
+//	fprintf( stderr, "nocount=%f\n", val );
+	return( val );
+}
+#endif
+
+
+
+#if 1 // tditeration 
+float imp_match_out_scH( int i1, int j1 )
+{
+//	fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
+//	fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+}
+#endif
+
+static void imp_match_out_veadH( float *imp, int i1, int lgth2 )
+{
+#if FASTMATCHCALC 
+	float *pt = impmtx[i1];
+	while( lgth2-- )
+		*imp++ += *pt++;
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[j];
+#endif
+}
+static void imp_match_out_vead_tateH( float *imp, int j1, int lgth1 )
+{
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[i][j1];
+}
+
+#if 1 // tbfast.c kara yobareru.
+void imp_match_init_strictH( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	static int impalloclen = 0;
+	float effij;
+	double effijx;
+	char *pt, *pt1, *pt2;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+	LocalHom *tmpptr;
+
+	if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx =  fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = (float)( eff1[i] * eff2[j] * effijx );
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = pt - seq1[i] - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = pt - seq1[i] - 0;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = pt - seq1[i] - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = pt - seq2[j] - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = pt - seq2[j] - 0;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = pt - seq2[j] - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+#if 1
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+//						fprintf( stderr, "%d (%c) - %d (%c)  - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+#else
+				while( k1 <= end1 && k2 <= end2 )
+				{
+					fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
+					if( !nocount1[k1] && !nocount2[k2] )
+					{
+						impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j]  * fastathreshold;
+						fprintf( stderr, "marked\n" );
+					}
+					else
+						fprintf( stderr, "no count\n" );
+					k1++; k2++;
+				}
+#endif
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+#if 0
+	if( clus1 == 1 && clus2 == 6 )
+	{
+		fprintf( stderr, "\n" );
+		fprintf( stderr, "seq1[0] =  %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] =  %s\n", seq2[0] );
+		fprintf( stderr, "impmtx = \n" );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", (double)k2 );
+		fprintf( stderr, "\n" );
+		for( k1=0; k1<lgth1; k1++ )
+		{
+			fprintf( stderr, "%d ", k1 );
+			for( k2=0; k2<3; k2++ )
+				fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+			fprintf( stderr, "\n" );
+		}
+		exit( 1 );
+	}
+#endif
+}
+#endif
+
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+				scarr[l] += n_dis[j][l] * cpmx1[j][i1];
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_scH( iin, jin );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+}
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+	return( 0.0 );
+}
+
+float H__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static Gappat **gappat1;
+	static Gappat **gappat2;
+	static float *digf1;
+	static float *digf2;
+	static float *diaf1;
+	static float *diaf2;
+	static float *gapz1;
+	static float *gapz2;
+	static float *gapf1;
+	static float *gapf2;
+	static float *ogcp1g;
+	static float *ogcp2g;
+	static float *fgcp1g;
+	static float *fgcp2g;
+	static float *ogcp1;
+	static float *ogcp2;
+	static float *fgcp1;
+	static float *fgcp2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float fpenalty = (float)penalty;
+	float tmppenal;
+	float cumpenal;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fgcp1va;
+	float ogcp1va;
+	int maegap;
+
+
+
+#if 0
+	fprintf( stderr, "####  eff in SA+++align\n" );
+	fprintf( stderr, "####  seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "####  strlen( seq1[0] ) = %d\n", strlen( seq1[0] ) );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
+#endif
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			free( gappat1 );
+			free( gappat2 );
+			FreeFloatVec( digf1 );
+			FreeFloatVec( digf2 );
+			FreeFloatVec( diaf1 );
+			FreeFloatVec( diaf2 );
+			FreeFloatVec( gapz1 );
+			FreeFloatVec( gapz2 );
+			FreeFloatVec( gapf1 );
+			FreeFloatVec( gapf2 );
+			FreeFloatVec( ogcp1 );
+			FreeFloatVec( ogcp2 );
+			FreeFloatVec( fgcp1 );
+			FreeFloatVec( fgcp2 );
+			FreeFloatVec( ogcp1g );
+			FreeFloatVec( ogcp2g );
+			FreeFloatVec( fgcp1g );
+			FreeFloatVec( fgcp2g );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		digf1 = AllocateFloatVec( ll1+2 );
+		digf2 = AllocateFloatVec( ll2+2 );
+		diaf1 = AllocateFloatVec( ll1+2 );
+		diaf2 = AllocateFloatVec( ll2+2 );
+		gappat1 = (Gappat **)calloc( ll1+2, sizeof( Gappat * ) );
+		gappat2 = (Gappat **)calloc( ll2+2, sizeof( Gappat * ) );
+		gapz1 = AllocateFloatVec( ll1+2 );
+		gapz2 = AllocateFloatVec( ll2+2 );
+		gapf1 = AllocateFloatVec( ll1+2 );
+		gapf2 = AllocateFloatVec( ll2+2 );
+		ogcp1 = AllocateFloatVec( ll1+2 );
+		ogcp2 = AllocateFloatVec( ll2+2 );
+		fgcp1 = AllocateFloatVec( ll1+2 );
+		fgcp2 = AllocateFloatVec( ll2+2 );
+		ogcp1g = AllocateFloatVec( ll1+2 );
+		ogcp2g = AllocateFloatVec( ll2+2 );
+		fgcp1g = AllocateFloatVec( ll1+2 );
+		fgcp2g = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+#if 0
+	{
+		float t = 0.0;
+		for( i=0; i<icyc; i++ )
+			t += eff1[i];
+	fprintf( stderr, "## totaleff = %f\n", t );
+	}
+#endif
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap1 );
+		new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap1, egap2 );
+		getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
+		getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 ); // sgap1 ha iranai ?
+		getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
+		getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap1, egap2 ); // sgap1 ha iranai ?
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 ); // atode
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 ); // atode
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 ); // atode
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 ); // atode
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
+		st_getGapPattern( gappat1, icyc, seq1, eff1, lgth1 );
+		st_getGapPattern( gappat2, jcyc, seq2, eff2, lgth2 );
+		getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
+		getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
+		getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
+		getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead_tateH( initverticalw, 0, lgth1 ); // 060306
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_veadH( currentw, 0, lgth2 ); // 060306
+
+
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+	if( outgap == 1 )
+	{
+//		if( g ) fprintf( stderr, "init-match penal1=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+//		initverticalw[0] += g;
+//		currentw[0] += g;
+
+//		if( g ) fprintf( stderr, "init-match penal2=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+//		initverticalw[0] += g;
+//		currentw[0] += g;
+
+		for( i=1; i<lgth1+1; i++ )
+		{
+//			initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
+
+			tmppenal = 0.0;
+//			tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+0.0) + gapz2[0]*(1.0-digf1[0] - diaf1[0]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-0.0)*(1.0-ogcp1g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-0.0) * (1.0-diaf1[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
+//			tmppenal -= ( (1.0-gapf2[j-1]) * ogcp1g[i] + gapf2[j-1] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 1 = %f\n", i, 0, tmppenal );
+			initverticalw[i] += tmppenal;
+
+			tmppenal = diaf1[i] * ( 1.0 - gapf2[0] ) * fpenalty;
+			if( gappat1[i][0].freq )
+			{
+				tmppenal += ( gappat1[i][0].freq ) * ( 1.0 - gapf2[0] ) * fpenalty;
+				tmppenal -= ( countnocountx( gappat2[0], diaf2[0], gappat1[i], i, 1 ) ) * fpenalty;
+			}
+//			tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[0])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[0]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[0]) * (1.0-diaf1[i]) + gapf2[0] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j]) * fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
+			initverticalw[i] += tmppenal;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 2 = %f, cumpenal=%f, fgcp1g[i]=%f, ogcp1g[i]=%f\n", i, 0, tmppenal, cumpenal, fgcp1g[i], ogcp1g[i] );
+
+		}
+		cumpenal = 0.0;
+		for( j=1; j<lgth2+1; j++ )
+		{
+//			currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
+
+			tmppenal = 0.0;
+//			tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[j]+fgcp2g[j]) + gapf1[i-1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+0.0) + gapz1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-0.0)*(1.0-ogcp2g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-0.0) * (1.0-diaf2[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
+//			tmppenal -= ( (1.0-gapf1[0]) * fgcp2g[j] + gapf1[0] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 3 = %f\n", 0, j, tmppenal );
+			currentw[j] += tmppenal;
+
+			tmppenal = diaf2[j] * ( 1.0 - gapf1[0] ) * fpenalty;
+			if( gappat2[j][0].freq )
+			{
+				tmppenal += ( gappat2[j][0].freq ) * ( 1.0 - gapf1[0] ) * fpenalty;
+				tmppenal -= ( countnocountx( gappat1[0], diaf1[0], gappat2[j], j, 1 ) ) * fpenalty;
+			}
+//			tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[0])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[0]) * (1.0-diaf2[j]) + gapf1[0] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[0]) * ogcp2g[j] + gapf1[i-1] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 4 = %f\n", 0, j, tmppenal );
+			currentw[j] += tmppenal;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	m[0] = 0.0; // iranai
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+//		m[j] = currentw[j-1] + ogcp1[1]; 
+		mp[j] = 0;
+
+		tmppenal = 0.0;
+//		tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[1]+fgcp1g[1]) + gapz2[j]*(1.0-digf1[1]-diaf1[1]) ) * 0.5 * fpenalty; // mada
+//		tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[1]+fgcp1g[1]) + gapf2[j-1]*(1.0-digf1[1]-diaf1[1]) ) * 0.5 * fpenalty; // mada
+//		tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//		tmppenal = 0.5 * fpenalty;
+//		tmppenal -= ( (1.0-0.0) * (1.0-0.0) + 0.0 ) * 0.5 * fpenalty;
+//		tmppenal -= ( (1.0-gapf2[-1]) * (1.0-diaf1[0]) + gapf2[-1] ) * 0.5 * fpenalty;
+//		if( tmppenal ) fprintf( stderr, "%c=%c, end j tmppenal=%f\n", seq1[0][0], seq2[0][j-1], tmppenal );
+		m[j] = currentw[j-1] + tmppenal + fpenalty * 10000;  
+//		m[j] = currentw[j-1] + ogcp1[1]; 
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_veadH( currentw, i, lgth2 );
+#else
+			imp_match_out_veadH( currentw, i, lgth2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+
+//		mi = previousw[0] + ogcp2[1];  // machigai
+		tmppenal = 0.0;
+//		tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[1]+fgcp2g[1]) + gapz1[i]*(1.0-digf2[1]-diaf2[1]) ) * 0.5 * fpenalty; // mada
+//		tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[1]+fgcp2g[1]) + gapf1[i-1]*(1.0-digf2[1]-diaf2[1]) ) * 0.5 * fpenalty; // mada
+//		fprintf( stderr, "%c=%c, end i tmppenal=%f, ogcp2g[1]=%f\n", seq1[0][i-1], seq2[0][0], tmppenal, ogcp2g[1] );
+//		mi = previousw[0] + tmppenal;
+		mi = previousw[0] + tmppenal + fpenalty * 10000;
+
+		mpi = 0;
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fgcp2pt = fgcp2;
+		ogcp2pt = ogcp2 + 1;
+		fgcp1va = fgcp1[i-1];
+		ogcp1va = ogcp1[i];
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+
+			if( gappat2[j][0].freq )
+			{
+				g = diaf1[i] * gappat2[j][0].freq * fpenalty;
+//				if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
+//				if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
+				wm += g;
+			}
+
+			if( gappat1[i][0].freq )
+			{
+				g = diaf2[j] * gappat1[i][0].freq * fpenalty;
+//				if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
+//				if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
+				wm += g;
+			}
+			{
+				g = ( (gappat1[i][0].freq) * (gappat2[j][0].freq) ) * fpenalty;
+//				if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
+//				if( g ) fprintf( stderr, "match penal3=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
+				wm += g;
+			}
+			if( 0 )
+			{
+				maegap = ijp[i-1][j-1];
+//				if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
+//					fprintf( stderr, "i,j=%d,%d, maegap=%d\n", i, j, maegap );
+				maegap = 0;
+
+				if( maegap == 0 )
+				{
+				 	g = ( countnocountmatchx( gappat1[i], gappat2[j], 0, 0, 0 ) ) * fpenalty;
+//					if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
+//						fprintf( stderr, "kanwa0 %c-%c, i,j=%d,%d, g/fpenalty=%f, nocount=%f\n", seq1[0][i], seq2[0][j], i, j, g/fpenalty, countnocountmatchx( gappat1[i], gappat2[j], 0, -maegap, 1 ) );
+				}
+#if 0 // atta houga yoi hazu
+				else if( maegap < 0 ) // i jump
+				{
+				 	g = ( countnocountmatchx( gappat1[i], gappat2[j], 0, -maegap, 0 ) ) * fpenalty;
+					if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
+					{
+						fprintf( stderr, "i-jumped, offset1=%d\n", maegap );
+						fprintf( stderr, "kanwa1 %c-%c, i,j=%d,%d, g/fpenalty=%f, nocount=%f, nocount=%f\n", seq1[0][i], seq2[0][j], i, j, g/fpenalty, countnocountmatchx( gappat1[i], gappat2[j], 0, -maegap, 0 ) );
+					}
+				}
+				else                  // j jump
+				{
+				 	g = ( countnocountmatchx( gappat1[i], gappat2[j], maegap, 0, 0 ) ) * fpenalty;
+					if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
+					{
+						fprintf( stderr, "j-jumped, offset1=%d\n", maegap );
+						fprintf( stderr, "kanwa2, %c-%c, i,j=%d,%d, g/fpenalty=%f, nocount=%f\n", seq1[0][i], seq2[0][j], i, j, g/fpenalty, countnocountmatchx( gappat1[i], gappat2[j], 0, -maegap, 1 ) );
+					}
+				}
+#endif
+				wm -= g;
+			}
+
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+//			tmppenal = fpenalty;
+			tmppenal = diaf2[j] * ( 1.0 - gapf1[i] ) * fpenalty;
+			if( gappat2[j][0].freq )
+			{
+				tmppenal += ( gappat2[j][0].freq ) * ( 1.0 - gapf1[i] ) * fpenalty;
+//				tmppenal -= ( countnocountx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
+				maegap = ijp[i-1][mpi];
+				maegap = 0;
+				if( maegap == 0 )
+				{
+					tmppenal -= ( countnocountx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
+				}
+#if 0 // attahouga yoi hazu
+				else if( maegap < 0 ) // i jump
+				{
+					maegap = -maegap;
+					tmppenal -= ( countnocountxx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1+maegap, 0 ) ) * fpenalty;
+				}
+				else                  // j jump
+				{
+					tmppenal -= ( countnocountxx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, maegap ) ) * fpenalty;
+				}
+#endif
+			}
+			if( (g=mi+tmppenal) > wm )
+			{
+//				if( seq1[0][i] == 'A' && seq2[0][j] == 'A' ) fprintf( stderr, "jump i start=%f (i,j=%d,%d, *ijppt=%d, digf2[j]=%f, diaf2[j]=%f), %c-%c\n", g-mi, i, j, -(j-mpi), digf2[j], diaf2[j], seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			if( (g=*prept) >= mi )
+			{
+//				fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				mi = g;
+				mpi = j-1;
+			}
+			else if( j != 1 )
+			{
+//				mi += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5;
+//				fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", '=', '=', seq2[0][j-1], seq2[0][j], ogcp2g[j-0] * fpenalty*0.5, fgcp2g[j] * fpenalty*0.5 );
+			}
+#if USE_PENALTY_EX
+				mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+
+//			tmppenal = fpenalty;
+			tmppenal = diaf1[i] * ( 1.0 - gapf2[j] ) * fpenalty;
+			if( gappat1[i][0].freq )
+			{
+				tmppenal += ( gappat1[i][0].freq ) * ( 1.0 - gapf2[j] ) * fpenalty;
+//				tmppenal -= ( countnocountx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, 1 ) ) * fpenalty;
+				maegap = ijp[*mpjpt][j-1];
+				if( maegap == 0 )
+				{
+					tmppenal -= ( countnocountx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, 1 ) ) * fpenalty;
+				}
+#if 0 // attahouga yoi hazu
+				else if( maegap > 0 ) // j jump
+				{
+					tmppenal -= ( countnocountxx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1+maegap, 0 ) ) * fpenalty;
+				}
+				else                  // i jump
+				{
+					maegap = -maegap;
+					tmppenal -= ( countnocountxx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, maegap ) ) * fpenalty;
+				}
+#endif
+			}
+			if( (g=*mjpt+tmppenal) > wm )
+			{
+//				if( seq1[0][i] == 'S' && seq2[0][j] == 'S' ) fprintf( stderr, "jump j start at %d, %d, g=%f, %c-%c\n", i, j, g-*mjpt, seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			if( (g=*prept) >= *mjpt )
+			{
+//				fprintf( stderr, "jump j end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+			else if( i != 1 )
+			{
+//				m[j] += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5;
+//				fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", seq1[0][i-1], seq1[0][i], '=', '=', ogcp1g[i-0] * fpenalty*0.5, fgcp1g[i] * fpenalty*0.5 );
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+			*curpt++ += wm;
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+	fprintf( stderr, "wm = %f\n", wm );
+
+	for( i=0; i<lgth1+1; i++ ) 
+	{
+		free( gappat1[i] );
+		gappat1[i] = NULL;
+	}
+	for( i=0; i<lgth2+1; i++ ) 
+	{
+		free( gappat2[i] );
+		gappat2[i] = NULL;
+	}
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/JTT.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/JTT.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/JTT.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/JTT.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,243 @@
+#if 0
+#include "mltaln.h"
+#endif
+#define DEFAULTGOP_J -1530
+#define DEFAULTGEP_J   -00 
+#define DEFAULTOFS_J  -123  /* +10 -- -50  teido ka ? */
+#define DEFAULTPAMN  200
+
+void JTTmtx( double **rsr, double *freq, char locamino[26], char locgrp[26], int isTM )
+{
+	int i, j;
+	double r[20][20];
+	char locamino0[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
+	char locgrp0[] = 
+	{
+		0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
+		6, 6, 6, 6, 
+	};
+
+	double freq0[20] = 
+	{
+		0.077,
+		0.051,
+		0.043,
+		0.052,
+		0.020,
+		0.041,
+		0.062,
+		0.074,
+		0.023,
+		0.052,
+		0.091,
+		0.059,
+		0.024,
+		0.040,
+		0.051,
+		0.069,
+		0.059,
+		0.014,
+		0.032,
+		0.066,
+	};
+	double freq0_TM[20] = 
+	{
+		 0.1051,
+		 0.0157,
+		 0.0185,
+		 0.0089,
+		 0.0219,
+		 0.0141,
+		 0.0097,
+		 0.0758,
+		 0.0168,
+		 0.1188,
+		 0.1635,
+		 0.0112,
+		 0.0333,
+		 0.0777,
+		 0.0260,
+		 0.0568,
+		 0.0523,
+		 0.0223,
+		 0.0324,
+		 0.1195,
+	};
+
+    /* Lower triangular is JTT's Accepted point mutations */
+    r[ 1][ 0]=  247;
+
+    r[ 2][ 0]=  216; r[ 2][ 1]=  116;
+
+    r[ 3][ 0]=  386; r[ 3][ 1]=   48; r[ 3][ 2]= 1433;
+
+    r[ 4][ 0]=  106; r[ 4][ 1]=  125; r[ 4][ 2]=   32; r[ 4][ 3]=   13;
+
+    r[ 5][ 0]=  208; r[ 5][ 1]=  750; r[ 5][ 2]=  159; r[ 5][ 3]=  130;
+    r[ 5][ 4]=    9;
+
+    r[ 6][ 0]=  600; r[ 6][ 1]=  119; r[ 6][ 2]=  180; r[ 6][ 3]= 2914;
+    r[ 6][ 4]=    8; r[ 6][ 5]= 1027;
+
+    r[ 7][ 0]= 1183; r[ 7][ 1]=  614; r[ 7][ 2]=  291; r[ 7][ 3]=  577;
+    r[ 7][ 4]=   98; r[ 7][ 5]=   84; r[ 7][ 6]=  610;
+
+    r[ 8][ 0]=   46; r[ 8][ 1]=  446; r[ 8][ 2]=  466; r[ 8][ 3]=  144;
+    r[ 8][ 4]=   40; r[ 8][ 5]=  635; r[ 8][ 6]=   41; r[ 8][ 7]=   41;
+
+    r[ 9][ 0]=  173; r[ 9][ 1]=   76; r[ 9][ 2]=  130; r[ 9][ 3]=   37;
+    r[ 9][ 4]=   19; r[ 9][ 5]=   20; r[ 9][ 6]=   43; r[ 9][ 7]=   25;
+    r[ 9][ 8]=   26;
+
+    r[10][ 0]=  257; r[10][ 1]=  205; r[10][ 2]=   63; r[10][ 3]=   34;
+    r[10][ 4]=   36; r[10][ 5]=  314; r[10][ 6]=   65; r[10][ 7]=   56;
+    r[10][ 8]=  134; r[10][ 9]= 1324;
+
+    r[11][ 0]=  200; r[11][ 1]= 2348; r[11][ 2]=  758; r[11][ 3]=  102;
+    r[11][ 4]=    7; r[11][ 5]=  858; r[11][ 6]=  754; r[11][ 7]=  142;
+    r[11][ 8]=   85; r[11][ 9]=   75; r[11][10]=   94;
+
+    r[12][ 0]=  100; r[12][ 1]=   61; r[12][ 2]=   39; r[12][ 3]=   27;
+    r[12][ 4]=   23; r[12][ 5]=   52; r[12][ 6]=   30; r[12][ 7]=   27;
+    r[12][ 8]=   21; r[12][ 9]=  704; r[12][10]=  974; r[12][11]=  103;
+
+    r[13][ 0]=   51; r[13][ 1]=   16; r[13][ 2]=   15; r[13][ 3]=    8;
+    r[13][ 4]=   66; r[13][ 5]=    9; r[13][ 6]=   13; r[13][ 7]=   18;
+    r[13][ 8]=   50; r[13][ 9]=  196; r[13][10]= 1093; r[13][11]=    7;
+    r[13][12]=   49;
+
+    r[14][ 0]=  901; r[14][ 1]=  217; r[14][ 2]=   31; r[14][ 3]=   39;
+    r[14][ 4]=   15; r[14][ 5]=  395; r[14][ 6]=   71; r[14][ 7]=   93;
+    r[14][ 8]=  157; r[14][ 9]=   31; r[14][10]=  578; r[14][11]=   77;
+    r[14][12]=   23; r[14][13]=   36;
+
+    r[15][ 0]= 2413; r[15][ 1]=  413; r[15][ 2]= 1738; r[15][ 3]=  244;
+    r[15][ 4]=  353; r[15][ 5]=  182; r[15][ 6]=  156; r[15][ 7]= 1131;
+    r[15][ 8]=  138; r[15][ 9]=  172; r[15][10]=  436; r[15][11]=  228;
+    r[15][12]=   54; r[15][13]=  309; r[15][14]= 1138;
+
+    r[16][ 0]= 2440; r[16][ 1]=  230; r[16][ 2]=  693; r[16][ 3]=  151;
+    r[16][ 4]=   66; r[16][ 5]=  149; r[16][ 6]=  142; r[16][ 7]=  164;
+    r[16][ 8]=   76; r[16][ 9]=  930; r[16][10]=  172; r[16][11]=  398;
+    r[16][12]=  343; r[16][13]=   39; r[16][14]=  412; r[16][15]= 2258;
+
+    r[17][ 0]=   11; r[17][ 1]=  109; r[17][ 2]=    2; r[17][ 3]=    5;
+    r[17][ 4]=   38; r[17][ 5]=   12; r[17][ 6]=   12; r[17][ 7]=   69;
+    r[17][ 8]=    5; r[17][ 9]=   12; r[17][10]=   82; r[17][11]=    9;
+    r[17][12]=    8; r[17][13]=   37; r[17][14]=    6; r[17][15]=   36;
+    r[17][16]=    8;
+
+    r[18][ 0]=   41; r[18][ 1]=   46; r[18][ 2]=  114; r[18][ 3]=   89;
+    r[18][ 4]=  164; r[18][ 5]=   40; r[18][ 6]=   15; r[18][ 7]=   15;
+    r[18][ 8]=  514; r[18][ 9]=   61; r[18][10]=   84; r[18][11]=   20;
+    r[18][12]=   17; r[18][13]=  850; r[18][14]=   22; r[18][15]=  164;
+    r[18][16]=   45; r[18][17]=   41;
+
+    r[19][ 0]= 1766; r[19][ 1]=   69; r[19][ 2]=   55; r[19][ 3]=  127;
+    r[19][ 4]=   99; r[19][ 5]=   58; r[19][ 6]=  226; r[19][ 7]=  276;
+    r[19][ 8]=   22; r[19][ 9]= 3938; r[19][10]= 1261; r[19][11]=   58;
+    r[19][12]=  559; r[19][13]=  189; r[19][14]=   84; r[19][15]=  219;
+    r[19][16]=  526; r[19][17]=   27; r[19][18]=   42;
+
+
+    /* Upper triangular is JTT's Accepted point mutations for transmembrane */
+ r[ 0][ 1]=   21; r[ 0][ 2]=    2; r[ 0][ 3]=    7; r[ 0][ 4]=   13;
+ r[ 0][ 5]=    4; r[ 0][ 6]=    6; r[ 0][ 7]=  160; r[ 0][ 8]=    6;
+ r[ 0][ 9]=   44; r[ 0][10]=   43; r[ 0][11]=    5; r[ 0][12]=   10;
+ r[ 0][13]=   21; r[ 0][14]=   34; r[ 0][15]=  198; r[ 0][16]=  202;
+ r[ 0][17]=    0; r[ 0][18]=    1; r[ 0][19]=  292; 
+ 
+ r[ 1][ 2]=    0; r[ 1][ 3]=    1; r[ 1][ 4]=    2; r[ 1][ 5]=   21;
+ r[ 1][ 6]=    3; r[ 1][ 7]=   22; r[ 1][ 8]=   21; r[ 1][ 9]=    4;
+ r[ 1][10]=    8; r[ 1][11]=   53; r[ 1][12]=   19; r[ 1][13]=    0;
+ r[ 1][14]=    1; r[ 1][15]=    5; r[ 1][16]=    5; r[ 1][17]=   28;
+ r[ 1][18]=    0; r[ 1][19]=    0; 
+ 
+ r[ 2][ 3]=   14; r[ 2][ 4]=    1; r[ 2][ 5]=    7; r[ 2][ 6]=    0;
+ r[ 2][ 7]=    0; r[ 2][ 8]=    8; r[ 2][ 9]=    4; r[ 2][10]=    5;
+ r[ 2][11]=   11; r[ 2][12]=    3; r[ 2][13]=    1; r[ 2][14]=    2;
+ r[ 2][15]=   32; r[ 2][16]=   19; r[ 2][17]=    1; r[ 2][18]=    1;
+ r[ 2][19]=    2; 
+ 
+ r[ 3][ 4]=    0; r[ 3][ 5]=    0; r[ 3][ 6]=   12; r[ 3][ 7]=   15;
+ r[ 3][ 8]=    4; r[ 3][ 9]=    1; r[ 3][10]=    0; r[ 3][11]=    2;
+ r[ 3][12]=    1; r[ 3][13]=    0; r[ 3][14]=    1; r[ 3][15]=    0;
+ r[ 3][16]=    6; r[ 3][17]=    0; r[ 3][18]=    1; r[ 3][19]=    4;
+ 
+ r[ 4][ 5]=    0; r[ 4][ 6]=    0; r[ 4][ 7]=   13; r[ 4][ 8]=    2;
+ r[ 4][ 9]=    4; r[ 4][10]=   11; r[ 4][11]=    0; r[ 4][12]=    1;
+ r[ 4][13]=   34; r[ 4][14]=    0; r[ 4][15]=   48; r[ 4][16]=   13;
+ r[ 4][17]=    8; r[ 4][18]=   23; r[ 4][19]=   47; 
+ 
+ r[ 5][ 6]=   16; r[ 5][ 7]=    1; r[ 5][ 8]=   26; r[ 5][ 9]=    1;
+ r[ 5][10]=   16; r[ 5][11]=    6; r[ 5][12]=    3; r[ 5][13]=    0;
+ r[ 5][14]=    5; r[ 5][15]=    7; r[ 5][16]=    2; r[ 5][17]=    0;
+ r[ 5][18]=    0; r[ 5][19]=    0; 
+ 
+ r[ 6][ 7]=   21; r[ 6][ 8]=    0; r[ 6][ 9]=    0; r[ 6][10]=    0;
+ r[ 6][11]=    0; r[ 6][12]=    0; r[ 6][13]=    0; r[ 6][14]=    0;
+ r[ 6][15]=    4; r[ 6][16]=    2; r[ 6][17]=    0; r[ 6][18]=    0;
+ r[ 6][19]=    7; 
+ 
+ r[ 7][ 8]=    1; r[ 7][ 9]=   10; r[ 7][10]=    0; r[ 7][11]=    0;
+ r[ 7][12]=    3; r[ 7][13]=    4; r[ 7][14]=    7; r[ 7][15]=   64;
+ r[ 7][16]=   12; r[ 7][17]=    5; r[ 7][18]=    0; r[ 7][19]=   53;
+ 
+ r[ 8][ 9]=    3; r[ 8][10]=    2; r[ 8][11]=    0; r[ 8][12]=    1;
+ r[ 8][13]=    0; r[ 8][14]=    0; r[ 8][15]=    0; r[ 8][16]=    4;
+ r[ 8][17]=    0; r[ 8][18]=   29; r[ 8][19]=    2;
+
+ r[ 9][10]=  273; r[ 9][11]=    0; r[ 9][12]=  161; r[ 9][13]=   66;
+ r[ 9][14]=    4; r[ 9][15]=   22; r[ 9][16]=  150; r[ 9][17]=    1;
+ r[ 9][18]=    4; r[ 9][19]=  883;
+
+ r[10][11]=    1; r[10][12]=  153; r[10][13]=  251; r[10][14]=   37;
+ r[10][15]=   43; r[10][16]=   26; r[10][17]=   20; r[10][18]=    6;
+ r[10][19]=  255;
+
+ r[11][12]=    4; r[11][13]=    0; r[11][14]=    0; r[11][15]=    1;
+ r[11][16]=    2; r[11][17]=    0; r[11][18]=    5; r[11][19]=    1;
+
+ r[12][13]=    8; r[12][14]=    0; r[12][15]=    1; r[12][16]=   32;
+ r[12][17]=    1; r[12][18]=    5; r[12][19]=   89;
+
+ r[13][14]=    0; r[13][15]=   32; r[13][16]=    9; r[13][17]=    2;
+ r[13][18]=   54; r[13][19]=   37;
+
+ r[14][15]=    9; r[14][16]=   10; r[14][17]=    0; r[14][18]=    1;
+ r[14][19]=    1;
+
+ r[15][16]=  134; r[15][17]=    1; r[15][18]=   22; r[15][19]=   13;
+
+ r[16][17]=    1; r[16][18]=    3; r[16][19]=   48;
+
+ r[17][18]=    2; r[17][19]=   18;
+
+ r[18][19]=    2;
+
+
+
+	for (i = 0; i < 20; i++) r[i][i] = 0.0;
+	if( isTM )
+	{
+		for (i = 1; i < 20; i++) for (j = 0; j < i; j++)
+		{
+			r[j][i] /= 400.0 * freq0_TM[i] * freq0_TM[j];
+			r[i][j] = r[j][i];
+		}
+		for( i=0; i<20; i++ ) freq[i] = freq0_TM[i];
+	}
+	else
+	{
+		for (i = 1; i < 20; i++) for (j = 0; j < i; j++)
+		{
+			r[i][j] /= 400.0 * freq0[i] * freq0[j];
+			r[j][i] = r[i][j];
+		}
+		for( i=0; i<20; i++ ) freq[i] = freq0[i];
+	}
+
+	for( i=0; i<26; i++ ) locamino[i] = locamino0[i];
+	for( i=0; i<26; i++ ) locgrp[(int)locamino[i]] = locgrp0[i];
+	for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) rsr[i][j] = r[i][j];
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Lalign11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Lalign11.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Lalign11.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Lalign11.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,533 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+#define DEBUG2 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  1
+
+static int localstop; // 060910
+
+#if 1
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 ) 
+{
+	char *seq2 = s2[0];
+	int *intptr;
+
+	intptr = amino_dis[(int)s1[0][i1]];
+	while( lgth2-- )
+		*match++ = intptr[(int)*seq2++];
+}
+#else
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 )
+{
+	int j;
+
+	for( j=0; j<lgth2; j++ )
+		match[j] = amino_dis[(*s1)[i1]][(*s2)[j]];
+}
+#endif
+
+#if 0
+static void match_calc_bk( 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[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+#if 0 /* ¤³¤ì¤ò»È¤¦¤È¤­¤Ï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[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+#endif
+
+static float Ltracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        int **ijp, int *off1pt, int *off2pt, int endi, int endj )
+{
+	int i, j, l, iin, jin, lgth1, lgth2, k, limk;
+	int ifi=0, jfi=0; // by D.Mathog, a guess
+	char gap[] = "-";
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = localstop;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = localstop;
+    }
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+	iin = endi; jin = endj;
+	limk = lgth1+lgth2;
+	for( k=0; k<=limk; 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 ) 
+		{
+			*--mseq1[0] = seq1[0][ifi+l];
+			*--mseq2[0] = *gap;
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--mseq1[0] = *gap;
+			*--mseq2[0] = seq2[0][jfi+l];
+			k++;
+		}
+
+		if( iin <= 0 || jin <= 0 ) break;
+		*--mseq1[0] = seq1[0][ifi];
+		*--mseq2[0] = seq2[0][jfi];
+		if( ijp[ifi][jfi] == localstop ) break;
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	if( ifi == -1 ) *off1pt = 0; else *off1pt = ifi;
+	if( jfi == -1 ) *off2pt = 0; else *off2pt = jfi;
+
+//	fprintf( stderr, "ifn = %d, jfn = %d\n", ifi, jfi );
+
+
+	return( 0.0 );
+}
+
+
+float L__align11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;                      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+//	static int **intwork;
+//	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float maxwm;
+	int endali = 0, endalj = 0; // by D.Mathog, a guess
+//	int endali, endalj;
+	float localthr = -offset;
+	float localthr2 = -offset;
+//	float localthr = 100;
+//	float localthr2 = 100;
+	float fpenalty = (float)penalty;
+	float fpenalty_ex = (float)penalty_ex;
+
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+
+
+//			FreeFloatMtx( floatwork );
+//			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+
+//		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+//		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, seq2, seq1, 0, lgth1 );
+
+	match_calc( currentw, seq1, seq2, 0, lgth2 );
+
+
+	lasti = lgth2+1;
+	for( j=1; j<lasti; ++j ) 
+	{
+		m[j] = currentw[j-1]; mp[j] = 0;
+#if 0
+		if( m[j] < localthr ) m[j] = localthr2;
+#endif
+	}
+
+	lastverticalw[0] = currentw[lgth2-1];
+
+	lasti = lgth1+1;
+
+#if 0
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if DEBUG2
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "       " );
+	for( j=0; j<lgth2; j++ )
+		fprintf( stderr, "%c     ", seq2[0][j] );
+	fprintf( stderr, "\n" );
+#endif
+
+	localstop = lgth1+lgth2+1;
+	maxwm = -999999999.9;
+#if DEBUG2
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "%c   ", seq1[0][0] );
+
+	for( j=0; j<lgth2+1; j++ )
+		fprintf( stderr, "%5.0f ", currentw[j] );
+	fprintf( stderr, "\n" );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, seq1, seq2, i, lgth2 );
+#if DEBUG2
+		fprintf( stderr, "%c   ", seq1[0][i] );
+		fprintf( stderr, "%5.0f ", currentw[0] );
+#endif
+
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0]; mpi = 0;
+
+#if 0
+		if( mi < localthr ) mi = localthr2;
+#endif
+
+		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
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+fpenalty) > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			if( *prept > mi )
+			{
+				mi = *prept;
+				mpi = j-1;
+			}
+
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt+fpenalty) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			if( *prept > *mjpt )
+			{
+				*mjpt = *prept;
+				*mpjpt = i-1;
+			}
+#if USE_PENALTY_EX
+			*mjpt += fpenalty_ex;
+#endif
+
+			if( maxwm < wm )
+			{
+				maxwm = wm;
+				endali = i;
+				endalj = j;
+			}
+#if 1
+			if( wm < localthr )
+			{
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				*ijppt = localstop;
+				wm = localthr2;
+			}
+#endif
+#if 0
+			fprintf( stderr, "%5.0f ", *curpt );
+#endif
+#if DEBUG2
+			fprintf( stderr, "%5.0f ", wm );
+//			fprintf( stderr, "%c-%c *ijppt = %d, localstop = %d\n", seq1[0][i], seq2[0][j], *ijppt, localstop );
+#endif
+
+			*curpt++ += wm;
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+		}
+#if DEBUG2
+		fprintf( stderr, "\n" );
+#endif
+
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+
+#if 0
+	fprintf( stderr, "maxwm = %f\n", maxwm );
+	fprintf( stderr, "endali = %d\n", endali );
+	fprintf( stderr, "endalj = %d\n", endalj );
+#endif
+
+	if( ijp[endali][endalj] == localstop )
+	{
+		strcpy( seq1[0], "" );
+		strcpy( seq2[0], "" );
+		*off1pt = *off2pt = 0;
+		return( 0.0 );
+	}
+		
+	Ltracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, ijp, off1pt, off2pt, endali, endalj );
+
+
+	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" );
+	}
+
+
+	strcpy( seq1[0], mseq1[0] );
+	strcpy( seq2[0], mseq2[0] );
+
+#if 0
+	fprintf( stderr, "wm=%f\n", wm );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+
+	fprintf( stderr, "maxwm = %f\n", maxwm );
+	fprintf( stderr, "   wm = %f\n",    wm );
+#endif
+
+	return( maxwm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Lalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Lalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Lalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Lalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,2685 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MEMSAVE 1
+
+#define DEBUG 0
+#define USE_PENALTY_EX  0
+#define STOREWM 1
+
+#define DPTANNI 10
+
+#define LOCAL 0
+
+static int reccycle = 0;
+
+static float localthr;
+
+static void match_ribosum( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+	int j, k, l;
+	float scarr[38];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	int count = 0;
+	float *matchpt;
+	float **cpmxpdpt;
+	int **cpmxpdnpt;
+	int cpkd;
+
+	if( initialize )
+	{
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<37; l++ )
+			{
+				if( cpmx2[j][l] )
+				{
+					cpmxpd[j][count] = cpmx2[j][l];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	for( l=0; l<37; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<37; k++ )
+		{
+			scarr[l] += ribosumdis[k][l] * cpmx1[i1][k];
+		}
+	}
+#if 0 /* ¤³¤ì¤ò»È¤¦¤È¤­¤Ï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++;
+		} 
+	}
+	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];
+	} 
+#else
+	matchpt = match;
+	cpmxpdnpt = cpmxpdn;
+	cpmxpdpt = cpmxpd;
+	while( lgth2-- )
+	{
+		*matchpt = 0.0;
+		for( k=0; (cpkd=(*cpmxpdnpt)[k])>-1; k++ )
+			*matchpt += scarr[cpkd] * (*cpmxpdpt)[k];
+		matchpt++;
+		cpmxpdnpt++;
+		cpmxpdpt++;
+	}
+#endif
+}
+
+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;
+	float *matchpt;
+	float **cpmxpdpt;
+	int **cpmxpdnpt;
+	int cpkd;
+
+	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]-RNAthr) * cpmx1[i1][k];
+		}
+	}
+#if 0 /* ¤³¤ì¤ò»È¤¦¤È¤­¤Ï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++;
+		} 
+	}
+	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];
+	} 
+#else
+	matchpt = match;
+	cpmxpdnpt = cpmxpdn;
+	cpmxpdpt = cpmxpd;
+	while( lgth2-- )
+	{
+		*matchpt = 0.0;
+		for( k=0; (cpkd=(*cpmxpdnpt)[k])>-1; k++ )
+			*matchpt += scarr[cpkd] * (*cpmxpdpt)[k];
+		matchpt++;
+		cpmxpdnpt++;
+		cpmxpdpt++;
+	}
+#endif
+}
+
+#if 0
+static void match_add( 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;
+	float *matchpt;
+	float **cpmxpdpt;
+	int **cpmxpdnpt;
+	int cpkd;
+
+
+	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 /* ¤³¤ì¤ò»È¤¦¤È¤­¤Ï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++;
+		} 
+	}
+	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];
+	} 
+#else
+	matchpt = match;
+	cpmxpdnpt = cpmxpdn;
+	cpmxpdpt = cpmxpd;
+	while( lgth2-- )
+	{
+//		*matchpt = 0.0; // add dakara
+		for( k=0; (cpkd=(*cpmxpdnpt)[k])>-1; k++ )
+			*matchpt += scarr[cpkd] * (*cpmxpdpt)[k];
+		matchpt++;
+		cpmxpdnpt++;
+		cpmxpdpt++;
+	}
+#endif
+}
+#endif
+
+#if 0
+static float Atracking( 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        int **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 *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = ien-ist+1;
+	lgth2 = jen-jst+1;
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+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 );
+    }
+
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i]+ist, gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j]+jst, gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+//	fprintf( stderr, "in Atracking (owari), mseq1 = %s\n", mseq1[0] );
+//	fprintf( stderr, "in Atracking (owari), mseq2 = %s\n", mseq2[0] );
+	return( 0.0 );
+}
+#endif
+
+
+static float MSalign2m2m_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, float **map )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+	float value = 0.0;
+	register int i, j;
+	char **aseq1, **aseq2;
+	int ll1, ll2;
+	int lasti, lastj, imid, jmid = 0;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+//	float fpenalty = (float)penalty;
+	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;
+	int lgth1, lgth2;
+	float maxwm = 0.0;
+	int *jumpforwi;
+	int *jumpforwj;
+	int *jumpbacki;
+	int *jumpbackj;
+	int *jumpdummi; //muda
+	int *jumpdummj; //muda
+	int jumpi, jumpj = 0;
+	char *gaps;
+	int ijpi, ijpj;
+	float *ogcp1;
+	float *fgcp1;
+	float *ogcp2;
+	float *fgcp2;
+	float firstm;
+	int firstmp;
+#if 0
+	static char ttt1[50000];
+	static char ttt2[50000];
+#endif
+
+	localthr = -offset + 500; // 0?
+
+	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( lgth1 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth1 = %d\n", lgth1 );
+//	if( lgth2 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth2 = %d\n", lgth2 );
+//
+
+#if 0
+	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 );
+	}
+
+#if MEMSAVE
+	aseq1 = AllocateCharMtx( icyc, 0 );
+	aseq2 = AllocateCharMtx( jcyc, 0 );
+	for( i=0; i<icyc; i++ ) aseq1[i] = mseq1[i];
+	for( i=0; i<jcyc; i++ ) aseq2[i] = mseq2[i];
+#else
+	aseq1 = AllocateCharMtx( icyc, lgth1+lgth2+100 );
+	aseq2 = AllocateCharMtx( jcyc, lgth1+lgth2+100 );
+#endif
+
+//  if( lgth1 < DPTANNI && lgth2 < DPTANNI ) // & dato lgth ==1 no kanousei ga arunode yokunai 
+//    if( lgth1 < DPTANNI ) // kore mo lgth2 ga mijikasugiru kanousei ari
+    if( lgth1 < DPTANNI || lgth2 < DPTANNI ) // zettai ni anzen ka?
+	{
+//		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 );	
+
+
+#if MEMSAVE
+		free( aseq1 );
+		free( aseq2 );
+#else
+		for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
+		for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
+
+		FreeCharMtx( aseq1 );
+		FreeCharMtx( aseq2 );
+#endif
+
+//		fprintf( stderr, "value = %f\n", value );
+
+		return( value );
+	}
+//	fprintf( stderr, "Trying to divide the mtx\n" );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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_ribosum( initverticalw, cpmx2+jst, cpmx1+ist, 0, lgth1, floatwork, intwork, 1 );
+
+	match_ribosum( currentw, cpmx1+ist, cpmx2+jst, 0, lgth2, floatwork, intwork, 1 );
+
+	for( i=1; i<lgth1+1; i++ )
+	{
+		initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] );
+	}
+	for( j=1; j<lgth2+1; j++ )
+	{
+		currentw[j] += ( ogcp2[0] + fgcp2[j-1] );
+	}
+
+#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] + 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_ribosum( currentw, cpmx1+ist, cpmx2+jst, i, lgth2, floatwork, intwork, 0 );
+		currentw[0] = initverticalw[i];
+
+		m[0] = ogcp1[i];
+#if STOREM
+		WMMTX2[i][0] = m[0];
+#endif
+		if( i == imid ) midm[0] = m[0];
+
+		mi = previousw[0] + 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 + fgcp2[j-1];
+//			g = mi + fpenalty;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = -( j - mpi );
+			}
+			g = *prept + ogcp2[j];
+//			g = *prept;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1[i-1];
+//			g = *mjpt + fpenalty;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = +( i - *mpjpt );
+			}
+
+
+			g = *prept + ogcp1[i];
+//			g = *prept;
+			if( g >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+#if LOCAL
+            if( wm < localthr )
+            {       
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				wm = 0;
+            }       
+#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_ribosum( initverticalw, cpmx2+jst, cpmx1+ist, lgth2-1, lgth1, floatwork, intwork, 1 );
+	match_ribosum( currentw, cpmx1+ist, cpmx2+jst, lgth1-1, lgth2, floatwork, intwork, 1 );
+
+	for( i=0; i<lgth1-1; i++ )
+	{
+		initverticalw[i] += ( fgcp1[lgth1-1] + ogcp1[i+1] );
+//		initverticalw[i] += fpenalty;
+	}
+	for( j=0; j<lgth2-1; j++ )
+	{
+		currentw[j] += ( fgcp2[lgth2-1] + ogcp2[j+1] );
+//		currentw[j] += fpenalty;
+	}
+
+#if STOREWM
+	for( i=0; i<lgth1-1; i++ )
+	{
+		WMMTX[i][lgth2-1] += ( 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] += ( 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] + 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_ribosum( currentw, cpmx1+ist, cpmx2+jst, i, lgth2, floatwork, intwork, 0 );
+
+		currentw[lgth2-1] = initverticalw[i];
+
+//		m[lgth2] = fgcp1[i];
+//		WMMTX2[i][lgth2] += m[lgth2];
+//		fprintf( stderr, "m[] = %f\n", m[lgth2] );
+
+		mi = previousw[lgth2-1] + 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 + ogcp2[j+1];
+//			g = mi + fpenalty;
+			if( g > wm )
+			{
+				wm = g;
+				ijpj = mpi;
+				ijpi = i+1;
+			}
+
+			g = *prept + 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 + 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 + 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 LOCAL
+            if( wm < localthr )
+            {       
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				wm = 0;
+            }       
+#endif
+
+#if STOREWM
+			WMMTX[i][j] += wm;
+//			WMMTX2[i][j+1] += *mjpt + fpenalty;
+			WMMTX2[i][j] += *curpt;
+#endif
+			*curpt += wm;
+
+			mjpt--;
+			prept--;
+			mpjpt--;
+			curpt--;
+		}
+//		fprintf( stderr, "adding *mjpt (=%f) to WMMTX2[%d][%d]\n", *mjpt, i, j+1 );
+		g = *prept + 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( jmid > 0 && midn[jmid-1] > wm ) //060413
+			{
+				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 0
+			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;
+			}
+
+#if 0
+			else if( jmid == lgth2 ) 
+			{
+				fprintf( stderr, "CHUI1!\n" );
+				jumpi=0; jumpj=0;
+				imid=jumpforwi[0]; jmid=lgth2-1;
+			}
+#else // 060414
+			else if( jmid >= lgth2 ) 
+			{
+//				fprintf( stderr, "CHUI1!\n" );
+				jumpi=imid-1; jmid=lgth2;
+				jumpj = lgth2-1;
+			}
+#endif
+			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];
+
+
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		map[i][j] = WMMTX[i][j] / maxwm;
+//		map[i][j] = WMMTX2[i][j] / maxwm;
+
+#if STOREWM
+
+#if 0
+	for( i=0; i<lgth1; i++ )
+	{
+		float maxpairscore = -9999.9;
+		float tmpscore;
+
+		for( j=0; j<lgth2; j++ )
+		{
+			if( maxpairscore < (tmpscore=WMMTX[i][j]) )
+			{
+				map12[i].pos = j;
+				map12[i].score = tmpscore;
+				maxpairscore = tmpscore;
+			}
+		}
+
+		for( k=0; k<lgth1; k++ )
+		{
+			if( i == k ) continue;
+			if( map12[i].score <= WMMTX[k][map12[i].pos] )
+				break;
+		}
+		if( k != lgth1 )
+		{
+			map12[i].pos = -1;
+			map12[i].score = -1.0;
+		}
+		fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", i, map12[i].pos, map12[i].score, seq1[0][i], seq2[0][map12[i].pos] );
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		float maxpairscore = -9999.9;
+		float tmpscore;
+
+		for( i=0; i<lgth1; i++ )
+		{
+			if( maxpairscore < (tmpscore=WMMTX[i][j]) )
+			{
+				map21[j].pos = i;
+				map21[j].score = tmpscore;
+				maxpairscore = tmpscore;
+			}
+		}
+
+		for( k=0; k<lgth2; k++ )
+		{
+			if( j == k ) continue;
+			if( map21[j].score <= WMMTX[map21[j].pos][k] )
+				break;
+		}
+		if( k != lgth2 )
+		{
+			map21[j].pos = -1;
+			map21[j].score = -1.0;
+		}
+		fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", j, map21[j].pos, map21[j].score, seq2[0][j], seq1[0][map21[j].pos] );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		if( map12[i].pos != -1 ) if( map21[map12[i].pos].pos != i ) 
+			fprintf( stderr, "ERROR i=%d, but map12[i].pos=%d and map21[map12[i].pos]=%d\n", i, map12[i].pos, map21[map12[i].pos].pos );
+	}
+#endif
+
+#if 0
+	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" );
+    }
+#endif
+
+#if 0
+    fprintf( stdout, "#WMMTX = \n" );
+    for( i=0; i<lgth1; i++ )
+    {
+//        fprintf( stdout, "%d ", i ); 
+        for( j=0; j<lgth2; j++ )
+        {
+//          if( WMMTX[i][j] > amino_dis['a']['g'] -1 )
+                fprintf( stdout, "%d %d %8.1f", i, j, WMMTX[i][j] );
+			if( WMMTX[i][j] == maxwm )
+                fprintf( stdout, "selected \n" );
+			else
+                fprintf( stdout, "\n" );
+        }
+        fprintf( stdout, "\n" );
+    }
+#endif
+
+#if 0
+
+	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
+
+
+#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
+
+	return( value );
+
+}
+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, float **map )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+	int alnlen;
+	float value = 0.0;
+	register int i, j;
+	char **aseq1, **aseq2;
+	int ll1, ll2, l, len;
+	int lasti, lastj, imid, jmid=0;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)RNApenalty_ex;
+#endif
+//	float fpenalty = (float)penalty;
+	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;
+	int lgth1, lgth2;
+	float maxwm = 0.0;
+	int *jumpforwi;
+	int *jumpforwj;
+	int *jumpbacki;
+	int *jumpbackj;
+	int *jumpdummi; //muda
+	int *jumpdummj; //muda
+	int jumpi, jumpj = 0;
+	char *gaps;
+	int ijpi, ijpj;
+	float *ogcp1;
+	float *fgcp1;
+	float *ogcp2;
+	float *fgcp2;
+	float firstm;
+	int firstmp;
+#if 0
+	static char ttt1[50000];
+	static char ttt2[50000];
+#endif
+
+	localthr = -offset + 500; // 0?
+
+	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( lgth1 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth1 = %d\n", lgth1 );
+//	if( lgth2 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth2 = %d\n", lgth2 );
+//
+
+#if 0
+	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 );
+	}
+
+#if MEMSAVE
+	aseq1 = AllocateCharMtx( icyc, 0 );
+	aseq2 = AllocateCharMtx( jcyc, 0 );
+	for( i=0; i<icyc; i++ ) aseq1[i] = mseq1[i];
+	for( i=0; i<jcyc; i++ ) aseq2[i] = mseq2[i];
+#else
+	aseq1 = AllocateCharMtx( icyc, lgth1+lgth2+100 );
+	aseq2 = AllocateCharMtx( jcyc, lgth1+lgth2+100 );
+#endif
+
+//  if( lgth1 < DPTANNI && lgth2 < DPTANNI ) // & dato lgth ==1 no kanousei ga arunode yokunai 
+//    if( lgth1 < DPTANNI ) // kore mo lgth2 ga mijikasugiru kanousei ari
+    if( lgth1 < DPTANNI || lgth2 < DPTANNI ) // zettai ni anzen ka?
+	{
+//		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 );	
+
+
+#if MEMSAVE
+		free( aseq1 );
+		free( aseq2 );
+#else
+		for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
+		for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
+
+		FreeCharMtx( aseq1 );
+		FreeCharMtx( aseq2 );
+#endif
+
+//		fprintf( stderr, "value = %f\n", value );
+
+		return( value );
+	}
+//	fprintf( stderr, "Trying to divide the mtx\n" );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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] += ( ogcp1[0] + fgcp1[i-1] );
+	}
+	for( j=1; j<lgth2+1; j++ )
+	{
+		currentw[j] += ( ogcp2[0] + fgcp2[j-1] );
+	}
+
+#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] + 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] = ogcp1[i];
+#if STOREM
+		WMMTX2[i][0] = m[0];
+#endif
+		if( i == imid ) midm[0] = m[0];
+
+		mi = previousw[0] + 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 + fgcp2[j-1];
+//			g = mi + fpenalty;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = -( j - mpi );
+			}
+			g = *prept + ogcp2[j];
+//			g = *prept;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1[i-1];
+//			g = *mjpt + fpenalty;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = +( i - *mpjpt );
+			}
+
+
+			g = *prept + ogcp1[i];
+//			g = *prept;
+			if( g >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+#if LOCAL
+            if( wm < localthr )
+            {       
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				wm = 0;
+            }       
+#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] += ( fgcp1[lgth1-1] + ogcp1[i+1] );
+//		initverticalw[i] += fpenalty;
+	}
+	for( j=0; j<lgth2-1; j++ )
+	{
+		currentw[j] += ( fgcp2[lgth2-1] + ogcp2[j+1] );
+//		currentw[j] += fpenalty;
+	}
+
+#if STOREWM
+	for( i=0; i<lgth1-1; i++ )
+	{
+		WMMTX[i][lgth2-1] += ( 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] += ( 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] + 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] = fgcp1[i];
+//		WMMTX2[i][lgth2] += m[lgth2];
+//		fprintf( stderr, "m[] = %f\n", m[lgth2] );
+
+		mi = previousw[lgth2-1] + 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 + ogcp2[j+1];
+//			g = mi + fpenalty;
+			if( g > wm )
+			{
+				wm = g;
+				ijpj = mpi;
+				ijpi = i+1;
+			}
+
+			g = *prept + 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 + 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 + 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 LOCAL
+            if( wm < localthr )
+            {       
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				wm = 0;
+            }       
+#endif
+
+#if STOREWM
+			WMMTX[i][j] += wm;
+//			WMMTX2[i][j+1] += *mjpt + fpenalty;
+			WMMTX2[i][j] += *curpt;
+#endif
+			*curpt += wm;
+
+			mjpt--;
+			prept--;
+			mpjpt--;
+			curpt--;
+		}
+//		fprintf( stderr, "adding *mjpt (=%f) to WMMTX2[%d][%d]\n", *mjpt, i, j+1 );
+		g = *prept + 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( jmid > 0 && midn[jmid-1] > wm ) //060413
+			{
+				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 0
+			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;
+			}
+
+#if 0
+			else if( jmid == lgth2 ) 
+			{
+				fprintf( stderr, "CHUI1!\n" );
+				jumpi=0; jumpj=0;
+				imid=jumpforwi[0]; jmid=lgth2-1;
+			}
+#else // 060414
+			else if( jmid >= lgth2 ) 
+			{
+//				fprintf( stderr, "CHUI1!\n" );
+				jumpi=imid-1; jmid=lgth2;
+				jumpj = lgth2-1;
+			}
+#endif
+			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];
+
+
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		map[i][j] = WMMTX[i][j] / maxwm;
+//		map[i][j] = WMMTX2[i][j] / maxwm;
+
+#if STOREWM
+
+#if 0
+	for( i=0; i<lgth1; i++ )
+	{
+		float maxpairscore = -9999.9;
+		float tmpscore;
+
+		for( j=0; j<lgth2; j++ )
+		{
+			if( maxpairscore < (tmpscore=WMMTX[i][j]) )
+			{
+				map12[i].pos = j;
+				map12[i].score = tmpscore;
+				maxpairscore = tmpscore;
+			}
+		}
+
+		for( k=0; k<lgth1; k++ )
+		{
+			if( i == k ) continue;
+			if( map12[i].score <= WMMTX[k][map12[i].pos] )
+				break;
+		}
+		if( k != lgth1 )
+		{
+			map12[i].pos = -1;
+			map12[i].score = -1.0;
+		}
+		fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", i, map12[i].pos, map12[i].score, seq1[0][i], seq2[0][map12[i].pos] );
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		float maxpairscore = -9999.9;
+		float tmpscore;
+
+		for( i=0; i<lgth1; i++ )
+		{
+			if( maxpairscore < (tmpscore=WMMTX[i][j]) )
+			{
+				map21[j].pos = i;
+				map21[j].score = tmpscore;
+				maxpairscore = tmpscore;
+			}
+		}
+
+		for( k=0; k<lgth2; k++ )
+		{
+			if( j == k ) continue;
+			if( map21[j].score <= WMMTX[map21[j].pos][k] )
+				break;
+		}
+		if( k != lgth2 )
+		{
+			map21[j].pos = -1;
+			map21[j].score = -1.0;
+		}
+		fprintf( stderr, "pair of %d = %d (%f) %c:%c\n", j, map21[j].pos, map21[j].score, seq2[0][j], seq1[0][map21[j].pos] );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		if( map12[i].pos != -1 ) if( map21[map12[i].pos].pos != i ) 
+			fprintf( stderr, "ERROR i=%d, but map12[i].pos=%d and map21[map12[i].pos]=%d\n", i, map12[i].pos, map21[map12[i].pos].pos );
+	}
+#endif
+
+#if 0
+	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" );
+    }
+	exit( 1 );
+#endif
+
+#if 0
+    fprintf( stdout, "#WMMTX = \n" );
+    for( i=0; i<lgth1; i++ )
+    {
+//        fprintf( stdout, "%d ", i ); 
+        for( j=0; j<lgth2; j++ )
+        {
+//          if( WMMTX[i][j] > amino_dis['a']['g'] -1 )
+                fprintf( stdout, "%d %d %8.1f", i, j, WMMTX[i][j] );
+			if( WMMTX[i][j] == maxwm )
+                fprintf( stdout, "selected \n" );
+			else
+                fprintf( stdout, "\n" );
+        }
+        fprintf( stdout, "\n" );
+    }
+	exit( 1 );
+#endif
+
+#if 0
+
+	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
+
+
+#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
+
+	return( value );
+
+//	fprintf( stderr, "==== calling myself (first)\n" );
+
+#if 0
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
+#endif
+	value = MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist, ist+jumpi, jst, jst+jumpj, alloclen, aseq1, aseq2, depth, gapinfo, map );	
+#if 0
+		fprintf( stderr, "aseq1[0] = %s\n", aseq1[0] );
+		fprintf( stderr, "aseq2[0] = %s\n", aseq2[0] );
+#endif
+#if MEMSAVE
+#else
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
+#endif
+
+//	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 +=  ( 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 += ( 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" );
+
+#if MEMSAVE
+	alnlen = strlen( aseq1[0] );
+	for( i=0; i<icyc; i++ ) aseq1[i] += alnlen;
+	for( i=0; i<jcyc; i++ ) aseq2[i] += alnlen;
+#endif
+
+#if 0
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
+#endif
+	value += MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist+imid, ien, jst+jmid, jen, alloclen, aseq1, aseq2, depth, gapinfo, map );	
+#if 0
+		fprintf( stderr, "aseq1[0] = %s\n", aseq1[0] );
+		fprintf( stderr, "aseq2[0] = %s\n", aseq2[0] );
+#endif
+
+
+
+#if DEBUG
+	if( value - maxwm > 1 || maxwm - value > 1 )
+	{
+		fprintf( stderr, "WARNING value  = %f, but maxwm = %f\n", value, maxwm );
+		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
+
+#if MEMSAVE
+#else
+	for( i=0; i<icyc; i++ ) strcat( mseq1[i], aseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcat( mseq2[i], aseq2[i] );
+#endif
+
+//	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 );
+#if MEMSAVE
+	free( aseq1 );
+	free( aseq2 );
+#else
+	FreeCharMtx( aseq1 );
+	FreeCharMtx( aseq2 );
+#endif
+	
+	return( value );
+}
+
+
+
+float Lalignmm_hmout( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *sgap1, char *sgap2, char *egap1, char *egap2, float **map )
+/* 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 = 0.0;   /* int ?????? */
+	char **mseq1;
+	char **mseq2;
+//	char **mseq;
+	float *ogcp1;
+	float *ogcp2;
+	float *fgcp1;
+	float *fgcp2;
+	float **cpmx1;
+	float **cpmx2;
+	float **gapinfo;
+//	float fpenalty;
+	float fpenalty = (float)RNApenalty;
+	int nglen1, nglen2;
+
+
+
+
+
+#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
+
+	nglen1 = seqlen( seq1[0] );
+	nglen2 = seqlen( seq2[0] );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+
+	MScpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	MScpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+
+#if 1
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
+		new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
+		new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap2 );
+		new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp1[%d] = %f\n", i, fgcp1[i] );
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp2[%d] = %f\n", i, fgcp2[i] );
+	}
+#else
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * fpenalty;
+		fgcp1[i] = 0.5 * fpenalty;
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * fpenalty;
+		fgcp2[i] = 0.5 * fpenalty;
+	}
+#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, map );
+#if DEBUG
+		fprintf( stderr, " seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, " seq2[0] = %s\n", seq2[0] );
+		fprintf( stderr, "mseq1[0] = %s\n", mseq1[0] );
+		fprintf( stderr, "mseq2[0] = %s\n", mseq2[0] );
+#endif
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if 0
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcpy( seq2[i], mseq2[i] );
+
+	if( seqlen( seq1[0] ) != nglen1 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen1) seqlen(seq1[0])=%d but nglen1=%d\n", seqlen( seq1[0] ), nglen1 );
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		exit( 1 );
+	}
+	if( seqlen( seq2[0] ) != nglen2 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen2) seqlen(seq2[0])=%d but nglen2=%d\n", seqlen( seq2[0] ), nglen2 );
+		exit( 1 );
+	}
+#endif
+
+	FreeFloatVec( ogcp1 );
+	FreeFloatVec( ogcp2 );
+	FreeFloatVec( fgcp1 );
+	FreeFloatVec( fgcp2 );
+	FreeFloatMtx( cpmx1 );
+	FreeFloatMtx( cpmx2 );
+	free( (void *)gapinfo );
+
+	FreeCharMtx( mseq1 );
+	FreeCharMtx( mseq2 );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	for( i=0; i<icyc; i++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+
+	return( wm );
+}
+
+float Lalign2m2m_hmout( char **seq1, char **seq2, char **seq1r, char **seq2r, char *dir1, char *dir2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *sgap1, char *sgap2, char *egap1, char *egap2, float **map )
+/* 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 = 0.0;   /* int ?????? */
+	char **mseq1;
+	char **mseq2;
+	float *ogcp1;
+	float *ogcp2;
+	float *fgcp1;
+	float *fgcp2;
+	float **cpmx1;
+	float **cpmx2;
+	float **gapinfo;
+	float fpenalty = (float)penalty;
+	int nglen1, nglen2;
+
+#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
+
+	nglen1 = seqlen( seq1[0] );
+	nglen2 = seqlen( seq2[0] );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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, 39 );
+	cpmx2 = AllocateFloatMtx( ll2+2, 39 );
+
+	for( i=0; i<icyc; i++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+
+#if 0
+	MScpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	MScpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+#else
+	cpmx_ribosum( seq1, seq1r, dir1, cpmx1, eff1, lgth1, icyc );
+	cpmx_ribosum( seq2, seq2r, dir2, cpmx2, eff2, lgth2, jcyc );
+#endif
+
+
+#if 1
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
+		new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
+		new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap2 );
+		new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp1[%d] = %f\n", i, fgcp1[i] );
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp2[%d] = %f\n", i, fgcp2[i] );
+	}
+#else
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * fpenalty;
+		fgcp1[i] = 0.5 * fpenalty;
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * fpenalty;
+		fgcp2[i] = 0.5 * fpenalty;
+	}
+#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 = MSalign2m2m_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, 0, lgth1-1, 0, lgth2-1, alloclen, mseq1, mseq2, 0, gapinfo, map );
+#if DEBUG
+		fprintf( stderr, " seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, " seq2[0] = %s\n", seq2[0] );
+		fprintf( stderr, "mseq1[0] = %s\n", mseq1[0] );
+		fprintf( stderr, "mseq2[0] = %s\n", mseq2[0] );
+#endif
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if 0
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcpy( seq2[i], mseq2[i] );
+
+	if( seqlen( seq1[0] ) != nglen1 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen1) seqlen(seq1[0])=%d but nglen1=%d\n", seqlen( seq1[0] ), nglen1 );
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		exit( 1 );
+	}
+	if( seqlen( seq2[0] ) != nglen2 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen2) seqlen(seq2[0])=%d but nglen2=%d\n", seqlen( seq2[0] ), nglen2 );
+		exit( 1 );
+	}
+#endif
+
+	FreeFloatVec( ogcp1 );
+	FreeFloatVec( ogcp2 );
+	FreeFloatVec( fgcp1 );
+	FreeFloatVec( fgcp2 );
+	FreeFloatMtx( cpmx1 );
+	FreeFloatMtx( cpmx2 );
+	free( (void *)gapinfo );
+
+	FreeCharMtx( mseq1 );
+	FreeCharMtx( mseq2 );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	for( i=0; i<icyc; i++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+
+	return( wm );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/MSalign11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/MSalign11.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/MSalign11.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/MSalign11.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,661 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+
+static void extendmseq( char **mseq1, char **mseq2, char **seq1, char **seq2, int i, int j, int prevhiti, int prevhitj )
+{
+	char gap[] = "-";
+	int l;
+
+	fprintf( stderr, "i=%d, prevhiti=%d\n", i, prevhiti );
+	fprintf( stderr, "j=%d, prevhitj=%d\n", j, prevhitj );
+	l = prevhiti - i - 1;
+	fprintf( stderr, "l=%d\n", l );
+	while( l>0 ) 
+	{
+		*--mseq1[0] = seq1[0][i+l--];
+		*--mseq2[0] = *gap;
+	}
+	l= prevhitj - j - 1;
+	fprintf( stderr, "l=%d\n", l );
+	while( l>0 )
+	{
+		*--mseq1[0] = *gap;
+		*--mseq2[0] = seq2[0][j+l--];
+	}
+	if( i < 0 || j < 0 ) return;
+	*--mseq1[0] = seq1[0][i];
+	*--mseq2[0] = seq2[0][j];
+	fprintf( stderr, "added %c to mseq1, mseq1 = %s \n", seq1[0][i], mseq1[0] );
+	fprintf( stderr, "added %c to mseq2, mseq2 = %s \n", seq2[0][j], mseq2[0] );
+}
+
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 )
+{
+	char tmpc = s1[0][i1];
+	char *seq2 = s2[0];
+
+	while( lgth2-- )
+		*match++ = amino_dis[(int)tmpc][(int)*seq2++];
+}
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, limk;
+	char gap[] = "-";
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+	iin = lgth1; jin = lgth2;
+	limk = lgth1+lgth2 + 1;
+	for( k=0; k<limk; 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 ) 
+		{
+			*--mseq1[0] = seq1[0][ifi+l];
+			*--mseq2[0] = *gap;
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--mseq1[0] = *gap;
+			*--mseq2[0] = seq2[0][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--mseq1[0] = seq1[0][ifi];
+		*--mseq2[0] = seq2[0][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+void backdp( float **WMMTX, float wmmax, float *maxinw, float *maxinh, int lgth1, int lgth2, int alloclen, float *w1, float *w2, float *initverticalw, float *m, int *mp, int iin, int jin, char **seq1, char **seq2, char **mseq1, char **mseq2 )
+{
+	register int i, j;
+	int prevhiti, prevhitj;
+//	int lasti, lastj; 
+	float g;
+	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+	float *currentw, *previousw, *wtmp;
+	float mi;
+	int mpi;
+	int *mpjpt;
+	float *mjpt, *prept, *curpt;
+	float wm = 0.0;
+	float forwwm;
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, seq2, seq1, lgth2-1, lgth1 );
+	match_calc( currentw, seq1, seq2, lgth1-1, lgth2 );
+
+
+	prevhiti = iin;
+	prevhitj = jin;
+	fprintf( stderr, "prevhiti = %d, lgth1 = %d\n", prevhiti, lgth1 );
+	fprintf( stderr, "prevhitj = %d, lgth2 = %d\n", prevhitj, lgth2 );
+	extendmseq( mseq1, mseq2, seq1, seq2, prevhiti, prevhitj, lgth1, lgth2 );
+
+	for( i=0; i<lgth1-1; i++ )
+	{
+		initverticalw[i] += fpenalty;
+		WMMTX[i][lgth2-1] += fpenalty;
+	}
+	for( j=0; j<lgth2-1; j++ )
+	{
+		currentw[j] += fpenalty;
+		WMMTX[lgth1-1][j] += fpenalty;
+	}
+
+
+#if 0
+	fprintf( stderr, "initverticalw = \n" );
+	for( i=0; i<lgth1; i++ )
+		fprintf( stderr, "% 8.2f", initverticalw[i] );
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "currentw = \n" );
+	for( i=0; i<lgth2; i++ )
+		fprintf( stderr, "% 8.2f", currentw[i] );
+	fprintf( stderr, "\n" );
+#endif
+
+	for( j=lgth2-1; j>0; --j ) 
+	{
+		m[j-1] = currentw[j]; 
+		mp[j] = 0; // iranai
+	}
+
+	for( j=0; j<lgth2; j++ ) m[j] = 0.0;
+	//m[lgth2-1] ga, irunoka iranainoka irahai.
+
+	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 );
+
+#if 0
+		fprintf( stderr, "i=%d, currentw = \n", i );
+		for( j=0; j<lgth2; j++ ) fprintf( stderr, "% 8.2f", currentw[j] );
+		fprintf( stderr, "\n" );
+#endif
+
+		currentw[lgth2-1] = initverticalw[i];
+
+		mi = previousw[lgth2-1]; 
+		mpi = lgth2-1; //iranai
+
+
+		mjpt = m + lgth2 - 2;
+		prept = previousw + lgth2 - 1;
+		curpt = currentw + lgth2 - 2;
+		mpjpt = mp + lgth2 - 2;
+
+		for( j=lgth2-2; j>-1; j-- )
+		{
+
+//			fprintf( stderr, "i,j=%d,%d %c-%c ", i, j, seq1[0][i], seq2[0][j] );
+			wm = *prept;
+			g = mi + fpenalty;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+			}
+			g = *prept;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j+1; //iranai
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fpenalty;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+			}
+			g = *prept;
+			if( g >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1; //iranai
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+
+#if 0
+			fprintf( stderr, "*curpt = %5.0f \n", *curpt );
+#endif
+
+//			forwwm = wm + MIN( maxinw[i], maxinh[j] );
+			forwwm = wm + MIN( maxinw[i], maxinh[j] );
+			WMMTX[i][j] = forwwm;
+			if( forwwm == wmmax && i<prevhiti && j<prevhitj ) 
+			{
+				fprintf( stderr, "hit!\n" );
+				extendmseq( mseq1, mseq2, seq1, seq2, i, j, prevhiti, prevhitj );
+				if( forwwm == wmmax )
+				{
+					*--mseq1[0] = 'u';
+					*--mseq2[0] = 'u';
+				}
+				prevhiti = i;
+				prevhitj = j;
+			}
+			*curpt += wm;
+
+			mjpt--;
+			prept--;
+			mpjpt--;
+			curpt--;
+		}
+	}
+	extendmseq( mseq1, mseq2, seq1, seq2, -1, -1, prevhiti, prevhitj );
+}
+
+
+float MSalign11( char **seq1, char **seq2, int alloclen )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;
+	int iin = 0, jin = 0;  // by Mathog, a guess
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+	float *maxinw = NULL, *maxinwpt = NULL; // by D.Mathog, guess
+	float *maxinh = NULL; // by D.Mathog, guess
+#if 1
+	float wmmax;
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **WMMTX;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+			FreeFloatVec( maxinw );
+			FreeFloatVec( maxinh );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+		maxinw = AllocateFloatVec( ll1+2 );
+
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+		maxinh = AllocateFloatVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+			FreeFloatMtx( WMMTX );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+		WMMTX = AllocateFloatMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, seq2, seq1, 0, lgth1 );
+
+
+	match_calc( currentw, seq1, seq2, 0, lgth2 );
+
+	WMMTX[0][0] = initverticalw[0];
+
+	maxinh[0] = initverticalw[0];
+	for( i=1; i<lgth1+1; i++ )
+	{
+		initverticalw[i] += fpenalty;
+		WMMTX[i][0] = initverticalw[i];
+		if( maxinh[0] < initverticalw[i] ) maxinh[0] = initverticalw[i];
+	}
+	maxinw[0] = currentw[0];
+	for( j=1; j<lgth2+1; j++ )
+	{
+		currentw[j] += fpenalty;
+		WMMTX[0][j] = currentw[j];
+		if( maxinw[0] < currentw[j] ) maxinw[0] = currentw[j];
+	}
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-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, seq1, seq2, i, lgth2 );
+
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0]; mpi = 0;
+
+		maxinwpt = maxinw + i;
+		*maxinwpt = currentw[0];
+
+		fprintf( stderr, "currentw[0]  = %f, *maxinwpt = %f\n", currentw[0], maxinw[i] );
+
+		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;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			g = *prept;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fpenalty;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			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;
+
+			WMMTX[i][j] = *curpt;
+
+
+			if( j<lgth2 && *maxinwpt < *curpt ) *maxinwpt = *curpt;
+			if( j<lgth2 && maxinh[j] < *curpt ) maxinh[j] = *curpt;
+//			fprintf( stderr, "maxintwpt = %f\n", *maxinwpt );
+
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+			curpt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+	wmmax = -999.9;
+	for( i=0; i<lgth1; i++ )
+	{
+		g = lastverticalw[i];
+		if( g > wmmax ) 
+		{
+			wmmax = g;
+			iin = i;
+			jin = lgth2-1;
+		}
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		g = currentw[j];
+		if( g > wmmax )
+		{
+			wmmax = g;
+			iin = lgth1-1;
+			jin = j;
+		}
+	}
+
+	for( i=0; i<lgth1; i++ )
+		fprintf( stderr, "maxinw[%d] = %f\n", i, maxinw[i] );
+	for( j=0; j<lgth2; j++ )
+		fprintf( stderr, "maxinh[%d] = %f\n", j, maxinh[j] );
+
+	fprintf( stderr, "wmmax = %f (%d,%d)\n", wmmax, iin, jin );
+	if( iin == lgth1 - 1 && jin == lgth2 - 1 )
+		;
+	else
+		wmmax += fpenalty;
+
+	fprintf( stderr, "wmmax = %f\n", wmmax );
+
+#if 0
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<lgth2; j++ )
+		{
+			fprintf( stderr, "% 10.2f ", WMMTX[i][j] );
+		}
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+
+	backdp( WMMTX, wmmax, maxinw, maxinh, lgth1, lgth2, alloclen, w1, w2, initverticalw, m, mp, iin, jin, seq1, seq2, mseq1, mseq2 );
+
+	fprintf( stderr, "\n" );
+#if 1
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">MSres\n%s\n", mseq1[0] );
+	fprintf( stderr, ">MSres\n%s\n", mseq2[0] );
+#endif
+
+#if 0
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<lgth2; j++ )
+		{
+			fprintf( stderr, "% 10.2f ", WMMTX[i][j] );
+		}
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+
+	Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp );
+
+
+	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" );
+	}
+
+
+	strcpy( seq1[0], mseq1[0] );
+	strcpy( seq2[0], mseq2[0] );
+#if 1
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+#endif
+
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/MSalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/MSalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/MSalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/MSalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1530 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MEMSAVE 1
+
+#define DEBUG 0
+#define USE_PENALTY_EX  0
+#define STOREWM 0
+
+#define DPTANNI 100
+
+
+static int reccycle = 0;
+
+
+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;
+	float *matchpt;
+	float **cpmxpdpt;
+	int **cpmxpdnpt;
+	int cpkd;
+
+	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 /* ¤³¤ì¤ò»È¤¦¤È¤­¤Ï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++;
+		} 
+	}
+	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];
+	} 
+#else
+	matchpt = match;
+	cpmxpdnpt = cpmxpdn;
+	cpmxpdpt = cpmxpd;
+	while( lgth2-- )
+	{
+		*matchpt = 0.0;
+		for( k=0; (cpkd=(*cpmxpdnpt)[k])>-1; k++ )
+			*matchpt += scarr[cpkd] * (*cpmxpdpt)[k];
+		matchpt++;
+		cpmxpdnpt++;
+		cpmxpdpt++;
+	}
+#endif
+}
+
+static float Atracking( 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        int **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 *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = ien-ist+1;
+	lgth2 = jen-jst+1;
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+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 );
+    }
+
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i]+ist, gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j]+jst, gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+//	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;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	float mi, *m;
+	int **ijp;
+	int mpi, *mp;
+	float *w1, *w2;
+	float *initverticalw;    /* kufuu sureba iranai */
+	float *lastverticalw;    /* kufuu sureba iranai */
+	int **intwork;
+	float **floatwork;
+	int **intmtx;
+	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)(lgth1) ) + 100;
+	ll2 = ( (int)(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 ); 
+
+
+	intmtx = AllocateIntMtx( ll1+1, ll2+1 );
+
+	ijp = intmtx;
+
+	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] += ( ogcp1[0] + fgcp1[i-1] );
+	}
+	for( j=1; j<lgth2+1; j++ )
+	{
+		currentw[j] += ( ogcp2[0] + fgcp2[j-1] );
+	}
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1] + 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] + 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 + fgcp2[j-1];
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			g = *prept + ogcp2[j];
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1[i-1];
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			g = *prept + 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, mseq1, mseq2, 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 );
+
+	FreeIntMtx( intmtx );
+
+//	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;
+	int alnlen;
+	float value = 0.0;
+	register int i, j;
+	char **aseq1, **aseq2;
+	int ll1, ll2, l, len;
+	int lasti, lastj, imid;
+	int jmid = 0; // by D.Mathog, a guess
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+	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;
+	int lgth1, lgth2;
+	float maxwm;
+	int *jumpforwi;
+	int *jumpforwj;
+	int *jumpbacki;
+	int *jumpbackj;
+	int *jumpdummi; //muda
+	int *jumpdummj = NULL; // by D.Mathog, a guess
+	int jumpi, jumpj = 0; // by D.Mathog, a guess
+	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( lgth1 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth1 = %d\n", lgth1 );
+//	if( lgth2 < 5 )
+//		fprintf( stderr, "\nWARNING: lgth2 = %d\n", lgth2 );
+//
+
+#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 );
+	}
+
+#if MEMSAVE
+	aseq1 = AllocateCharMtx( icyc, 0 );
+	aseq2 = AllocateCharMtx( jcyc, 0 );
+	for( i=0; i<icyc; i++ ) aseq1[i] = mseq1[i];
+	for( i=0; i<jcyc; i++ ) aseq2[i] = mseq2[i];
+#else
+	aseq1 = AllocateCharMtx( icyc, lgth1+lgth2+100 );
+	aseq2 = AllocateCharMtx( jcyc, lgth1+lgth2+100 );
+#endif
+
+//  if( lgth1 < DPTANNI && lgth2 < DPTANNI ) // & dato lgth ==1 no kanousei ga arunode yokunai 
+//    if( lgth1 < DPTANNI ) // kore mo lgth2 ga mijikasugiru kanousei ari
+    if( lgth1 < DPTANNI || lgth2 < DPTANNI ) // zettai ni anzen ka?
+	{
+//		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 );	
+
+
+#if MEMSAVE
+		free( aseq1 );
+		free( aseq2 );
+#else
+		for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
+		for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
+
+		FreeCharMtx( aseq1 );
+		FreeCharMtx( aseq2 );
+#endif
+
+//		fprintf( stderr, "value = %f\n", value );
+
+		return( value );
+	}
+//	fprintf( stderr, "Trying to divide the mtx\n" );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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] += ( ogcp1[0] + fgcp1[i-1] );
+	}
+	for( j=1; j<lgth2+1; j++ )
+	{
+		currentw[j] += ( ogcp2[0] + fgcp2[j-1] );
+	}
+
+#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] + 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] = ogcp1[i];
+#if STOREM
+		WMMTX2[i][0] = m[0];
+#endif
+		if( i == imid ) midm[0] = m[0];
+
+		mi = previousw[0] + 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 + fgcp2[j-1];
+//			g = mi + fpenalty;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = -( j - mpi );
+			}
+			g = *prept + ogcp2[j];
+//			g = *prept;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1[i-1];
+//			g = *mjpt + fpenalty;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijppt = +( i - *mpjpt );
+			}
+
+
+			g = *prept + 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] += ( fgcp1[lgth1-1] + ogcp1[i+1] );
+//		initverticalw[i] += fpenalty;
+	}
+	for( j=0; j<lgth2-1; j++ )
+	{
+		currentw[j] += ( fgcp2[lgth2-1] + ogcp2[j+1] );
+//		currentw[j] += fpenalty;
+	}
+
+#if STOREWM
+	for( i=0; i<lgth1-1; i++ )
+	{
+		WMMTX[i][lgth2-1] += ( 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] += ( 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] + 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] = fgcp1[i];
+//		WMMTX2[i][lgth2] += m[lgth2];
+//		fprintf( stderr, "m[] = %f\n", m[lgth2] );
+
+		mi = previousw[lgth2-1] + 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 + ogcp2[j+1];
+//			g = mi + fpenalty;
+			if( g > wm )
+			{
+				wm = g;
+				ijpj = mpi;
+				ijpi = i+1;
+			}
+
+			g = *prept + 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 + 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 + 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 + 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( jmid > 0 && midn[jmid-1] > wm ) //060413
+			{
+				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;
+			}
+
+#if 0
+			else if( jmid == lgth2 ) 
+			{
+				fprintf( stderr, "CHUI1!\n" );
+				jumpi=0; jumpj=0;
+				imid=jumpforwi[0]; jmid=lgth2-1;
+			}
+#else // 060414
+			else if( jmid >= lgth2 ) 
+			{
+//				fprintf( stderr, "CHUI1!\n" );
+				jumpi=imid-1; jmid=lgth2;
+				jumpj = lgth2-1;
+			}
+#endif
+			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" );
+
+#if 0
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
+#endif
+	value = MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist, ist+jumpi, jst, jst+jumpj, alloclen, aseq1, aseq2, depth, gapinfo );	
+#if 0
+		fprintf( stderr, "aseq1[0] = %s\n", aseq1[0] );
+		fprintf( stderr, "aseq2[0] = %s\n", aseq2[0] );
+#endif
+#if MEMSAVE
+#else
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], aseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcpy( mseq2[i], aseq2[i] );
+#endif
+
+//	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 +=  ( 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 += ( 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" );
+
+#if MEMSAVE
+	alnlen = strlen( aseq1[0] );
+	for( i=0; i<icyc; i++ ) aseq1[i] += alnlen;
+	for( i=0; i<jcyc; i++ ) aseq2[i] += alnlen;
+#endif
+
+#if 0
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
+#endif
+	value += MSalignmm_rec( icyc, jcyc, eff1, eff2, seq1, seq2, cpmx1, cpmx2, ist+imid, ien, jst+jmid, jen, alloclen, aseq1, aseq2, depth, gapinfo );	
+#if 0
+		fprintf( stderr, "aseq1[0] = %s\n", aseq1[0] );
+		fprintf( stderr, "aseq2[0] = %s\n", aseq2[0] );
+#endif
+
+
+
+#if DEBUG
+	if( value - maxwm > 1 || maxwm - value > 1 )
+	{
+		fprintf( stderr, "WARNING value  = %f, but maxwm = %f\n", value, maxwm );
+		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
+
+#if MEMSAVE
+#else
+	for( i=0; i<icyc; i++ ) strcat( mseq1[i], aseq1[i] );
+	for( i=0; i<jcyc; i++ ) strcat( mseq2[i], aseq2[i] );
+#endif
+
+//	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 );
+#if MEMSAVE
+	free( aseq1 );
+	free( aseq2 );
+#else
+	FreeCharMtx( aseq1 );
+	FreeCharMtx( aseq2 );
+#endif
+	
+	return( value );
+}
+
+
+
+float MSalignmm( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* 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 = 0.0;   /* int ?????? */
+	char **mseq1;
+	char **mseq2;
+	float *ogcp1;
+	float *ogcp2;
+	float *fgcp1;
+	float *fgcp2;
+	float **cpmx1;
+	float **cpmx2;
+	float **gapinfo;
+	float fpenalty = (float)penalty;
+	int nglen1, nglen2;
+
+#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
+
+	nglen1 = seqlen( seq1[0] );
+	nglen2 = seqlen( seq2[0] );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	ll1 = ( (int)(lgth1) ) + 100;
+	ll2 = ( (int)(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++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "bug! hairetsu ga kowareta!\n" );
+			exit( 1 );
+		}
+	}
+
+	MScpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	MScpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+
+#if 1
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
+		new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
+		new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap2 );
+		new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp1[%d] = %f\n", i, fgcp1[i] );
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
+//		fprintf( stderr, "fgcp2[%d] = %f\n", i, fgcp2[i] );
+	}
+#else
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * fpenalty;
+		fgcp1[i] = 0.5 * fpenalty;
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * fpenalty;
+		fgcp2[i] = 0.5 * fpenalty;
+	}
+#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 );
+#if DEBUG
+		fprintf( stderr, " seq1[0] = %s\n", seq1[0] );
+		fprintf( stderr, " seq2[0] = %s\n", seq2[0] );
+		fprintf( stderr, "mseq1[0] = %s\n", mseq1[0] );
+		fprintf( stderr, "mseq2[0] = %s\n", mseq2[0] );
+#endif
+
+//	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] );
+
+	if( seqlen( seq1[0] ) != nglen1 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen1) seqlen(seq1[0])=%d but nglen1=%d\n", seqlen( seq1[0] ), nglen1 );
+		fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+		exit( 1 );
+	}
+	if( seqlen( seq2[0] ) != nglen2 )
+	{
+		fprintf( stderr, "bug! hairetsu ga kowareta! (nglen2) seqlen(seq2[0])=%d but nglen2=%d\n", seqlen( seq2[0] ), nglen2 );
+		exit( 1 );
+	}
+
+	FreeFloatVec( ogcp1 );
+	FreeFloatVec( ogcp2 );
+	FreeFloatVec( fgcp1 );
+	FreeFloatVec( fgcp2 );
+	FreeFloatMtx( cpmx1 );
+	FreeFloatMtx( cpmx2 );
+	free( (void *)gapinfo );
+
+	FreeCharMtx( mseq1 );
+	FreeCharMtx( mseq2 );
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	for( i=0; i<icyc; i++ ) 
+	{
+		if( strlen( seq1[i] ) != lgth1 )
+		{
+			fprintf( stderr, "i = %d / %d\n", i, icyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		if( strlen( seq2[j] ) != lgth2 )
+		{
+			fprintf( stderr, "j = %d / %d\n", j, jcyc );
+			fprintf( stderr, "hairetsu ga kowareta (end of MSalignmm) !\n" );
+			exit( 1 );
+		}
+	}
+
+	return( wm );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Makefile?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Makefile (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Makefile Thu Feb 19 06:37:59 2009
@@ -0,0 +1,13 @@
+LEVEL = ../../../
+
+Source = Calignm1.c constants.c defs.c Falign.c fft.c fftFunctions.c Galign11.c\
+         genalign11.c genGalign11.c Halignmm.c io.c Lalign11.c Lalignmm.c\
+         mltaln9.c MSalign11.c MSalignmm.c mtxutl.c pairlocalalign.c\
+         partQalignmm.c partSalignmm.c Qalignmm.c Ralignmm.c rna.c SAalignmm.c\
+         Salignmm.c suboptalign11.c tddis.c
+PROG = pairlocalalign
+CPPFLAGS = -DLLVM
+RUN_OPTIONS = -b 62 -g 0.100 -f 2.00 -h 0.100 -L
+STDIN_FILENAME = pyruvate_decarboxylase.fasta
+LDFLAGS = -lm
+include $(LEVEL)/MultiSource/Makefile.multisrc

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Qalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Qalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Qalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Qalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,2179 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+
+
+static float **impmtx = NULL;
+static int impalloclen = 0;
+#if 1 // tditeration to naiveQscore_imp de tsukawareru.
+float imp_match_out_scQ( int i1, int j1 )
+{
+//	fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
+//	fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+}
+#endif
+
+static void imp_match_out_veadQ_gapmap( float *imp, int i1, int lgth2, int *gapmap2 )
+{
+#if FASTMATCHCALC
+	float *pt = impmtx[i1];
+	int *gapmappt = gapmap2;
+	while( lgth2-- )
+		*imp++ += pt[*gapmappt++];
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[gapmap2[j]];
+#endif
+}
+
+
+static void imp_match_out_vead_tateQ_gapmap( float *imp, int j1, int lgth1, int *gapmap1 )
+{
+#if FASTMATCHCALC
+	int *gapmappt = gapmap1;
+	while( lgth1-- )
+		*imp++ += impmtx[*gapmappt++][j1];
+#else
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[gapmap1[i]][j1];
+#endif
+}
+
+
+static void imp_match_out_veadQ( float *imp, int i1, int lgth2 )
+{
+#if FASTMATCHCALC 
+	float *pt = impmtx[i1];
+	while( lgth2-- )
+		*imp++ += *pt++;
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[j];
+#endif
+}
+static void imp_match_out_vead_tateQ( float *imp, int j1, int lgth1 )
+{
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[i][j1];
+}
+
+void imp_rnaQ( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, int *gapmap1, int *gapmap2, RNApair *additionalpair )
+{
+	foldrna( nseq1, nseq2, seq1, seq2, eff1, eff2, grouprna1, grouprna2, impmtx, gapmap1, gapmap2, additionalpair );
+}
+
+#if 1 // tbfast.c kara yobareru.
+void imp_match_init_strictQ( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	float effij;
+	double effijx;
+	char *pt, *pt1, *pt2;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+	LocalHom *tmpptr;
+
+	if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx =  fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = (float)( eff1[i] * eff2[j] * effijx );
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = pt - seq1[i] - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = pt - seq1[i] - 0;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = pt - seq1[i] - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = pt - seq2[j] - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = pt - seq2[j] - 0;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = pt - seq2[j] - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+#if 1
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+//						fprintf( stderr, "%d (%c) - %d (%c)  - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+#else
+				while( k1 <= end1 && k2 <= end2 )
+				{
+					fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
+					if( !nocount1[k1] && !nocount2[k2] )
+					{
+						impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j]  * fastathreshold;
+						fprintf( stderr, "marked\n" );
+					}
+					else
+						fprintf( stderr, "no count\n" );
+					k1++; k2++;
+				}
+#endif
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+#if 0
+	if( clus1 == 1 && clus2 == 6 )
+	{
+		fprintf( stderr, "\n" );
+		fprintf( stderr, "seq1[0] =  %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] =  %s\n", seq2[0] );
+		fprintf( stderr, "impmtx = \n" );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", (double)k2 );
+		fprintf( stderr, "\n" );
+		for( k1=0; k1<lgth1; k1++ )
+		{
+			fprintf( stderr, "%d ", k1 );
+			for( k2=0; k2<3; k2++ )
+				fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+			fprintf( stderr, "\n" );
+		}
+		exit( 1 );
+	}
+#endif
+}
+#endif
+
+
+static void clearvec( float *match, int lgth )
+{
+	while( lgth-- ) *match++ = 0.0;
+}
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+				scarr[l] += n_dis_consweight_multi[j][l] * cpmx1[j][i1];
+//			scarr[l] *= consweight_multi;
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis_consweight_multi[k][l] * cpmx1[k][i1];
+//		scarr[l] *= consweight_multi;
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom_gapmap( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc,
+						int *gapmap1, int *gapmap2 )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	char gap[] = "-";
+	float wm;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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][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][jfi+l];
+			k++;
+		}
+		if( iin != lgth1 && jin != lgth2 ) // ??
+		{
+			*impwmpt += imp_match_out_scQ( gapmap1[iin], gapmap2[jin] );
+//			fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+}
+
+#if 0
+static void Atracking_localhom_gapmap_bk( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc,
+						int *gapmap1, int *gapmap2 )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_scQ( gapmap1[iin], gapmap2[jin] );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = '-';
+		*--gaptable2 = '-';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	fprintf( stderr, "mseq1[0] = %s\n", mseq1[0] );
+	fprintf( stderr, "mseq2[0] = %s\n", mseq2[0] );
+
+
+	free( gt1bk );
+	free( gt2bk );
+}
+
+#endif
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_scQ( iin, jin );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+}
+
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+	return( 0.0 );
+}
+
+float Q__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+	fprintf( stderr, "fpenalty_ex = %f\n", fpenalty_ex );
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *digf1;
+	static float *digf2;
+	static float *diaf1;
+	static float *diaf2;
+	static float *gapz1;
+	static float *gapz2;
+	static float *gapf1;
+	static float *gapf2;
+	static float *ogcp1g;
+	static float *ogcp2g;
+	static float *fgcp1g;
+	static float *fgcp2g;
+	static float *og_h_dg_n1_p;
+	static float *og_h_dg_n2_p;
+	static float *fg_h_dg_n1_p;
+	static float *fg_h_dg_n2_p;
+	static float *og_t_fg_h_dg_n1_p;
+	static float *og_t_fg_h_dg_n2_p;
+	static float *fg_t_og_h_dg_n1_p;
+	static float *fg_t_og_h_dg_n2_p;
+	static float *gapz_n1;
+	static float *gapz_n2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float tmppenal;
+	float *fg_t_og_h_dg_n2_p_pt;
+	float *og_t_fg_h_dg_n2_p_pt;
+	float *og_h_dg_n2_p_pt;
+	float *fg_h_dg_n2_p_pt;
+	float *gapz_n2_pt0;
+	float *gapz_n2_pt1;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fg_t_og_h_dg_n1_p_va;
+	float og_t_fg_h_dg_n1_p_va;
+	float og_h_dg_n1_p_va;
+	float fg_h_dg_n1_p_va;
+	float gapz_n1_va0;
+	float gapz_n1_va1;
+	float fgcp1va;
+	float ogcp1va;
+	float kyokaipenal;
+#if 1
+	float fpenalty = (float)penalty;
+#else
+	float fpenalty;
+	if( RNAscoremtx != 'r' ) fpenalty = (float)penalty;
+	else fpenalty = (float)penalty * 10;
+#endif
+
+#if 0
+	fprintf( stderr, "####  seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "####  seq2[0] = %s\n", seq2[0] );
+#endif
+
+
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( digf1 );
+			FreeFloatVec( digf2 );
+			FreeFloatVec( diaf1 );
+			FreeFloatVec( diaf2 );
+			FreeFloatVec( gapz1 );
+			FreeFloatVec( gapz2 );
+			FreeFloatVec( gapf1 );
+			FreeFloatVec( gapf2 );
+			FreeFloatVec( ogcp1g );
+			FreeFloatVec( ogcp2g );
+			FreeFloatVec( fgcp1g );
+			FreeFloatVec( fgcp2g );
+			FreeFloatVec( og_h_dg_n1_p );
+			FreeFloatVec( og_h_dg_n2_p );
+			FreeFloatVec( fg_h_dg_n1_p );
+			FreeFloatVec( fg_h_dg_n2_p );
+			FreeFloatVec( og_t_fg_h_dg_n1_p );
+			FreeFloatVec( og_t_fg_h_dg_n2_p );
+			FreeFloatVec( fg_t_og_h_dg_n1_p );
+			FreeFloatVec( fg_t_og_h_dg_n2_p );
+			FreeFloatVec( gapz_n1 );
+			FreeFloatVec( gapz_n2 );
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		digf1 = AllocateFloatVec( ll1+2 );
+		digf2 = AllocateFloatVec( ll2+2 );
+		diaf1 = AllocateFloatVec( ll1+2 );
+		diaf2 = AllocateFloatVec( ll2+2 );
+		gapz1 = AllocateFloatVec( ll1+2 );
+		gapz2 = AllocateFloatVec( ll2+2 );
+		gapf1 = AllocateFloatVec( ll1+2 );
+		gapf2 = AllocateFloatVec( ll2+2 );
+		ogcp1g = AllocateFloatVec( ll1+2 );
+		ogcp2g = AllocateFloatVec( ll2+2 );
+		fgcp1g = AllocateFloatVec( ll1+2 );
+		fgcp2g = AllocateFloatVec( ll2+2 );
+		og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		og_t_fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_t_fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_t_og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_t_og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		gapz_n1 = AllocateFloatVec( ll1+2 );
+		gapz_n2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+#if 0
+	{
+		float t = 0.0;
+		for( i=0; i<icyc; i++ )
+			t += eff1[i];
+	fprintf( stderr, "## totaleff = %f\n", t );
+	}
+#endif
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure_part( gapz1, icyc, seq1, eff1, lgth1, sgap1 );
+		getgapfreq_zure_part( gapz2, jcyc, seq2, eff2, lgth2, sgap1 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
+		getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
+		getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
+		getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
+		getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	lastj = lgth2+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n2_p[i] = ( 1.0-ogcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		fg_h_dg_n2_p[i] = ( 1.0-fgcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n2_p[i] = (1.0-ogcp2g[i]+fgcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n2_p[i] = (1.0-fgcp2g[i]+ogcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		gapz_n2[i] = (1.0-gapz2[i]);
+	}
+	lastj = lgth1+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n1_p[i] = ( 1.0-ogcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		fg_h_dg_n1_p[i] = ( 1.0-fgcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n1_p[i] = (1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n1_p[i] = (1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		gapz_n1[i] = (1.0-gapz1[i]);
+	}
+#endif
+
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	if( RNAscoremtx != 'r' )
+		match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	else
+		clearvec( initverticalw, lgth1 );
+	if( localhom )
+		imp_match_out_vead_tateQ( initverticalw, 0, lgth1 ); // 060306
+
+	if( RNAscoremtx != 'r' )
+		match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	else
+		clearvec( currentw, lgth2 );
+	if( localhom )
+		imp_match_out_veadQ( currentw, 0, lgth2 ); // 060306
+
+
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+
+
+	kyokaipenal = 0.0;
+	if( outgap == 1 )
+	{
+		g = 0.0;
+
+		g += ogcp1g[0] * og_h_dg_n2_p[0];
+//		g += ogcp1g[0] * ( 1.0-ogcp2g[0]-digf2[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal1=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += ogcp2g[0] * og_h_dg_n1_p[0];
+//		g += ogcp2g[0] * ( 1.0-ogcp1g[0]-digf1[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal2=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += fgcp1g[0] * fg_h_dg_n2_p[0];
+//		g += fgcp1g[0] * ( 1.0-fgcp2g[0]-digf2[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		g += fgcp2g[0] * fg_h_dg_n1_p[0];
+//		g += fgcp2g[0] * ( 1.0-fgcp1g[0]-digf1[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		kyokaipenal = g;
+		initverticalw[0] += g;
+		currentw[0] += g;
+
+		for( i=1; i<lgth1+1; i++ )
+		{
+			tmppenal = gapz_n2[0]*og_t_fg_h_dg_n1_p[0];
+//			tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+fgcp1g[0]-digf1[0]) ) * 0.5 * fpenalty; // mada
+			initverticalw[i] += tmppenal;
+
+			tmppenal = gapz_n2[1]*fg_t_og_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			initverticalw[i] += tmppenal;
+
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			tmppenal = gapz_n1[0]*og_t_fg_h_dg_n2_p[0];
+//			tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+fgcp2g[0]-digf2[0]) ) * 0.5 * fpenalty; // mada
+			currentw[j] += tmppenal;
+
+			tmppenal = gapz_n1[1]*fg_t_og_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			currentw[j] += tmppenal;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	m[0] = 0.0; // iranai
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		mp[j] = 0;
+		m[j] = currentw[j-1] + 10000 * fpenalty; //iinoka?
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		if( RNAscoremtx != 'r' )
+			match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+		else
+			clearvec( currentw, lgth2 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_veadQ( currentw, i, lgth2 );
+#else
+			imp_match_out_veadQ( currentw, i, lgth2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mpi = 0;
+		mi = previousw[0] + 10000 * fpenalty;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fg_t_og_h_dg_n2_p_pt = fg_t_og_h_dg_n2_p + 1;
+		og_t_fg_h_dg_n2_p_pt = og_t_fg_h_dg_n2_p + 1;
+		og_h_dg_n2_p_pt = og_h_dg_n2_p + 1;
+		fg_h_dg_n2_p_pt = fg_h_dg_n2_p + 1;
+		gapz_n2_pt0 = gapz_n2 + 1;
+		gapz_n2_pt1 = gapz_n2 + 2;
+		fgcp2pt = fgcp2g + 1;
+		ogcp2pt = ogcp2g + 1;
+
+		fg_t_og_h_dg_n1_p_va = fg_t_og_h_dg_n1_p[i];
+		og_t_fg_h_dg_n1_p_va = og_t_fg_h_dg_n1_p[i];
+		og_h_dg_n1_p_va = og_h_dg_n1_p[i];
+		fg_h_dg_n1_p_va = fg_h_dg_n1_p[i];
+		gapz_n1_va0 = gapz_n1[i];
+		gapz_n1_va1 = gapz_n1[i+1];
+		fgcp1va = fgcp1g[i];
+		ogcp1va = ogcp1g[i];
+
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+
+			g = ogcp1va * *og_h_dg_n2_p_pt;
+//			g = ogcp1g[i] * og_h_dg_n2_p[j];
+//			g = ogcp1g[i] * ( 1.0-ogcp2g[j]-digf2[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = *ogcp2pt * og_h_dg_n1_p_va;
+//			g = ogcp2g[j] * og_h_dg_n1_p[i];
+//			g = ogcp2g[j] * ( 1.0-ogcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = fgcp1va * *fg_h_dg_n2_p_pt;
+//			g = fgcp1g[i] * fg_h_dg_n2_p[j];
+//			g = fgcp1g[i] * ( 1.0-fgcp2g[j]-digf2[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal3=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = *fgcp2pt * fg_h_dg_n1_p_va;
+//			g = fgcp2g[j] * fg_h_dg_n1_p[i];
+//			g = fgcp2g[j] * ( 1.0-fgcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal4=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			tmppenal = gapz_n1_va1 * *fg_t_og_h_dg_n2_p_pt;
+//			tmppenal = gapz_n1[i+1] * fg_t_og_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[i+1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			if( (g=mi+tmppenal) > wm )
+			{
+//				fprintf( stderr, "jump i start=%f (j=%d, fgcp2g[j]=%f, digf2[j]=%f, diaf2[j]=%f), %c-%c\n", g-mi, j, fgcp2g[j], digf2[j], diaf2[j], seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			tmppenal = gapz_n1_va0 * *og_t_fg_h_dg_n2_p_pt;
+//			tmppenal = gapz_n1[i] * og_t_fg_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[j]+fgcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			if( (g=*prept+tmppenal) >= mi )
+			{
+//				fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				mi = g;
+				mpi = j-1;
+			}
+
+#if USE_PENALTY_EX
+            mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			tmppenal = *gapz_n2_pt1 * fg_t_og_h_dg_n1_p_va;
+//			tmppenal = gapz_n2[j+1] * fg_t_og_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[j+1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			if( (g=*mjpt+tmppenal) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			tmppenal = *gapz_n2_pt0 * og_t_fg_h_dg_n1_p_va;
+//			tmppenal = gapz_n2[j] * og_t_fg_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			if( (g=*prept+tmppenal) >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+
+#if USE_PENALTY_EX
+            m[j] += fpenalty_ex;
+#endif
+
+
+
+
+
+			*curpt++ += wm;
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+			fg_t_og_h_dg_n2_p_pt++;
+			og_t_fg_h_dg_n2_p_pt++;
+			og_h_dg_n2_p_pt++;
+			fg_h_dg_n2_p_pt++;
+			gapz_n2_pt0++;
+			gapz_n2_pt1++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+
+	return( wm );
+}
+
+float Q__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2, int *gapmap1, int *gapmap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+	fprintf( stderr, "fpenalty_ex = %f\n", fpenalty_ex );
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *digf1;
+	static float *digf2;
+	static float *diaf1;
+	static float *diaf2;
+	static float *gapz1;
+	static float *gapz2;
+	static float *gapf1;
+	static float *gapf2;
+	static float *ogcp1g;
+	static float *ogcp2g;
+	static float *fgcp1g;
+	static float *fgcp2g;
+	static float *og_h_dg_n1_p;
+	static float *og_h_dg_n2_p;
+	static float *fg_h_dg_n1_p;
+	static float *fg_h_dg_n2_p;
+	static float *og_t_fg_h_dg_n1_p;
+	static float *og_t_fg_h_dg_n2_p;
+	static float *fg_t_og_h_dg_n1_p;
+	static float *fg_t_og_h_dg_n2_p;
+	static float *gapz_n1;
+	static float *gapz_n2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float tmppenal;
+	float *fg_t_og_h_dg_n2_p_pt;
+	float *og_t_fg_h_dg_n2_p_pt;
+	float *og_h_dg_n2_p_pt;
+	float *fg_h_dg_n2_p_pt;
+	float *gapz_n2_pt0;
+	float *gapz_n2_pt1;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fg_t_og_h_dg_n1_p_va;
+	float og_t_fg_h_dg_n1_p_va;
+	float og_h_dg_n1_p_va;
+	float fg_h_dg_n1_p_va;
+	float gapz_n1_va0;
+	float gapz_n1_va1;
+	float fgcp1va;
+	float ogcp1va;
+	float kyokaipenal;
+	float fpenalty = (float)penalty;
+
+#if 0
+	fprintf( stderr, "####  seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "####  seq2[0] = %s\n", seq2[0] );
+#endif
+
+
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( digf1 );
+			FreeFloatVec( digf2 );
+			FreeFloatVec( diaf1 );
+			FreeFloatVec( diaf2 );
+			FreeFloatVec( gapz1 );
+			FreeFloatVec( gapz2 );
+			FreeFloatVec( gapf1 );
+			FreeFloatVec( gapf2 );
+			FreeFloatVec( ogcp1g );
+			FreeFloatVec( ogcp2g );
+			FreeFloatVec( fgcp1g );
+			FreeFloatVec( fgcp2g );
+			FreeFloatVec( og_h_dg_n1_p );
+			FreeFloatVec( og_h_dg_n2_p );
+			FreeFloatVec( fg_h_dg_n1_p );
+			FreeFloatVec( fg_h_dg_n2_p );
+			FreeFloatVec( og_t_fg_h_dg_n1_p );
+			FreeFloatVec( og_t_fg_h_dg_n2_p );
+			FreeFloatVec( fg_t_og_h_dg_n1_p );
+			FreeFloatVec( fg_t_og_h_dg_n2_p );
+			FreeFloatVec( gapz_n1 );
+			FreeFloatVec( gapz_n2 );
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		digf1 = AllocateFloatVec( ll1+2 );
+		digf2 = AllocateFloatVec( ll2+2 );
+		diaf1 = AllocateFloatVec( ll1+2 );
+		diaf2 = AllocateFloatVec( ll2+2 );
+		gapz1 = AllocateFloatVec( ll1+2 );
+		gapz2 = AllocateFloatVec( ll2+2 );
+		gapf1 = AllocateFloatVec( ll1+2 );
+		gapf2 = AllocateFloatVec( ll2+2 );
+		ogcp1g = AllocateFloatVec( ll1+2 );
+		ogcp2g = AllocateFloatVec( ll2+2 );
+		fgcp1g = AllocateFloatVec( ll1+2 );
+		fgcp2g = AllocateFloatVec( ll2+2 );
+		og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		og_t_fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_t_fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_t_og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_t_og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		gapz_n1 = AllocateFloatVec( ll1+2 );
+		gapz_n2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+#if 0
+	{
+		float t = 0.0;
+		for( i=0; i<icyc; i++ )
+			t += eff1[i];
+	fprintf( stderr, "## totaleff = %f\n", t );
+	}
+#endif
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure_part( gapz1, icyc, seq1, eff1, lgth1, sgap1 );
+		getgapfreq_zure_part( gapz2, jcyc, seq2, eff2, lgth2, sgap1 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
+		getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
+		getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
+		getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
+		getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	lastj = lgth2+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n2_p[i] = ( 1.0-ogcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		fg_h_dg_n2_p[i] = ( 1.0-fgcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n2_p[i] = (1.0-ogcp2g[i]+fgcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n2_p[i] = (1.0-fgcp2g[i]+ogcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		gapz_n2[i] = (1.0-gapz2[i]);
+	}
+	lastj = lgth1+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n1_p[i] = ( 1.0-ogcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		fg_h_dg_n1_p[i] = ( 1.0-fgcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n1_p[i] = (1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n1_p[i] = (1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		gapz_n1[i] = (1.0-gapz1[i]);
+	}
+#endif
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	if( RNAscoremtx != 'r' )
+		match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	else
+		clearvec( initverticalw, lgth1 );
+	if( localhom )
+		imp_match_out_vead_tateQ_gapmap( initverticalw, gapmap2[0], lgth1, gapmap1 ); // 060306
+
+	if( RNAscoremtx != 'r' )
+		match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	else
+		clearvec( currentw, lgth2 );
+	if( localhom )
+		imp_match_out_veadQ_gapmap( currentw, gapmap1[0], lgth2, gapmap2 ); // 060306
+
+
+
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+
+
+	kyokaipenal = 0.0;
+	if( outgap == 1 )
+	{
+		g = 0.0;
+
+		g += ogcp1g[0] * og_h_dg_n2_p[0];
+//		g += ogcp1g[0] * ( 1.0-ogcp2g[0]-digf2[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal1=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += ogcp2g[0] * og_h_dg_n1_p[0];
+//		g += ogcp2g[0] * ( 1.0-ogcp1g[0]-digf1[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal2=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += fgcp1g[0] * fg_h_dg_n2_p[0];
+//		g += fgcp1g[0] * ( 1.0-fgcp2g[0]-digf2[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		g += fgcp2g[0] * fg_h_dg_n1_p[0];
+//		g += fgcp2g[0] * ( 1.0-fgcp1g[0]-digf1[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		kyokaipenal = g;
+		initverticalw[0] += g;
+		currentw[0] += g;
+
+		for( i=1; i<lgth1+1; i++ )
+		{
+			tmppenal = gapz_n2[0]*og_t_fg_h_dg_n1_p[0];
+//			tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+fgcp1g[0]-digf1[0]) ) * 0.5 * fpenalty; // mada
+			initverticalw[i] += tmppenal;
+
+			tmppenal = gapz_n2[1]*fg_t_og_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			initverticalw[i] += tmppenal;
+
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			tmppenal = gapz_n1[0]*og_t_fg_h_dg_n2_p[0];
+//			tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+fgcp2g[0]-digf2[0]) ) * 0.5 * fpenalty; // mada
+			currentw[j] += tmppenal;
+
+			tmppenal = gapz_n1[1]*fg_t_og_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			currentw[j] += tmppenal;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	m[0] = 0.0; // iranai
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		mp[j] = 0;
+		m[j] = currentw[j-1] + 10000 * fpenalty; //iinoka?
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		if( RNAscoremtx != 'r' )
+			match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+		else
+			clearvec( currentw, lgth2 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_veadQ( currentw, i, lgth2 );
+#else
+			imp_match_out_veadQ_gapmap( currentw, gapmap1[i], lgth2, gapmap2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mpi = 0;
+		mi = previousw[0] + 10000 * fpenalty;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fg_t_og_h_dg_n2_p_pt = fg_t_og_h_dg_n2_p + 1;
+		og_t_fg_h_dg_n2_p_pt = og_t_fg_h_dg_n2_p + 1;
+		og_h_dg_n2_p_pt = og_h_dg_n2_p + 1;
+		fg_h_dg_n2_p_pt = fg_h_dg_n2_p + 1;
+		gapz_n2_pt0 = gapz_n2 + 1;
+		gapz_n2_pt1 = gapz_n2 + 2;
+		fgcp2pt = fgcp2g + 1;
+		ogcp2pt = ogcp2g + 1;
+
+		fg_t_og_h_dg_n1_p_va = fg_t_og_h_dg_n1_p[i];
+		og_t_fg_h_dg_n1_p_va = og_t_fg_h_dg_n1_p[i];
+		og_h_dg_n1_p_va = og_h_dg_n1_p[i];
+		fg_h_dg_n1_p_va = fg_h_dg_n1_p[i];
+		gapz_n1_va0 = gapz_n1[i];
+		gapz_n1_va1 = gapz_n1[i+1];
+		fgcp1va = fgcp1g[i];
+		ogcp1va = ogcp1g[i];
+
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+
+			g = ogcp1va * *og_h_dg_n2_p_pt;
+//			g = ogcp1g[i] * og_h_dg_n2_p[j];
+//			g = ogcp1g[i] * ( 1.0-ogcp2g[j]-digf2[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = *ogcp2pt * og_h_dg_n1_p_va;
+//			g = ogcp2g[j] * og_h_dg_n1_p[i];
+//			g = ogcp2g[j] * ( 1.0-ogcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = fgcp1va * *fg_h_dg_n2_p_pt;
+//			g = fgcp1g[i] * fg_h_dg_n2_p[j];
+//			g = fgcp1g[i] * ( 1.0-fgcp2g[j]-digf2[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal3=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = *fgcp2pt * fg_h_dg_n1_p_va;
+//			g = fgcp2g[j] * fg_h_dg_n1_p[i];
+//			g = fgcp2g[j] * ( 1.0-fgcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal4=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			tmppenal = gapz_n1_va1 * *fg_t_og_h_dg_n2_p_pt;
+//			tmppenal = gapz_n1[i+1] * fg_t_og_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[i+1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			if( (g=mi+tmppenal) > wm )
+			{
+//				fprintf( stderr, "jump i start=%f (j=%d, fgcp2g[j]=%f, digf2[j]=%f, diaf2[j]=%f), %c-%c\n", g-mi, j, fgcp2g[j], digf2[j], diaf2[j], seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			tmppenal = gapz_n1_va0 * *og_t_fg_h_dg_n2_p_pt;
+//			tmppenal = gapz_n1[i] * og_t_fg_h_dg_n2_p[j];
+//			tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[j]+fgcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			if( (g=*prept+tmppenal) >= mi )
+			{
+//				fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				mi = g;
+				mpi = j-1;
+			}
+
+#if USE_PENALTY_EX
+            mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			tmppenal = *gapz_n2_pt1 * fg_t_og_h_dg_n1_p_va;
+//			tmppenal = gapz_n2[j+1] * fg_t_og_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[j+1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			if( (g=*mjpt+tmppenal) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			tmppenal = *gapz_n2_pt0 * og_t_fg_h_dg_n1_p_va;
+//			tmppenal = gapz_n2[j] * og_t_fg_h_dg_n1_p[i];
+//			tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			if( (g=*prept+tmppenal) >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+
+#if USE_PENALTY_EX
+            m[j] += fpenalty_ex;
+#endif
+
+
+
+
+
+			*curpt++ += wm;
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+			fg_t_og_h_dg_n2_p_pt++;
+			og_t_fg_h_dg_n2_p_pt++;
+			og_h_dg_n2_p_pt++;
+			fg_h_dg_n2_p_pt++;
+			gapz_n2_pt0++;
+			gapz_n2_pt1++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom_gapmap( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, gapmap1, gapmap2 );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Ralignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Ralignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Ralignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Ralignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1213 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+
+static float **impmtx = NULL;
+#if 1 // tditeration to naiveRscore_imp de tsukawareru.
+float imp_match_out_scR( int i1, int j1 )
+{
+//	fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
+//	fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+}
+#endif
+
+static void imp_match_out_veadR( float *imp, int i1, int lgth2 )
+{
+#if FASTMATCHCALC 
+	float *pt = impmtx[i1];
+	while( lgth2-- )
+		*imp++ += *pt++;
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[j];
+#endif
+}
+static void imp_match_out_vead_tateR( float *imp, int j1, int lgth1 )
+{
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[i][j1];
+}
+
+#if 1 // tbfast.c kara yobareru.
+void imp_match_init_strictR( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	static int impalloclen = 0;
+	float effij;
+	double effijx;
+	char *pt, *pt1, *pt2;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+	LocalHom *tmpptr;
+
+	if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx =  fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = (float)( eff1[i] * eff2[j] * effijx );
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = pt - seq1[i] - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = pt - seq1[i] - 0;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = pt - seq1[i] - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = pt - seq2[j] - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = pt - seq2[j] - 0;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = pt - seq2[j] - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+#if 1
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+//						fprintf( stderr, "%d (%c) - %d (%c)  - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+#else
+				while( k1 <= end1 && k2 <= end2 )
+				{
+					fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
+					if( !nocount1[k1] && !nocount2[k2] )
+					{
+						impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j]  * fastathreshold;
+						fprintf( stderr, "marked\n" );
+					}
+					else
+						fprintf( stderr, "no count\n" );
+					k1++; k2++;
+				}
+#endif
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+#if 0
+	if( clus1 == 1 && clus2 == 6 )
+	{
+		fprintf( stderr, "\n" );
+		fprintf( stderr, "seq1[0] =  %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] =  %s\n", seq2[0] );
+		fprintf( stderr, "impmtx = \n" );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", (double)k2 );
+		fprintf( stderr, "\n" );
+		for( k1=0; k1<lgth1; k1++ )
+		{
+			fprintf( stderr, "%d ", k1 );
+			for( k2=0; k2<3; k2++ )
+				fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+			fprintf( stderr, "\n" );
+		}
+		exit( 1 );
+	}
+#endif
+}
+#endif
+
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+				scarr[l] += n_dis[j][l] * cpmx1[j][i1];
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_scR( iin, jin );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+}
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+	return( 0.0 );
+}
+
+float R__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *digf1;
+	static float *digf2;
+	static float *diaf1;
+	static float *diaf2;
+	static float *gapz1;
+	static float *gapz2;
+	static float *gapf1;
+	static float *gapf2;
+	static float *ogcp1g;
+	static float *ogcp2g;
+	static float *fgcp1g;
+	static float *fgcp2g;
+	static float *ogcp1;
+	static float *ogcp2;
+	static float *fgcp1;
+	static float *fgcp2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float fpenalty = (float)penalty;
+	float tmppenal;
+	float cumpenal;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fgcp1va;
+	float ogcp1va;
+	float kyokaipenal;
+
+
+
+#if 0
+	fprintf( stderr, "####  seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "####  seq2[0] = %s\n", seq2[0] );
+#endif
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( digf1 );
+			FreeFloatVec( digf2 );
+			FreeFloatVec( diaf1 );
+			FreeFloatVec( diaf2 );
+			FreeFloatVec( gapz1 );
+			FreeFloatVec( gapz2 );
+			FreeFloatVec( gapf1 );
+			FreeFloatVec( gapf2 );
+			FreeFloatVec( ogcp1 );
+			FreeFloatVec( ogcp2 );
+			FreeFloatVec( fgcp1 );
+			FreeFloatVec( fgcp2 );
+			FreeFloatVec( ogcp1g );
+			FreeFloatVec( ogcp2g );
+			FreeFloatVec( fgcp1g );
+			FreeFloatVec( fgcp2g );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		digf1 = AllocateFloatVec( ll1+2 );
+		digf2 = AllocateFloatVec( ll2+2 );
+		diaf1 = AllocateFloatVec( ll1+2 );
+		diaf2 = AllocateFloatVec( ll2+2 );
+		gapz1 = AllocateFloatVec( ll1+2 );
+		gapz2 = AllocateFloatVec( ll2+2 );
+		gapf1 = AllocateFloatVec( ll1+2 );
+		gapf2 = AllocateFloatVec( ll2+2 );
+		ogcp1 = AllocateFloatVec( ll1+2 );
+		ogcp2 = AllocateFloatVec( ll2+2 );
+		fgcp1 = AllocateFloatVec( ll1+2 );
+		fgcp2 = AllocateFloatVec( ll2+2 );
+		ogcp1g = AllocateFloatVec( ll1+2 );
+		ogcp2g = AllocateFloatVec( ll2+2 );
+		fgcp1g = AllocateFloatVec( ll1+2 );
+		fgcp2g = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+#if 0
+	{
+		float t = 0.0;
+		for( i=0; i<icyc; i++ )
+			t += eff1[i];
+	fprintf( stderr, "## totaleff = %f\n", t );
+	}
+#endif
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure_part( gapz1, icyc, seq1, eff1, lgth1, sgap1 );
+		getgapfreq_zure_part( gapz2, jcyc, seq2, eff2, lgth2, sgap1 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
+		getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
+		getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
+		getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
+		getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead_tateR( initverticalw, 0, lgth1 ); // 060306
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_veadR( currentw, 0, lgth2 ); // 060306
+
+
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+
+
+	kyokaipenal = 0.0;
+	if( outgap == 1 )
+	{
+		g = 0.0;
+
+		g += ogcp1g[0] * ( 1.0-ogcp2g[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal1=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += ogcp2g[0] * ( 1.0-ogcp1g[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "init-match penal2=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
+
+		g += fgcp1g[0] * ( 1.0-fgcp2g[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		g += fgcp2g[0] * ( 1.0-fgcp1g[0] ) * fpenalty * 0.5;
+//		if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+
+		kyokaipenal = g;
+		initverticalw[0] += g;
+		currentw[0] += g;
+
+		cumpenal = 0.0;
+		for( i=1; i<lgth1+1; i++ )
+		{
+//			initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
+
+//	Q		tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+fgcp1g[0]-digf1[0]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+0.0) + gapz2[0]*(1.0-digf1[0] - diaf1[0]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-0.0)*(1.0-ogcp1g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-0.0) * (1.0-diaf1[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
+//			tmppenal -= ( (1.0-gapf2[j-1]) * ogcp1g[i] + gapf2[j-1] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 1 = %f\n", i, 0, tmppenal );
+			initverticalw[i] += tmppenal;
+
+//	Q		tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[0])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[0]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[0]) * (1.0-diaf1[i]) + gapf2[0] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j]) * fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
+			initverticalw[i] += tmppenal;
+			cumpenal += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5;
+			initverticalw[i] += cumpenal - fgcp1g[i] * fpenalty * 0.5; // honto ha iru
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 2 = %f, cumpenal=%f, fgcp1g[i]=%f, ogcp1g[i]=%f\n", i, 0, tmppenal, cumpenal, fgcp1g[i], ogcp1g[i] );
+
+		}
+		cumpenal = 0.0;
+		for( j=1; j<lgth2+1; j++ )
+		{
+//			currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
+
+//			tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+fgcp2g[0]-digf2[0]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[j]+fgcp2g[j]) + gapf1[i-1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+0.0) + gapz1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-0.0)*(1.0-ogcp2g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-0.0) * (1.0-diaf2[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
+//			tmppenal -= ( (1.0-gapf1[0]) * fgcp2g[j] + gapf1[0] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 3 = %f\n", 0, j, tmppenal );
+			currentw[j] += tmppenal;
+
+//			tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[0])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[0]) * (1.0-diaf2[j]) + gapf1[0] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[0]) * ogcp2g[j] + gapf1[i-1] ) * 0.5 * fpenalty;
+//			fprintf( stderr, "0,0<-%d,%d, tmppenal 4 = %f\n", 0, j, tmppenal );
+			currentw[j] += tmppenal;
+			cumpenal += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5;
+			currentw[j] += cumpenal - fgcp2g[j] * fpenalty * 0.5; // honto ha iru
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	m[0] = 0.0; // iranai
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		mp[j] = 0;
+		m[j] = currentw[j-1] + 10000 * fpenalty; //iinoka?
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_veadR( currentw, i, lgth2 );
+#else
+			imp_match_out_veadR( currentw, i, lgth2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mpi = 0;
+		mi = previousw[0] + 10000 * fpenalty;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fgcp2pt = fgcp2;
+		ogcp2pt = ogcp2 + 1;
+		fgcp1va = fgcp1[i-1];
+		ogcp1va = ogcp1[i];
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+
+			g = ogcp1g[i] * ( 1.0-ogcp2g[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal1=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = ogcp2g[j] * ( 1.0-ogcp1g[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal2=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = fgcp1g[i] * ( 1.0-fgcp2g[j] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal3=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+			g = fgcp2g[j] * ( 1.0-fgcp1g[i] ) * fpenalty * 0.5;
+//			if( g && i==j ) fprintf( stderr, "match penal4=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm += g;
+
+#if 0
+			g = fgcp2g[j] * ogcp1g[i] * fpenalty * 0.5;
+			if( g ) fprintf( stderr, "match m-penal5=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm -= g;
+
+			g = fgcp1g[i] * ogcp2g[j] * fpenalty * 0.5;
+			if( g ) fprintf( stderr, "match m-penal6=%f, %c-%c\n", g, seq1[0][i], seq2[0][j] );
+			wm -= g;
+#endif
+
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+//			tmppenal = ( (1.0-gapz1[i+1])*(1.0-fgcp2g[j]+ogcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz1[i+1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[i+1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[i])*(1.0-diaf2[j]) + gapf1[i] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[i])*fgcp2g[j] + gapf1[i] ) * 0.5 * fpenalty;
+//			tmppenal = *fgcp2pt-fpenalty*0.5*gapf1[i];
+//			tmppenal = *fgcp2pt;
+			if( (g=mi+tmppenal) > wm )
+			{
+//				fprintf( stderr, "jump i start=%f (j=%d, fgcp2g[j]=%f, digf2[j]=%f, diaf2[j]=%f), %c-%c\n", g-mi, j, fgcp2g[j], digf2[j], diaf2[j], seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+//			tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[j]+fgcp2g[j]-digf2[j]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[j]+fgcp2g[j]) + gapz1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[j]+fgcp2g[j]) + gapf1[i-1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = *ogcp2pt-fpenalty*0.5*(gapf2[j-1]+gapf1[i-1]);
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[i-1])*(1.0-diaf2[j]) + gapf1[i-1] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf1[i-1])*ogcp2g[j] + gapf1[i-1] ) * 0.5 * fpenalty;
+//			tmppenal = *prept+*ogcp2pt;
+			if( (g=*prept+tmppenal) >= mi )
+			{
+//				fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				mi = g;
+				mpi = j-1;
+			}
+			else if( j != 1 )
+			{
+				mi += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5; // CHUUI honto ha iru
+//				fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", '=', '=', seq2[0][j-1], seq2[0][j], ogcp2g[j-0] * fpenalty*0.5, fgcp2g[j] * fpenalty*0.5 );
+			}
+#if USE_PENALTY_EX
+				mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+//			tmppenal = ( (1.0-gapz2[j+1])*(1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz2[j+1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[j+1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j])*(1.0-diaf1[i]) + gapf2[j] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j])*fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
+//			tmppenal = fgcp1va-fpenalty*0.5*gapf2[j];
+//			tmppenal = fgcp1va;
+			if( (g=*mjpt+tmppenal) > wm )
+			{
+//				if( seq1[0][i] == 'Y' && seq2[0][j] == 'B' )
+//					fprintf( stderr, "jump j start=%f, %c-%c\n", g-*mjpt, seq1[0][i], seq2[0][j] );
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+//			tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) ) * 0.5 * fpenalty; // mada
+			tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapz2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
+//			tmppenal = ogcp1va-fpenalty*0.5*(gapf1[i-1]+gapf2[j-1]);
+//			tmppenal = 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j-1]) * (1.0-diaf1[i]) + gapf2[j-1] ) * 0.5 * fpenalty;
+//			tmppenal -= ( (1.0-gapf2[j-1]) * ogcp1g[i] + gapf2[j-1] ) * 0.5 * fpenalty;
+//			tmppenal = 0.5 * fpenalty - ( (1.0-gapf2[j-1]) * (ogcp1g[i]) + gapf2[j-1] ) * ( 0.5 * fpenalty );
+//			tmppenal = ogcp1va-fpenalty*0.5*gapf2[j-1];
+//			tmppenal = ogcp1va;
+			if( (g=*prept+tmppenal) >= *mjpt )
+			{
+//				if( seq1[0][i] == 'T' && seq2[0][j] == 'T' )
+//					fprintf( stderr, "jump j end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+			else if( i != 1 )
+			{
+				m[j] += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5; // CHUUI honto ha iru
+//				fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", seq1[0][i-1], seq1[0][i], '=', '=', ogcp1g[i-0] * fpenalty*0.5, fgcp1g[i] * fpenalty*0.5 );
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+			*curpt++ += wm;
+			ijppt++;
+			mjpt++;
+			prept++;
+			mpjpt++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+	fprintf( stderr, "wm = %f\n", wm );
+
+
+	return( wm );
+}
+
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/SAalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/SAalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/SAalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/SAalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,376 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+
+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[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0;
+		for( k=0; cpmxpdn[k][j] > -1;  k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+}
+
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, k, l, iin, jin, ifi, jfi, lgth1, lgth2;
+	char gap[] = "-";
+	float wm;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if DEBUG
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	for( k=0; k<=lgth1+lgth2; 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][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][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+
+float 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 float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *currentw;
+	static float *previousw;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+
+#if DEBUG
+	fprintf( stderr, "eff in SA+++align\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
+#endif
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 1 ); 
+		mseq2 = AllocateCharMtx( njob, 1 ); /* by J. Thompson */
+	}
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( currentw );
+			FreeFloatVec( previousw );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.1*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.1*lgth2), orlgth2 ) + 100;
+
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+
+		currentw = AllocateFloatVec( ll2+2 );
+		previousw = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+		fprintf( stderr, "succeeded\n" );
+
+		orlgth1 = ll1;
+		orlgth2 = ll2;
+	}
+
+	for( i=0; i<icyc; i++ ) mseq1[i] = mseq[i];
+	for( j=0; j<jcyc; j++ ) mseq2[j] = mseq[icyc+j];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+		fprintf( stderr, "succeeded\n\n" );
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+	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 );
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += penalty * 0.5;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += penalty * 0.5;
+		}
+	}
+
+	for( j=0; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1] + penalty * 0.5; mp[j] = 0;
+	}
+
+	lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+	for( i=1; i<lasti; i++ )
+	{
+
+		floatncpy( previousw, currentw, lgth2+1 );
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0] + penalty * 0.5; mpi = 0;
+		for( j=1; j<lgth2+1; j++ )
+		{
+			wm = previousw[j-1];
+			ijp[i][j] = 0;
+
+			g = penalty * 0.5;
+			x = mi + g;
+			if( x > wm )
+			{
+				wm = x;
+				ijp[i][j] = -( j - mpi );
+			}
+			g = penalty * 0.5;
+			x = previousw[j-1] + g;
+			if( mi <= x )
+			{
+				mi = x;
+				mpi = j-1;
+			}
+
+			g = penalty * 0.5;
+			x = m[j] + g;
+			if( x > wm )
+			{
+				wm = x;
+				ijp[i][j] = +( i - mp[j] );
+			}
+			g = penalty * 0.5;
+			x = previousw[j-1] + g;
+			if( m[j] <= x )
+			{
+				m[j] = x;
+				mp[j] = i-1;
+			}
+			currentw[j] += wm;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+	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" );
+	}
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+	return( wm );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/Salignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/Salignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/Salignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/Salignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1785 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+
+static float **impmtx = NULL;
+static int impalloclen = 0;
+float imp_match_out_sc( int i1, int j1 )
+{
+//	fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
+//	fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+}
+static void imp_match_out_vead_gapmap( float *imp, int i1, int lgth2, int *gapmap2 )
+{
+#if FASTMATCHCALC
+	float *pt = impmtx[i1];
+	int *gapmappt = gapmap2;
+	while( lgth2-- )
+		*imp++ += pt[*gapmappt++];
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[gapmap2[j]];
+#endif
+}
+
+
+static void imp_match_out_vead_tate_gapmap( float *imp, int j1, int lgth1, int *gapmap1 )
+{
+#if FASTMATCHCALC
+	int *gapmappt = gapmap1;
+	while( lgth1-- )
+		*imp++ += impmtx[*gapmappt++][j1];
+#else
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[gapmap1[i]][j1];
+#endif
+}
+
+static void imp_match_out_vead( float *imp, int i1, int lgth2 )
+{
+#if FASTMATCHCALC 
+	float *pt = impmtx[i1];
+	while( lgth2-- )
+		*imp++ += *pt++;
+#else
+	int j;
+	float *pt = impmtx[i1];
+	for( j=0; j<lgth2; j++ )
+		*imp++ += pt[j];
+#endif
+}
+static void imp_match_out_vead_tate( float *imp, int j1, int lgth1 )
+{
+	int i;
+	for( i=0; i<lgth1; i++ )
+		*imp++ += impmtx[i][j1];
+}
+
+void imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, int *gapmap1, int *gapmap2, RNApair *pair )
+{
+	foldrna( nseq1, nseq2, seq1, seq2, eff1, eff2, grouprna1, grouprna2, impmtx, gapmap1, gapmap2, pair );
+}
+
+
+void imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	float effij;
+	double effijx;
+	char *pt, *pt1, *pt2;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+	LocalHom *tmpptr;
+
+	if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx =  fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = (float)( eff1[i] * eff2[j] * effijx );
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = pt - seq1[i] - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = pt - seq1[i] - 0;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = pt - seq1[i] - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = pt - seq2[j] - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = pt - seq2[j] - 0;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = pt - seq2[j] - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+#if 1
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+//						fprintf( stderr, "%d (%c) - %d (%c)  - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+#else
+				while( k1 <= end1 && k2 <= end2 )
+				{
+					fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
+					if( !nocount1[k1] && !nocount2[k2] )
+					{
+						impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j]  * fastathreshold;
+						fprintf( stderr, "marked\n" );
+					}
+					else
+						fprintf( stderr, "no count\n" );
+					k1++; k2++;
+				}
+#endif
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+
+#if 0
+	if( clus1 == 1 && clus2 == 1 )
+	{
+		fprintf( stderr, "writing impmtx\n" );
+		fprintf( stderr, "\n" );
+		fprintf( stderr, "seq1[0] =  %s\n", seq1[0] );
+		fprintf( stderr, "seq2[0] =  %s\n", seq2[0] );
+		fprintf( stderr, "impmtx = \n" );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", (double)k2 );
+		fprintf( stderr, "\n" );
+		for( k1=0; k1<lgth1; k1++ )
+		{
+			fprintf( stderr, "%d ", k1 );
+			for( k2=0; k2<30; k2++ )
+				fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+			fprintf( stderr, "\n" );
+		}
+//		exit( 1 );
+	}
+#endif
+}
+
+#if 0
+void imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom )
+{
+	int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	static int impalloclen = 0;
+	char *pt;
+	int allgap;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+
+	if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0;
+	for( i=0; i<clus1; i++ )
+	{
+		fprintf( stderr, "i = %d, seq1 = %s\n", i, seq1[i] );
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stderr, "start1 = %d\n", localhom[i][j]->start1 );
+			fprintf( stderr, "end1   = %d\n", localhom[i][j]->end1   );
+			fprintf( stderr, "j = %d, seq2 = %s\n", j, seq2[j] );
+			pt = seq1[i];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start1 ) break;
+			}
+			start1 = pt - seq1[i] - 1;
+
+			while( *pt != 0 )
+			{
+//				fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, localhom[i][j].end1, pt-seq1[i] );
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end1 ) break;
+			}
+			end1 = pt - seq1[i] - 1;
+
+			pt = seq2[j];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start2 ) break;
+			}
+			start2 = pt - seq2[j] - 1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end2 ) break;
+			}
+			end2 = pt - seq2[j] - 1;
+//			fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+			k1 = start1;
+			k2 = start2;
+			fprintf( stderr, "step 0\n" );
+			while( k1 <= end1 && k2 <= end2 )
+			{
+#if 0
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j].wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#else
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j]->wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#endif
+			}
+
+			dif = ( end1 - start1 ) - ( end2 - start2 );
+			fprintf( stderr, "dif = %d\n", dif );
+			if( dif > 0 )
+			{
+				do
+				{
+					fprintf( stderr, "dif = %d\n", dif );
+					k1 = start1;
+					k2 = start2 - dif;
+					while( k1 <= end1 && k2 <= end2 )
+					{
+						if( 0 <= k2 && start2 <= k2 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif-- );
+			}
+			else
+			{
+				do
+				{
+					k1 = start1 + dif;
+					k2 = start2;
+					while( k1 <= end1 )
+					{
+						if( k1 >= 0 && k1 >= start1 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif++ );
+			}
+		}
+	}
+#if 0
+	fprintf( stderr, "impmtx = \n" );
+	for( k2=0; k2<lgth2; k2++ )
+		fprintf( stderr, "%6.3f ", (double)k2 );
+	fprintf( stderr, "\n" );
+	for( k1=0; k1<lgth1; k1++ )
+	{
+		fprintf( stderr, "%d", k1 );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", impmtx[k1][k2] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+}
+#endif
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+//				scarr[l] += n_dis[j][l] * cpmx1[j][i1];
+				scarr[l] += n_dis_consweight_multi[j][l] * cpmx1[j][i1];
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis_consweight_multi[k][l] * cpmx1[k][i1];
+//			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_sc( iin, jin );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+}
+static void Atracking_localhom_gapmap( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc,
+						int *gapmap1, int *gapmap2 )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin == lgth1 || jin == lgth2 )
+			;
+		else
+		{
+			*impwmpt += imp_match_out_sc( gapmap1[iin], gapmap2[jin] );
+
+//		fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = '-';
+		*--gaptable2 = '-';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+}
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	float wm;
+	char *gaptable1, *gt1bk;
+	char *gaptable2, *gt2bk;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	gt1bk = AllocateCharVec( lgth1+lgth2+1 );
+	gt2bk = AllocateCharVec( lgth1+lgth2+1 );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijp[i][0] = i + 1;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijp[0][j] = -( j + 1 );
+    }
+
+	gaptable1 = gt1bk + lgth1+lgth2;
+	*gaptable1 = 0;
+	gaptable2 = gt2bk + lgth1+lgth2;
+	*gaptable2 = 0;
+
+	iin = lgth1; jin = lgth2;
+	for( k=0; k<=lgth1+lgth2; 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 ) 
+		{
+			*--gaptable1 = 'o';
+			*--gaptable2 = '-';
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--gaptable1 = '-';
+			*--gaptable2 = 'o';
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--gaptable1 = 'o';
+		*--gaptable2 = 'o';
+		k++;
+		iin = ifi; jin = jfi;
+	}
+
+	for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
+	for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
+
+	free( gt1bk );
+	free( gt2bk );
+
+	return( 0.0 );
+}
+
+float A__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *ogcp1;
+	static float *ogcp2;
+	static float *fgcp1;
+	static float *fgcp2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float fpenalty = (float)penalty;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fgcp1va;
+	float ogcp1va;
+
+
+
+#if 0
+	fprintf( stderr, "####  eff in SA+++align\n" );
+	fprintf( stderr, "####  seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "####  strlen( seq1[0] ) = %d\n", strlen( seq1[0] ) );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
+#endif
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( ogcp1 );
+			FreeFloatVec( ogcp2 );
+			FreeFloatVec( fgcp1 );
+			FreeFloatVec( fgcp2 );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		ogcp1 = AllocateFloatVec( ll1+2 );
+		ogcp2 = AllocateFloatVec( ll2+2 );
+		fgcp1 = AllocateFloatVec( ll1+2 );
+		fgcp2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+#if 0
+	{
+		float t = 0.0;
+		for( i=0; i<icyc; i++ )
+			t += eff1[i];
+	fprintf( stderr, "## totaleff = %f\n", t );
+	}
+#endif
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
+		new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
+		new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap1 );
+		new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+	}
+
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
+	}
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead_tate( initverticalw, 0, lgth1 ); // 060306
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead( currentw, 0, lgth2 ); // 060306
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_vead( currentw, i, lgth2 );
+#else
+			imp_match_out_vead( currentw, i, lgth2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+
+		mi = previousw[0] + ogcp2[1]; mpi = 0;
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fgcp2pt = fgcp2;
+		ogcp2pt = ogcp2 + 1;
+		fgcp1va = fgcp1[i-1];
+		ogcp1va = ogcp1[i];
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+*fgcp2pt) > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			if( (g=*prept+*ogcp2pt) >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt+fgcp1va) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			if( (g=*prept+ogcp1va) >= *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++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+	return( wm );
+}
+
+float A__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int *gapmap1, int *gapmap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj;     /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+//	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *ogcp1;
+	static float *ogcp2;
+	static float *fgcp1;
+	static float *fgcp2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fgcp1va;
+	float ogcp1va;
+
+
+#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
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+#if 0
+	if( lgth1 == 0 || lgth2 == 0 )
+	{
+		fprintf( stderr, "WARNING (Aalign_gapmap): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+#endif
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( ogcp1 );
+			FreeFloatVec( ogcp2 );
+			FreeFloatVec( fgcp1 );
+			FreeFloatVec( fgcp2 );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		ogcp1 = AllocateFloatVec( ll1+2 );
+		ogcp2 = AllocateFloatVec( ll2+2 );
+		fgcp1 = AllocateFloatVec( ll1+2 );
+		fgcp2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 26 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 27, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ )
+	{
+		mseq1[i] = mseq[i];
+		seq1[i][lgth1] = 0;
+	}
+	for( j=0; j<jcyc; j++ )
+	{
+		mseq2[j] = mseq[icyc+j];
+		seq2[j][lgth2] = 0;
+	}
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+	cpmx_calc_new( seq1, cpmx1, eff1, strlen( seq1[0] ), icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, strlen( seq2[0] ), jcyc );
+
+	st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1  );
+	st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+	st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+	st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] );
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] );
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] );
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] );
+	}
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead_tate_gapmap( initverticalw, gapmap2[0], lgth1, gapmap1 ); // 060306
+
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		imp_match_out_vead_gapmap( currentw, gapmap1[0], lgth2, gapmap2 ); // 060306
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
+	}
+
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0;
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+#if  0
+			imp_match_out_vead( currentw, i, lgth2 );
+#else
+			imp_match_out_vead_gapmap( currentw, gapmap1[i], lgth2, gapmap2 );
+#endif
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+
+		mi = previousw[0] + ogcp2[1]; mpi = 0;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fgcp2pt = fgcp2;
+		ogcp2pt = ogcp2 + 1;
+		fgcp1va = fgcp1[i-1];
+		ogcp1va = ogcp1[i];
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+			g = mi + *fgcp2pt;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			g = *prept + *ogcp2pt;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1va;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			g = *prept + ogcp1va;
+			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++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom_gapmap( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, gapmap1, gapmap2 );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+	return( wm );
+}
+
+float translate_and_Calign( char **mseq1, char **mseq2, double *effarr1, double *effarr2, int clus1, int clus2, int alloclen )
+{
+    int i;
+    float wm;
+    char **result;
+    char *seq = NULL, **aseq = NULL;
+    double *effarr = NULL;
+    int nseq = 0;
+	int resultlen;
+
+    if     ( clus1 == 1 && clus2 != 1 ) 
+    {
+        seq = mseq1[0]; aseq = mseq2; effarr = effarr2; nseq = clus2+1;
+#if 0
+		printf( "effarr in transl... = \n" );
+		for( i=0; i<clus2; i++ ) printf( "%f ", effarr2[i] );
+#endif
+    }
+    else if( clus1 != 1 && clus2 == 1 ) 
+    {
+        seq = mseq2[0]; aseq = mseq1; effarr = effarr1; nseq = clus1+1;
+    }
+    else ErrorExit( "ERROR in translate_and_Calign" );
+
+    result = Calignm1( &wm, aseq, seq, effarr, nseq-2, 0 );
+
+	resultlen = strlen( result[0] );
+	if( alloclen < resultlen || resultlen > N )
+	{
+		fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
+		ErrorExit( "LENGTH OVER!\n" );
+	}
+    for( i=0; i<nseq-1; i++ ) strcpy( aseq[i], result[i] );
+    strcpy( seq, result[nseq-1] );
+
+    return( 0.0 );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,265 @@
+#define DEFAULTGOP_B -1530
+#define DEFAULTGEP_B   -00 
+#define DEFAULTOFS_B  -123   /* +10 -- -50  teido ka ? */
+
+void BLOSUMmtx( int n, double **matrix, double *freq, char *amino, char *amino_grp )
+{
+	/*
+	char locaminod[26] = "GASTPLIMVDNEQFYWKRHCXXX.-U";
+	*/
+	char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
+	char locgrpd[] = 
+	{
+		0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
+		6, 6, 6, 6,
+	};
+	double freqd[20] = 
+	{
+	    0.077,
+	    0.051,
+	    0.043,
+	    0.052,
+	    0.020,
+	    0.041,
+	    0.062,
+	    0.074,
+	    0.023,
+	    0.052,
+	    0.091,
+	    0.059,
+	    0.024,
+	    0.040,
+	    0.051,
+	    0.069,
+	    0.059,
+	    0.014,
+	    0.032,
+	    0.066,
+	};
+
+	double tmpmtx30[] = 
+	{
+    4,
+   -1,     8,
+    0,    -2,     8,
+    0,    -1,     1,     9,
+   -3,    -2,    -1,    -3,    17,
+    1,     3,    -1,    -1,    -2,     8,
+    0,    -1,    -1,     1,     1,     2,     6,
+    0,    -2,     0,    -1,    -4,    -2,    -2,     8,
+   -2,    -1,    -1,    -2,    -5,     0,     0,    -3,    14,
+    0,    -3,     0,    -4,    -2,    -2,    -3,    -1,    -2,     6,
+   -1,    -2,    -2,    -1,     0,    -2,    -1,    -2,    -1,     2,     4,
+    0,     1,     0,     0,    -3,     0,     2,    -1,    -2,    -2,    -2,     4,
+    1,     0,     0,    -3,    -2,    -1,    -1,    -2,     2,     1,     2,     2,     6,
+   -2,    -1,    -1,    -5,    -3,    -3,    -4,    -3,    -3,     0,     2,    -1,    -2,    10,
+   -1,    -1,    -3,    -1,    -3,     0,     1,    -1,     1,    -3,    -3,     1,    -4,    -4,    11,
+    1,    -1,     0,     0,    -2,    -1,     0,     0,    -1,    -1,    -2,     0,    -2,    -1,    -1,     4,
+    1,    -3,     1,    -1,    -2,     0,    -2,    -2,    -2,     0,     0,    -1,     0,    -2,     0,     2,     5,
+   -5,     0,    -7,    -4,    -2,    -1,    -1,     1,    -5,    -3,    -2,    -2,    -3,     1,    -3,    -3,    -5,    20,
+   -4,     0,    -4,    -1,    -6,    -1,    -2,    -3,     0,    -1,     3,    -1,    -1,     3,    -2,    -2,    -1,     5,     9,
+    1,    -1,    -2,    -2,    -2,    -3,    -3,    -3,    -3,     4,     1,    -2,     0,     1,    -4,    -1,     1,    -3,     1,     5,
+    0,    -2,     4,     5,    -2,    -1,     0,     0,    -2,    -2,    -1,     0,    -2,    -3,    -2,     0,     0,    -5,    -3,    -2,     5,
+    0,     0,    -1,     0,     0,     4,     5,    -2,     0,    -3,    -1,     1,    -1,    -4,     0,    -1,    -1,    -1,    -2,    -3,     0,     4,
+    0,    -1,     0,    -1,    -2,     0,    -1,    -1,    -1,     0,     0,     0,     0,    -1,    -1,     0,     0,    -2,    -1,     0,    -1,     0,    -1,
+	};
+	
+	double tmpmtx45[] = 
+	{
+      5,
+     -2,      7,
+     -1,      0,      6,
+     -2,     -1,      2,      7,
+     -1,     -3,     -2,     -3,     12,
+     -1,      1,      0,      0,     -3,      6,
+     -1,      0,      0,      2,     -3,      2,      6,
+      0,     -2,      0,     -1,     -3,     -2,     -2,      7,
+     -2,      0,      1,      0,     -3,      1,      0,     -2,     10,
+     -1,     -3,     -2,     -4,     -3,     -2,     -3,     -4,     -3,      5,
+     -1,     -2,     -3,     -3,     -2,     -2,     -2,     -3,     -2,      2,      5,
+     -1,      3,      0,      0,     -3,      1,      1,     -2,     -1,     -3,     -3,      5,
+     -1,     -1,     -2,     -3,     -2,      0,     -2,     -2,      0,      2,      2,     -1,      6,
+     -2,     -2,     -2,     -4,     -2,     -4,     -3,     -3,     -2,      0,      1,     -3,      0,      8,
+     -1,     -2,     -2,     -1,     -4,     -1,      0,     -2,     -2,     -2,     -3,     -1,     -2,     -3,      9,
+      1,     -1,      1,      0,     -1,      0,      0,      0,     -1,     -2,     -3,     -1,     -2,     -2,     -1,      4,
+      0,     -1,      0,     -1,     -1,     -1,     -1,     -2,     -2,     -1,     -1,     -1,     -1,     -1,     -1,      2,      5,
+     -2,     -2,     -4,     -4,     -5,     -2,     -3,     -2,     -3,     -2,     -2,     -2,     -2,      1,     -3,     -4,     -3,     15,
+     -2,     -1,     -2,     -2,     -3,     -1,     -2,     -3,      2,      0,      0,     -1,      0,      3,     -3,     -2,     -1,      3,      8,
+      0,     -2,     -3,     -3,     -1,     -3,     -3,     -3,     -3,      3,      1,     -2,      1,      0,     -3,     -1,      0,     -3,     -1,      5,
+	};
+    double tmpmtx50[] = 
+    {
+       5,
+      -2,      7,
+      -1,     -1,      7,
+      -2,     -2,      2,      8,
+      -1,     -4,     -2,     -4,     13,
+      -1,      1,      0,      0,     -3,      7,
+      -1,      0,      0,      2,     -3,      2,      6,
+       0,     -3,      0,     -1,     -3,     -2,     -3,      8,
+      -2,      0,      1,     -1,     -3,      1,      0,     -2,     10,
+      -1,     -4,     -3,     -4,     -2,     -3,     -4,     -4,     -4,      5,
+      -2,     -3,     -4,     -4,     -2,     -2,     -3,     -4,     -3,      2,      5,
+      -1,      3,      0,     -1,     -3,      2,      1,     -2,      0,     -3,     -3,      6,
+      -1,     -2,     -2,     -4,     -2,      0,     -2,     -3,     -1,      2,      3,     -2,      7,
+      -3,     -3,     -4,     -5,     -2,     -4,     -3,     -4,     -1,      0,      1,     -4,      0,      8,
+      -1,     -3,     -2,     -1,     -4,     -1,     -1,     -2,     -2,     -3,     -4,     -1,     -3,     -4,     10,
+       1,     -1,      1,      0,     -1,      0,     -1,      0,     -1,     -3,     -3,      0,     -2,     -3,     -1,      5,
+       0,     -1,      0,     -1,     -1,     -1,     -1,     -2,     -2,     -1,     -1,     -1,     -1,     -2,     -1,      2,      5,
+      -3,     -3,     -4,     -5,     -5,     -1,     -3,     -3,     -3,     -3,     -2,     -3,     -1,      1,     -4,     -4,     -3,     15,
+      -2,     -1,     -2,     -3,     -3,     -1,     -2,     -3,      2,     -1,     -1,     -2,      0,      4,     -3,     -2,     -2,      2,      8,
+       0,     -3,     -3,     -4,     -1,     -3,     -3,     -4,     -4,      4,      1,     -3,      1,     -1,     -3,     -2,      0,     -3,     -1,      5,
+    };
+	double tmpmtx62[] = 
+	{
+      6,
+     -2,      8,
+     -2,     -1,      8,
+     -3,     -2,      2,      9,
+     -1,     -5,     -4,     -5,     13,
+     -1,      1,      0,      0,     -4,      8,
+     -1,      0,      0,      2,     -5,      3,      7,
+      0,     -3,     -1,     -2,     -4,     -3,     -3,      8,
+     -2,      0,      1,     -2,     -4,      1,      0,     -3,     11,
+     -2,     -4,     -5,     -5,     -2,     -4,     -5,     -6,     -5,      6,
+     -2,     -3,     -5,     -5,     -2,     -3,     -4,     -5,     -4,      2,      6,
+     -1,      3,      0,     -1,     -5,      2,      1,     -2,     -1,     -4,     -4,      7,
+     -1,     -2,     -3,     -5,     -2,     -1,     -3,     -4,     -2,      2,      3,     -2,      8,
+     -3,     -4,     -4,     -5,     -4,     -5,     -5,     -5,     -2,      0,      1,     -5,      0,      9,
+     -1,     -3,     -3,     -2,     -4,     -2,     -2,     -3,     -3,     -4,     -4,     -2,     -4,     -5,     11,
+      2,     -1,      1,      0,     -1,      0,      0,      0,     -1,     -4,     -4,      0,     -2,     -4,     -1,      6,
+      0,     -2,      0,     -2,     -1,     -1,     -1,     -2,     -3,     -1,     -2,     -1,     -1,     -3,     -2,      2,      7,
+     -4,     -4,     -6,     -6,     -3,     -3,     -4,     -4,     -4,     -4,     -2,     -4,     -2,      1,     -5,     -4,     -4,     16,
+     -3,     -3,     -3,     -5,     -4,     -2,     -3,     -5,      3,     -2,     -2,     -3,     -1,      4,     -4,     -3,     -2,      3,     10,
+      0,     -4,     -4,     -5,     -1,     -3,     -4,     -5,     -5,      4,      1,     -3,      1,     -1,     -4,     -2,      0,     -4,     -2,      6,
+	};
+	double tmpmtx80[] = 
+	{
+      7,
+     -3,      9,
+     -3,     -1,      9,
+     -3,     -3,      2,     10,
+     -1,     -6,     -5,     -7,     13,
+     -2,      1,      0,     -1,     -5,      9,
+     -2,     -1,     -1,      2,     -7,      3,      8,
+      0,     -4,     -1,     -3,     -6,     -4,     -4,      9,
+     -3,      0,      1,     -2,     -7,      1,      0,     -4,     12,
+     -3,     -5,     -6,     -7,     -2,     -5,     -6,     -7,     -6,      7,
+     -3,     -4,     -6,     -7,     -3,     -4,     -6,     -7,     -5,      2,      6,
+     -1,      3,      0,     -2,     -6,      2,      1,     -3,     -1,     -5,     -4,      8,
+     -2,     -3,     -4,     -6,     -3,     -1,     -4,     -5,     -4,      2,      3,     -3,      9,
+     -4,     -5,     -6,     -6,     -4,     -5,     -6,     -6,     -2,     -1,      0,     -5,      0,     10,
+     -1,     -3,     -4,     -3,     -6,     -3,     -2,     -5,     -4,     -5,     -5,     -2,     -4,     -6,     12,
+      2,     -2,      1,     -1,     -2,     -1,     -1,     -1,     -2,     -4,     -4,     -1,     -3,     -4,     -2,      7,
+      0,     -2,      0,     -2,     -2,     -1,     -2,     -3,     -3,     -2,     -3,     -1,     -1,     -4,     -3,      2,      8,
+     -5,     -5,     -7,     -8,     -5,     -4,     -6,     -6,     -4,     -5,     -4,     -6,     -3,      0,     -7,     -6,     -5,     16,
+     -4,     -4,     -4,     -6,     -5,     -3,     -5,     -6,      3,     -3,     -2,     -4,     -3,      4,     -6,     -3,     -3,      3,     11,
+     -1,     -4,     -5,     -6,     -2,     -4,     -4,     -6,     -5,      4,      1,     -4,      1,     -2,     -4,     -3,      0,     -5,     -3,      7,
+	};
+	double tmpmtx0[] = 
+	{
+     2.4,
+    -0.6,    4.7,
+    -0.3,    0.3,    3.8,
+    -0.3,   -0.3,    2.2,    4.7,
+     0.5,   -2.2,   -1.8,   -3.2,   11.5,
+    -0.2,    1.5,    0.7,    0.9,   -2.4,    2.7,
+     0.0,    0.4,    0.9,    2.7,   -3.0,    1.7,    3.6,
+     0.5,   -1.0,    0.4,    0.1,   -2.0,   -1.0,   -0.8,    6.6,
+    -0.8,    0.6,    1.2,    0.4,   -1.3,    1.2,    0.4,   -1.4,    6.0,
+    -0.8,   -2.4,   -2.8,   -3.8,   -1.1,   -1.9,   -2.7,   -4.5,   -2.2,    4.0,
+    -1.2,   -2.2,   -3.0,   -4.0,   -1.5,   -1.6,   -2.8,   -4.4,   -1.9,    2.8,    4.0,
+    -0.4,    2.7,    0.8,    0.5,   -2.8,    1.5,    1.2,   -1.1,    0.6,   -2.1,   -2.1,    3.2,
+    -0.7,   -1.7,   -2.2,   -3.0,   -0.9,   -1.0,   -2.0,   -3.5,   -1.3,    2.5,    2.8,   -1.4,    4.3,
+    -2.3,   -3.2,   -3.1,   -4.5,   -0.8,   -2.6,   -3.9,   -5.2,   -0.1,    1.0,    2.0,   -3.3,    1.6,    7.0,
+     0.3,   -0.9,   -0.9,   -0.7,   -3.1,   -0.2,   -0.5,   -1.6,   -1.1,   -2.6,   -2.3,   -0.6,   -2.4,   -3.8,    7.6,
+     1.1,   -0.2,    0.9,    0.5,    0.1,    0.2,    0.2,    0.4,   -0.2,   -1.8,   -2.1,    0.1,   -1.4,   -2.8,    0.4,    2.2,
+     0.6,   -0.2,    0.5,    0.0,   -0.5,    0.0,   -0.1,   -1.1,   -0.3,   -0.6,   -1.3,    0.1,   -0.6,   -2.2,    0.1,    1.5,    2.5,
+    -3.6,   -1.6,   -3.6,   -5.2,   -1.0,   -2.7,   -4.3,   -4.0,   -0.8,   -1.8,   -0.7,   -3.5,   -1.0,    3.6,   -5.0,   -3.3,   -3.5,   14.2,
+    -2.2,   -1.8,   -1.4,   -2.8,   -0.5,   -1.7,   -2.7,   -4.0,    2.2,   -0.7,    0.0,   -2.1,   -0.2,    5.1,   -3.1,   -1.9,   -1.9,    4.1,    7.8,
+     0.1,   -2.0,   -2.2,   -2.9,    0.0,   -1.5,   -1.9,   -3.3,   -2.0,    3.1,    1.8,   -1.7,    1.6,    0.1,   -1.8,   -1.0,    0.0,   -2.6,   -1.1,    3.4,
+	};
+
+	int i, j, count;
+	double av;
+	double *tmpmtx;
+
+	if( n == 30 ) tmpmtx = tmpmtx30;
+	else if( n == 45 ) tmpmtx = tmpmtx45;
+	else if( n == 50 ) tmpmtx = tmpmtx50;
+	else if( n == 62 ) tmpmtx = tmpmtx62;
+	else if( n == 80 ) tmpmtx = tmpmtx80;
+	else if( n == 0 ) tmpmtx = tmpmtx0;
+	else if( n == -1 ) tmpmtx = loadaamtx();
+	else
+	{
+		fprintf( stderr, "blosum %d ?\n", n );
+		exit( 1 );
+	}
+
+	count = 0;
+	for( i=0; i<20; i++ )
+	{
+		for( j=0; j<=i; j++ )
+		{
+			matrix[i][j] = matrix[j][i] = (double)tmpmtx[count++];
+		}
+	}
+	if( n == -1 && tmpmtx[400] != -1.0 ) 
+	{
+		for( i=0; i<20; i++ ) freq[i] = tmpmtx[400+i];
+		av = 0.0;
+		for( i=0; i<20; i++ ) av += freq[i];
+		for( i=0; i<20; i++ ) freq[i] /= av;
+	}
+	else
+		for( i=0; i<20; i++ ) freq[i] = freqd[i];
+
+#if 0
+	av = 0.0;
+	for( i=0; i<20; i++ )
+		av += matrix[i][i];
+	av /= 20;
+	fprintf( stdout, "av = %f\n", av );
+
+	for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+		matrix[i][j] /= av;
+
+	av = wav = 0;
+	count = 0;
+	wcount = 0.0;
+	tmptmp = 0.0;
+	for( i=0; i<20; i++ )
+	{
+		fprintf( stdout, "freq[%d] = %f\n", i, freq[i] );
+		tmptmp += freq[i];
+		for( j=0; j<20; j++ )
+		{
+			av += matrix[i][j];
+			wav += freq[i] * freq[j] * matrix[i][j];
+			count++;
+			wcount += freq[i] * freq[j];
+		}
+	}
+
+	av /= count;
+	wav /= wcount;
+	fprintf( stdout, "av = %f\n", av );
+	fprintf( stdout, "wav = %f\n", wav );
+	fprintf( stdout, "wcount = %f\n", wcount );
+	fprintf( stdout, "tmptmp = %f\n", tmptmp );
+
+	for( i=0; i<20; i++ )
+	{
+		for( j=0; j<=i; j++ )
+		{
+			fprintf( stderr, "## %d-%d, %f\n", i, j, matrix[i][j] );
+		}
+	}
+
+	exit( 1 );
+#endif
+
+    for( i=0; i<26; i++ ) amino[i] = locaminod[i];
+    for( i=0; i<26; i++ ) amino_grp[(int)amino[i]] = locgrpd[i];
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/blosum.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,11 @@
+/*
+int locpenaltyd = -2400;
+int locoffsetd = -60;
+char locaminod[26] = "GASTPLIMVDNEQFYWKRHCXXX.-U";
+char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
+char locgrpd[] = 
+{
+	0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
+	6, 6, 6, 6,
+};
+*/

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/constants.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/constants.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/constants.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/constants.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1035 @@
+#include "mltaln.h"
+#include "miyata.h"
+#include "miyata5.h"
+#include "DNA.h"
+
+#include "JTT.c"
+#include "blosum.c"
+
+#define DEBUG 0
+#define TEST 0
+
+#define NORMALIZE1 1
+
+static int shishagonyuu( double in )
+{
+	int out;
+	if     ( in >  0.0 ) out = ( (int)( in + 0.5 ) );
+	else if( in == 0.0 ) out = ( 0 );
+	else if( in <  0.0 ) out = ( (int)( in - 0.5 ) );
+	else                 out = 0;
+	return( out );
+}
+
+static void calcfreq_nuc( int nseq, char **seq, double *datafreq )
+{
+	int i, j, l;
+	int aan;
+	double total;
+	for( i=0; i<4; i++ )
+		datafreq[i] = 0.0;
+	total = 0.0;
+	for( i=0; i<nseq; i++ )
+	{
+		l = strlen( seq[i] );
+		for( j=0; j<l; j++ )
+		{
+			aan = amino_n[(int)seq[i][j]];
+			if( aan == 4 ) aan = 3;
+			if( aan >= 0 && aan < 4 )
+			{
+				datafreq[aan] += 1.0;
+				total += 1.0;
+			}
+		}
+	}
+	for( i=0; i<4; i++ )
+		if( datafreq[i] < 0.0001 ) datafreq[i] = 0.0001;
+
+#if 0
+	fprintf( stderr, "\ndatafreq = " );
+	for( i=0; i<4; i++ )
+		fprintf( stderr, "%10.0f ", datafreq[i] );
+	fprintf( stderr, "\n" );
+#endif
+
+	total = 0.0; for( i=0; i<4; i++ ) total += datafreq[i];
+//	fprintf( stderr, "total = %f\n", total );
+	for( i=0; i<4; i++ ) datafreq[i] /= (double)total;
+}
+
+static void calcfreq( int nseq, char **seq, double *datafreq )
+{
+	int i, j, l;
+	int aan;
+	double total;
+	for( i=0; i<20; i++ )
+		datafreq[i] = 0.0;
+	total = 0.0;
+	for( i=0; i<nseq; i++ )
+	{
+		l = strlen( seq[i] );
+		for( j=0; j<l; j++ )
+		{
+			aan = amino_n[(int)seq[i][j]];
+			if( aan >= 0 && aan < 20 )
+			{
+				datafreq[aan] += 1.0;
+				total += 1.0;
+			}
+		}
+	}
+	for( i=0; i<20; i++ )
+		if( datafreq[i] < 0.0001 ) datafreq[i] = 0.0001;
+
+	fprintf( stderr, "datafreq = \n" );
+	for( i=0; i<20; i++ )
+		fprintf( stderr, "%f\n", datafreq[i] );
+
+	total = 0.0; for( i=0; i<20; i++ ) total += datafreq[i];
+	fprintf( stderr, "total = %f\n", total );
+	for( i=0; i<20; i++ ) datafreq[i] /= (double)total;
+}
+
+void constants( int nseq, char **seq )
+{
+	int i, j, x;
+//	double tmp;
+
+	if( dorp == 'd' )  /* DNA */
+	{
+		int k, m;
+		double average;
+		double **pamx = AllocateDoubleMtx( 11,11 );
+		double **pam1 = AllocateDoubleMtx( 4, 4 );
+		double *freq = AllocateDoubleVec( 4 );
+
+
+		scoremtx = -1;
+		if( RNAppenalty == NOTSPECIFIED ) RNAppenalty = DEFAULTRNAGOP_N;
+		if( RNAppenalty_ex == NOTSPECIFIED ) RNAppenalty_ex = DEFAULTRNAGEP_N;
+		if( ppenalty == NOTSPECIFIED ) ppenalty = DEFAULTGOP_N;
+		if( ppenalty_OP == NOTSPECIFIED ) ppenalty_OP = DEFAULTGOP_N;
+		if( ppenalty_ex == NOTSPECIFIED ) ppenalty_ex = DEFAULTGEP_N;
+		if( ppenalty_EX == NOTSPECIFIED ) ppenalty_EX = DEFAULTGEP_N;
+		if( poffset == NOTSPECIFIED ) poffset = DEFAULTOFS_N;
+		if( RNApthr == NOTSPECIFIED ) RNApthr = DEFAULTRNATHR_N;
+		if( pamN == NOTSPECIFIED ) pamN = DEFAULTPAMN;
+		if( kimuraR == NOTSPECIFIED ) kimuraR = 2;
+
+		RNApenalty = (int)( 3 * 600.0 / 1000.0 * RNAppenalty + 0.5 );
+		RNApenalty_ex = (int)( 3 * 600.0 / 1000.0 * RNAppenalty_ex + 0.5 );
+//		fprintf( stderr, "DEFAULTRNAGOP_N = %d\n", DEFAULTRNAGOP_N );
+//		fprintf( stderr, "RNAppenalty = %d\n", RNAppenalty );
+//		fprintf( stderr, "RNApenalty = %d\n", RNApenalty );
+
+
+		RNAthr = (int)( 3 * 600.0 / 1000.0 * RNApthr + 0.5 );
+		penalty = (int)( 3 * 600.0 / 1000.0 * ppenalty + 0.5);
+		penalty_OP = (int)( 3 * 600.0 / 1000.0 * ppenalty_OP + 0.5);
+		penalty_ex = (int)( 3 * 600.0 / 1000.0 * ppenalty_ex + 0.5);
+		penalty_EX = (int)( 3 * 600.0 / 1000.0 * ppenalty_EX + 0.5);
+		offset = (int)( 3 * 600.0 / 1000.0 * poffset + 0.5);
+		offsetFFT = (int)( 3 * 600.0 / 1000.0 * (-0) + 0.5);
+		offsetLN = (int)( 3 * 600.0 / 1000.0 * 100 + 0.5);
+		penaltyLN = (int)( 3 * 600.0 / 1000.0 * -2000 + 0.5);
+		penalty_exLN = (int)( 3 * 600.0 / 1000.0 * -100 + 0.5);
+		sprintf( modelname, "%s%d (%d), %6.3f (%6.3f), %6.3f (%6.3f)", rnakozo?"RNA":"DNA", pamN, kimuraR,
+        -(double)ppenalty*0.001, -(double)ppenalty*0.003, -(double)poffset*0.001, -(double)poffset*0.003 );
+
+		if( kimuraR == 9999 ) 
+		{
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ ) 
+				pamx[i][j] = (double)locn_disn[i][j];
+#if NORMALIZE1
+			average = 0.0;
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ ) 
+				average += pamx[i][j];
+			average /= 16.0;
+	
+   	     if( disp )
+				fprintf( stderr, "average = %f\n", average );
+	
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ ) 
+				pamx[i][j] -= average;
+	
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] *= 600.0 / average;
+			
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] -= offset; 
+#endif
+		}
+		else
+		{
+				double f = 0.99;
+				double s = (double)kimuraR / ( 2 + kimuraR ) * 0.01;
+				double v = (double)1       / ( 2 + kimuraR ) * 0.01;
+				pam1[0][0] = f; pam1[0][1] = s; pam1[0][2] = v; pam1[0][3] = v;
+				pam1[1][0] = s; pam1[1][1] = f; pam1[1][2] = v; pam1[1][3] = v;
+				pam1[2][0] = v; pam1[2][1] = v; pam1[2][2] = f; pam1[2][3] = s;
+				pam1[3][0] = v; pam1[3][1] = v; pam1[3][2] = s; pam1[3][3] = f;
+	
+				fprintf( stderr, "generating %dPAM scoring matrix for nucleotides ... ", pamN );
+	
+		       	if( disp )
+   		    	{
+   		     		fprintf( stderr, " TPM \n" );
+   		        	for( i=0; i<4; i++ )
+   			       	{
+   		            	for( j=0; j<4; j++ )
+   		                	fprintf( stderr, "%+#6.10f", pam1[i][j] );
+   		            	fprintf( stderr, "\n" );
+   		        	}
+   		        	fprintf( stderr, "\n" );
+   		     	}
+	
+	
+				MtxuntDouble( pamx, 4 );
+				for( x=0; x < pamN; x++ ) MtxmltDouble( pamx, pam1, 4 );
+				for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+					pamx[i][j] /= 1.0 / 4.0;
+	
+				for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				{
+					if( pamx[i][j] == 0.0 ) 
+					{
+						fprintf( stderr, "WARNING: pamx[i][j] = 0.0 ?\n" );
+						pamx[i][j] = 0.00001; /* by J. Thompson */
+					}
+					pamx[i][j] = log10( pamx[i][j] ) * 1000.0;
+				}
+	
+   	    		if( disp )
+   	    		{
+   		     		fprintf( stderr, " after log\n" );
+   	        		for( i=0; i<4; i++ )
+   		       		{
+   	        	    	for( j=0; j<4; j++ )
+   	        	        	fprintf( stderr, "%+#6.10f", pamx[i][j] );
+   	        	    	fprintf( stderr, "\n" );
+   	        		}
+   	        		fprintf( stderr, "\n" );
+   		     	}
+
+
+// ?????
+			for( i=0; i<26; i++ ) amino[i] = locaminon[i];
+			for( i=0; i<0x80; i++ ) amino_n[i] = -1;
+			for( i=0; i<26; i++ ) amino_n[(int)amino[i]] = i;
+			if( fmodel == 1 )
+				calcfreq_nuc( nseq, seq, freq );
+			else
+			{
+				freq[0] = 0.25;
+				freq[1] = 0.25;
+				freq[2] = 0.25;
+				freq[3] = 0.25;
+			}
+//			fprintf( stderr, "a, freq[0] = %f\n", freq[0] );
+//			fprintf( stderr, "g, freq[1] = %f\n", freq[1] );
+//			fprintf( stderr, "c, freq[2] = %f\n", freq[2] );
+//			fprintf( stderr, "t, freq[3] = %f\n", freq[3] );
+
+			
+			average = 0.0;
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				average += pamx[i][j] * freq[i] * freq[j];
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] -= average;
+
+			average = 0.0;
+			for( i=0; i<4; i++ )
+				average += pamx[i][i] * 1.0 / 4.0;
+
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] *= 600.0 / average;
+
+
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] -= offset;        /* extending gap cost */
+
+			for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+				pamx[i][j] = shishagonyuu( pamx[i][j] );
+
+       		if( disp )
+       		{
+        		fprintf( stderr, " after shishagonyuu\n" );
+           		for( i=0; i<4; i++ )
+   	       		{
+           	    	for( j=0; j<4; j++ )
+           	        	fprintf( stderr, "%+#6.10f", pamx[i][j] );
+           	    	fprintf( stderr, "\n" );
+           		}
+           		fprintf( stderr, "\n" );
+        	}
+			fprintf( stderr, "done\n" );
+		}
+	
+		for( i=0; i<5; i++ ) 
+		{
+			pamx[4][i] = pamx[3][i];
+			pamx[i][4] = pamx[i][3];
+		}	
+
+		for( i=5; i<10; i++ ) for( j=5; j<10; j++ )
+		{
+			pamx[i][j] = pamx[i-5][j-5];
+		}
+	
+       	if( disp )
+       	{
+       		fprintf( stderr, " before dis\n" );
+          	for( i=0; i<4; i++ )
+   	       	{
+           	   	for( j=0; j<4; j++ )
+           	       	fprintf( stderr, "%+#6.10f", pamx[i][j] );
+           	   	fprintf( stderr, "\n" );
+           	}
+           	fprintf( stderr, "\n" );
+        }
+
+       	if( disp )
+       	{
+        	fprintf( stderr, " score matrix  \n" );
+           	for( i=0; i<4; i++ )
+   	       	{
+               	for( j=0; j<4; j++ )
+                   	fprintf( stderr, "%+#6.10f", pamx[i][j] );
+               	fprintf( stderr, "\n" );
+           	}
+           	fprintf( stderr, "\n" );
+        }
+
+		for( i=0; i<26; i++ ) amino[i] = locaminon[i];
+		for( i=0; i<26; i++ ) amino_grp[(int)amino[i]] = locgrpn[i];
+		for( i=0; i<26; i++ ) for( j=0; j<26; j++ ) n_dis[i][j] = 0;
+		for( i=0; i<10; i++ ) for( j=0; j<10; j++ ) n_dis[i][j] = shishagonyuu( pamx[i][j] );
+        if( disp )
+        {
+            fprintf( stderr, " score matrix  \n" );
+            for( i=0; i<26; i++ )
+            {
+                for( j=0; j<26; j++ )
+                    fprintf( stderr, "%+6d", n_dis[i][j] );
+                fprintf( stderr, "\n" );
+            }
+            fprintf( stderr, "\n" );
+        }
+
+// RIBOSUM
+#if 1
+		average = 0.0;
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+			average += ribosum4[i][j] * freq[i] * freq[j];
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+			ribosum4[i][j] -= average;
+
+		average = 0.0;
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ ) for( k=0; k<4; k++ ) for( m=0; m<4; m++ )
+		{
+//			if( i%4==0&&j%4==3 || i%4==3&&j%4==0 || i%4==1&&j%4==2 || i%4==2&&j%4==1 || i%4==1&&j%4==3 || i%4==3&&j%4==1 )
+//			if( k%4==0&&m%4==3 || k%4==3&&m%4==0 || k%4==1&&m%4==2 || k%4==2&&m%4==1 || k%4==1&&m%4==3 || k%4==3&&m%4==1 )
+				average += ribosum16[i*4+j][k*4+m] * freq[i] * freq[j] * freq[k] * freq[m];
+		}
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ )
+			ribosum16[i][j] -= average;
+
+		average = 0.0;
+		for( i=0; i<4; i++ )
+			average += ribosum4[i][i] * freq[i];
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+			ribosum4[i][j] *= 600.0 / average;
+
+		average = 0.0;
+		average += ribosum16[0*4+3][0*4+3] * freq[0] * freq[3]; // AU
+		average += ribosum16[3*4+0][3*4+0] * freq[3] * freq[0]; // UA
+		average += ribosum16[1*4+2][1*4+2] * freq[1] * freq[2]; // CG
+		average += ribosum16[2*4+1][2*4+1] * freq[2] * freq[1]; // GC
+		average += ribosum16[1*4+3][1*4+3] * freq[1] * freq[3]; // GU
+		average += ribosum16[3*4+1][3*4+1] * freq[3] * freq[1]; // UG
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ )
+			ribosum16[i][j] *= 600.0 / average;
+
+
+#if 1
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+			ribosum4[i][j] -= offset;        /* extending gap cost ?????*/
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ )
+			ribosum16[i][j] -= offset;        /* extending gap cost ?????*/
+#endif
+
+		for( i=0; i<4; i++ ) for( j=0; j<4; j++ )
+			ribosum4[i][j] = shishagonyuu( ribosum4[i][j] );
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ )
+			ribosum16[i][j] = shishagonyuu( ribosum16[i][j] );
+
+  		if( disp )
+   		{
+     		fprintf( stderr, "ribosum after shishagonyuu\n" );
+       		for( i=0; i<4; i++ )
+       		{
+       	    	for( j=0; j<4; j++ )
+       	        	fprintf( stderr, "%+#6.10f", ribosum4[i][j] );
+       	    	fprintf( stderr, "\n" );
+       		}
+       		fprintf( stderr, "\n" );
+     		fprintf( stderr, "ribosum16 after shishagonyuu\n" );
+       		for( i=0; i<16; i++ )
+       		{
+       	    	for( j=0; j<16; j++ )
+       	        	fprintf( stderr, "%+#7.0f", ribosum16[i][j] );
+       	    	fprintf( stderr, "\n" );
+       		}
+       		fprintf( stderr, "\n" );
+      	}
+		fprintf( stderr, "done\n" );
+
+#if 1
+		for( i=0; i<37; i++ ) for( j=0; j<37; j++ ) ribosumdis[i][j] = 0.0; //iru
+		for( m=0; m<9; m++ ) for( i=0; i<4; i++ ) // loop
+			for( k=0; k<9; k++ ) for( j=0; j<4; j++ ) ribosumdis[m*4+i][k*4+j] = ribosum4[i][j]; // loop-loop
+//			for( k=0; k<9; k++ ) for( j=0; j<4; j++ ) ribosumdis[m*4+i][k*4+j] = n_dis[i][j]; // loop-loop
+
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ ) ribosumdis[i+4][j+4] = ribosum16[i][j]; // stem5-stem5
+		for( i=0; i<16; i++ ) for( j=0; j<16; j++ ) ribosumdis[i+20][j+20] = ribosum16[i][j]; // stem5-stem5
+#else // do not use ribosum
+		for( i=0; i<37; i++ ) for( j=0; j<37; j++ ) ribosumdis[i][j] = 0.0; //iru
+		for( m=0; m<9; m++ ) for( i=0; i<4; i++ ) // loop
+			for( k=0; k<9; k++ ) for( j=0; j<4; j++ ) ribosumdis[m*4+i][k*4+j] = n_dis[i][j]; // loop-loop
+#endif
+
+  		if( disp )
+   		{
+     		fprintf( stderr, "ribosumdis\n" );
+       		for( i=0; i<37; i++ )
+       		{
+       	    	for( j=0; j<37; j++ )
+       	        	fprintf( stderr, "%+5d", ribosumdis[i][j] );
+       	    	fprintf( stderr, "\n" );
+       		}
+       		fprintf( stderr, "\n" );
+      	}
+		fprintf( stderr, "done\n" );
+#endif
+
+		FreeDoubleMtx( pam1 );
+		FreeDoubleMtx( pamx );
+		free( freq );
+
+	}
+	else if( dorp == 'p' && scoremtx == 1 )  /* Blosum */
+	{
+		double *freq;
+		double *freq1;
+		double *datafreq;
+		double average;
+//		double tmp;
+		double **n_distmp;
+
+		n_distmp = AllocateDoubleMtx( 20, 20 );
+		datafreq = AllocateDoubleVec( 20 );
+		freq = AllocateDoubleVec( 20 );
+
+		if( ppenalty == NOTSPECIFIED ) ppenalty = DEFAULTGOP_B;
+		if( ppenalty_OP == NOTSPECIFIED ) ppenalty_OP = DEFAULTGOP_B;
+		if( ppenalty_ex == NOTSPECIFIED ) ppenalty_ex = DEFAULTGEP_B;
+		if( ppenalty_EX == NOTSPECIFIED ) ppenalty_EX = DEFAULTGEP_B;
+		if( poffset == NOTSPECIFIED ) poffset = DEFAULTOFS_B;
+		if( pamN == NOTSPECIFIED ) pamN = 0;
+		if( kimuraR == NOTSPECIFIED ) kimuraR = 1;
+		penalty = (int)( 600.0 / 1000.0 * ppenalty + 0.5 );
+		penalty_OP = (int)( 600.0 / 1000.0 * ppenalty_OP + 0.5 );
+		penalty_ex = (int)( 600.0 / 1000.0 * ppenalty_ex + 0.5 );
+		penalty_EX = (int)( 600.0 / 1000.0 * ppenalty_EX + 0.5 );
+		offset = (int)( 600.0 / 1000.0 * poffset + 0.5 );
+		offsetFFT = (int)( 600.0 / 1000.0 * (-0) + 0.5);
+		offsetLN = (int)( 600.0 / 1000.0 * 100 + 0.5);
+		penaltyLN = (int)( 600.0 / 1000.0 * -2000 + 0.5);
+		penalty_exLN = (int)( 600.0 / 1000.0 * -100 + 0.5);
+
+		BLOSUMmtx( nblosum, n_distmp, freq, amino, amino_grp );
+		if( nblosum == -1 )
+			sprintf( modelname, "User-defined, %6.3f, %+6.3f, %+6.3f", -(double)ppenalty/1000, -(double)poffset/1000, -(double)ppenalty_ex/1000 );
+		else
+			sprintf( modelname, "BLOSUM%d, %6.3f, %+6.3f, %+6.3f", nblosum, -(double)ppenalty/1000, -(double)poffset/1000, -(double)ppenalty_ex/1000 );
+#if 0
+		for( i=0; i<26; i++ ) amino[i] = locaminod[i];
+		for( i=0; i<26; i++ ) amino_grp[(int)amino[i]] = locgrpd[i];
+		for( i=0; i<0x80; i++ ) amino_n[i] = 0;
+		for( i=0; i<26; i++ ) amino_n[(int)amino[i]] = i;
+#endif
+		for( i=0; i<0x80; i++ )amino_n[i] = -1;
+		for( i=0; i<26; i++) amino_n[(int)amino[i]] = i;
+		if( fmodel == 1 )
+		{
+			calcfreq( nseq, seq, datafreq );
+			freq1 = datafreq;
+		}
+		else
+			freq1 = freq;
+#if TEST
+		fprintf( stderr, "raw scoreing matrix : \n" );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stdout, "%6.2f", n_distmp[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+		if( fmodel == -1 )
+			average = 0.0;
+		else
+		{
+			for( i=0; i<20; i++ )
+#if TEST 
+				fprintf( stdout, "freq[%c] = %f, datafreq[%c] = %f, freq1[] = %f\n", amino[i], freq[i], amino[i], datafreq[i], freq1[i] );
+#endif
+			average = 0.0;
+			for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+				average += n_distmp[i][j] * freq1[i] * freq1[j];
+		}
+#if TEST
+		fprintf( stdout, "####### average2  = %f\n", average );
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			n_distmp[i][j] -= average;
+#if TEST
+		fprintf( stdout, "average2 = %f\n", average );
+		fprintf( stdout, "after average substruction : \n" );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stdout, "%6.2f", n_distmp[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+		
+		average = 0.0;
+		for( i=0; i<20; i++ ) 
+			average += n_distmp[i][i] * freq1[i];
+#if TEST
+		fprintf( stdout, "####### average1  = %f\n", average );
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			n_distmp[i][j] *= 600.0 / average;
+#if TEST
+        fprintf( stdout, "after average division : \n" );
+        for( i=0; i<20; i++ )
+        {
+            for( j=0; j<=i; j++ )
+            {
+                fprintf( stdout, "%7.1f", n_distmp[i][j] );
+            }
+            fprintf( stdout, "\n" );
+        }
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			n_distmp[i][j] -= offset;  
+#if TEST
+		fprintf( stdout, "after offset substruction (offset = %d): \n", offset );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<=i; j++ ) 
+			{
+				fprintf( stdout, "%7.1f", n_distmp[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+#if 0
+/* Ãí°Õ ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª */
+			penalty -= offset;
+#endif
+
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			n_distmp[i][j] = shishagonyuu( n_distmp[i][j] );
+
+        if( disp )
+        {
+            fprintf( stdout, " scoring matrix  \n" );
+            for( i=0; i<20; i++ )
+            {
+				fprintf( stdout, "%c    ", amino[i] );
+                for( j=0; j<20; j++ )
+                    fprintf( stdout, "%5.0f", n_distmp[i][j] );
+                fprintf( stdout, "\n" );
+            }
+			fprintf( stdout, "     " );
+            for( i=0; i<20; i++ )
+				fprintf( stdout, "    %c", amino[i] );
+
+			average = 0.0;
+        	for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+				average += n_distmp[i][j] * freq1[i] * freq1[j];
+			fprintf( stdout, "average = %f\n", average );
+
+			average = 0.0;
+        	for( i=0; i<20; i++ )
+				average += n_distmp[i][i] * freq1[i];
+			fprintf( stdout, "itch average = %f\n", average );
+			fprintf( stderr, "parameters: %d, %d, %d\n", penalty, penalty_ex, offset );
+
+			
+  			exit( 1 );
+        }
+
+		for( i=0; i<26; i++ ) for( j=0; j<26; j++ ) n_dis[i][j] = 0;
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) n_dis[i][j] = (int)n_distmp[i][j];
+
+		FreeDoubleMtx( n_distmp );
+		FreeDoubleVec( datafreq );
+		FreeDoubleVec( freq );
+
+		fprintf( stderr, "done.\n" );
+
+	}
+	else if( dorp == 'p' && scoremtx == 2 ) /* Miyata-Yasunaga */
+	{
+		fprintf( stderr, "Not supported\n" );
+		exit( 1 );
+		for( i=0; i<26; i++ ) for( j=0; j<26; j++ ) n_dis[i][j] = locn_dism[i][j];
+		for( i=0; i<26; i++ ) if( i != 24 ) n_dis[i][24] = n_dis[24][i] = exgpm;
+		n_dis[24][24] = 0;
+		if( ppenalty == NOTSPECIFIED ) ppenalty = locpenaltym;
+		if( poffset == NOTSPECIFIED ) poffset = -20;
+		if( pamN == NOTSPECIFIED ) pamN = 0;
+		if( kimuraR == NOTSPECIFIED ) kimuraR = 1;
+
+		penalty = ppenalty;
+		offset = poffset;
+
+		sprintf( modelname, "Miyata-Yasunaga, %6.3f, %6.3f", -(double)ppenalty/1000, -(double)poffset/1000 );
+		for( i=0; i<26; i++ ) amino[i] = locaminom[i];
+		for( i=0; i<26; i++ ) amino_grp[(int)amino[i]] = locgrpm[i];
+#if DEBUG
+		fprintf( stdout, "scoreing matrix : \n" );
+		for( i=0; i<26; i++ )
+		{
+			for( j=0; j<26; j++ ) 
+			{
+				fprintf( stdout, "%#5d", n_dis[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+	}
+	else         /* JTT */
+	{
+		double **rsr;
+		double **pam1;
+		double **pamx;
+		double *freq;
+		double *freq1;
+		double *mutab;
+		double *datafreq;
+		double average;
+		double tmp;
+		double delta;
+
+		rsr = AllocateDoubleMtx( 20, 20 );
+		pam1 = AllocateDoubleMtx( 20, 20 );
+		pamx = AllocateDoubleMtx( 20, 20 );
+		freq = AllocateDoubleVec( 20 );
+		mutab = AllocateDoubleVec( 20 );
+		datafreq = AllocateDoubleVec( 20 );
+
+		if( ppenalty == NOTSPECIFIED ) ppenalty = DEFAULTGOP_J;
+		if( ppenalty_OP == NOTSPECIFIED ) ppenalty_OP = DEFAULTGOP_J;
+		if( ppenalty_ex == NOTSPECIFIED ) ppenalty_ex = DEFAULTGEP_J;
+		if( ppenalty_EX == NOTSPECIFIED ) ppenalty_EX = DEFAULTGEP_J;
+		if( poffset == NOTSPECIFIED ) poffset = DEFAULTOFS_J;
+		if( pamN == NOTSPECIFIED )    pamN    = DEFAULTPAMN;
+		if( kimuraR == NOTSPECIFIED ) kimuraR = 1;
+
+		penalty = (int)( 600.0 / 1000.0 * ppenalty + 0.5 );
+		penalty_OP = (int)( 600.0 / 1000.0 * ppenalty_OP + 0.5 );
+		penalty_ex = (int)( 600.0 / 1000.0 * ppenalty_ex + 0.5 );
+		penalty_EX = (int)( 600.0 / 1000.0 * ppenalty_EX + 0.5 );
+		offset = (int)( 600.0 / 1000.0 * poffset + 0.5 );
+		offsetFFT = (int)( 600.0 / 1000.0 * (-0) + 0.5 );
+		offsetLN = (int)( 600.0 / 1000.0 * 100 + 0.5);
+		penaltyLN = (int)( 600.0 / 1000.0 * -2000 + 0.5);
+		penalty_exLN = (int)( 600.0 / 1000.0 * -100 + 0.5);
+
+		sprintf( modelname, "%s %dPAM, %6.3f, %6.3f", (TMorJTT==TM)?"Transmembrane":"JTT", pamN, -(double)ppenalty/1000, -(double)poffset/1000 );
+
+		JTTmtx( rsr, freq, amino, amino_grp, (int)(TMorJTT==TM) );
+
+#if TEST
+		fprintf( stdout, "rsr = \n" );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ )
+			{
+				fprintf( stdout, "%9.2f ", rsr[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+
+		for( i=0; i<0x80; i++ ) amino_n[i] = -1;
+		for( i=0; i<26; i++ ) amino_n[(int)amino[i]] = i;
+
+		if( fmodel == 1 )
+		{
+			calcfreq( nseq, seq, datafreq );
+			freq1 = datafreq;
+		}
+		else
+			freq1 = freq;
+
+		fprintf( stderr, "generating %dPAM %s scoring matrix for amino acids ... ", pamN, (TMorJTT==TM)?"Transmembrane":"JTT" );
+
+		tmp = 0.0;
+		for( i=0; i<20; i++ )
+		{
+			mutab[i] = 0.0;
+			for( j=0; j<20; j++ )
+				mutab[i] += rsr[i][j] * freq[j];
+			tmp += mutab[i] * freq[i];
+		}
+#if TEST
+		fprintf( stdout, "mutability = \n" );
+		for( i=0; i<20; i++ )
+			fprintf( stdout, "%5.3f\n", mutab[i] );
+
+		fprintf( stdout, "tmp = %f\n", tmp );
+#endif
+		delta = 0.01 / tmp;
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ )
+			{
+				if( i != j )
+					pam1[i][j] = delta * rsr[i][j] * freq[i];
+				else
+					pam1[i][j] = 1.0 - delta * mutab[i];
+			}
+		}
+
+		if( disp )
+		{
+			fprintf( stdout, "pam1 = \n" );
+			for( i=0; i<20; i++ )
+			{
+				for( j=0; j<20; j++ )
+				{
+					fprintf( stdout, "%9.6f ", pam1[i][j] );
+				}
+				fprintf( stdout, "\n" );
+			}
+		}
+
+		MtxuntDouble( pamx, 20 );
+		for( x=0; x < pamN; x++ ) MtxmltDouble( pamx, pam1, 20 );
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			pamx[i][j] /= freq[j];
+
+        for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+		{
+			if( pamx[i][j] == 0.0 ) 
+			{
+				fprintf( stderr, "WARNING: pamx[%d][%d] = 0.0?\n", i, j );
+				pamx[i][j] = 0.00001; /* by J. Thompson */
+			}
+            pamx[i][j] = log10( pamx[i][j] ) * 1000.0;
+		}
+ 
+#if TEST
+		fprintf( stdout, "raw scoring matrix : \n" );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stdout, "%5.0f", pamx[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+        average = tmp = 0.0;
+        for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+		{
+           average += pamx[i][j] * freq1[i] * freq1[j];
+		   tmp += freq1[i] * freq1[j];
+		}
+		average /= tmp;
+		fprintf( stdout, "Zenbu average = %f, tmp = %f \n", average, tmp );
+        average = tmp = 0.0;
+        for( i=0; i<20; i++ ) for( j=i; j<20; j++ )
+		{
+           average += pamx[i][j] * freq1[i] * freq1[j];
+		   tmp += freq1[i] * freq1[j];
+		}
+		average /= tmp;
+		fprintf( stdout, "Zenbu average2 = %f, tmp = %f \n", average, tmp );
+		average = tmp = 0.0;
+		for( i=0; i<20; i++ )
+		{
+			average += pamx[i][i] * freq1[i];
+			tmp += freq1[i];
+		}
+		average /= tmp;
+		fprintf( stdout, "Itch average = %f, tmp = %f \n", average, tmp );
+#endif
+
+#if NORMALIZE1
+		if( fmodel == -1 )
+			average = 0.0;
+		else
+		{
+#if TEST
+			for( i=0; i<20; i++ )
+				fprintf( stdout, "freq[%c] = %f, datafreq[%c] = %f, freq1[] = %f\n", amino[i], freq[i], amino[i], datafreq[i], freq1[i] );
+#endif
+			average = 0.0;
+			for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+				average += pamx[i][j] * freq1[i] * freq1[j];
+		}
+#if TEST
+		fprintf( stdout, "####### average2  = %f\n", average );
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			pamx[i][j] -= average;
+#if TEST
+		fprintf( stdout, "average2 = %f\n", average );
+		fprintf( stdout, "after average substruction : \n" );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stdout, "%5.0f", pamx[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+		
+		average = 0.0;
+		for( i=0; i<20; i++ ) 
+			average += pamx[i][i] * freq1[i];
+#if TEST
+		fprintf( stdout, "####### average1  = %f\n", average );
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			pamx[i][j] *= 600.0 / average;
+#if TEST
+        fprintf( stdout, "after average division : \n" );
+        for( i=0; i<20; i++ )
+        {
+            for( j=0; j<=i; j++ )
+            {
+                fprintf( stdout, "%5.0f", pamx[i][j] );
+            }
+            fprintf( stdout, "\n" );
+        }
+#endif
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			pamx[i][j] -= offset;  
+#if TEST
+		fprintf( stdout, "after offset substruction (offset = %d): \n", offset );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<=i; j++ ) 
+			{
+				fprintf( stdout, "%5.0f", pamx[i][j] );
+			}
+			fprintf( stdout, "\n" );
+		}
+#endif
+#if 0
+/* Ãí°Õ ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª */
+			penalty -= offset;
+#endif
+
+
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) 
+			pamx[i][j] = shishagonyuu( pamx[i][j] );
+
+#else
+
+        average = 0.0;
+        for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+           average += pamx[i][j];
+        average /= 400.0;
+
+        for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+        {
+            pamx[i][j] -= average;
+            pamx[i][j] = shishagonyuu( pamx[i][j] );
+        }
+#endif
+        if( disp )
+        {
+            fprintf( stdout, " scoring matrix  \n" );
+            for( i=0; i<20; i++ )
+            {
+				fprintf( stdout, "%c    ", amino[i] );
+                for( j=0; j<20; j++ )
+                    fprintf( stdout, "%5.0f", pamx[i][j] );
+                fprintf( stdout, "\n" );
+            }
+			fprintf( stdout, "     " );
+            for( i=0; i<20; i++ )
+				fprintf( stdout, "    %c", amino[i] );
+
+			average = 0.0;
+        	for( i=0; i<20; i++ ) for( j=0; j<20; j++ )
+				average += pamx[i][j] * freq1[i] * freq1[j];
+			fprintf( stdout, "average = %f\n", average );
+
+			average = 0.0;
+        	for( i=0; i<20; i++ )
+				average += pamx[i][i] * freq1[i];
+			fprintf( stdout, "itch average = %f\n", average );
+			fprintf( stderr, "parameters: %d, %d, %d\n", penalty, penalty_ex, offset );
+
+			
+  			exit( 1 );
+        }
+
+		for( i=0; i<26; i++ ) for( j=0; j<26; j++ ) n_dis[i][j] = 0;
+		for( i=0; i<20; i++ ) for( j=0; j<20; j++ ) n_dis[i][j] = (int)pamx[i][j];
+
+		fprintf( stderr, "done.\n" );
+		FreeDoubleMtx( rsr );
+		FreeDoubleMtx( pam1 );
+		FreeDoubleMtx( pamx );
+		FreeDoubleVec( freq );
+		FreeDoubleVec( mutab );
+		FreeDoubleVec( datafreq );
+	}
+	fprintf( stderr, "scoremtx = %d\n", scoremtx );
+
+#if DEBUG
+	fprintf( stderr, "scoremtx = %d\n", scoremtx );
+	fprintf( stderr, "amino[] = %s\n", amino );
+#endif
+
+	for( i=0; i<0x80; i++ )amino_n[i] = -1;
+	for( i=0; i<26; i++) amino_n[(int)amino[i]] = i;
+    for( i=0; i<0x80; i++ ) for( j=0; j<0x80; j++ ) amino_dis[i][j] = 0;
+    for( i=0; i<0x80; i++ ) for( j=0; j<0x80; j++ ) amino_disLN[i][j] = 0;
+    for( i=0; i<0x80; i++ ) for( j=0; j<0x80; j++ ) amino_dis_consweight_multi[i][j] = 0.0;
+    for( i=0; i<26; i++) for( j=0; j<26; j++ )
+	{
+        amino_dis[(int)amino[i]][(int)amino[j]] = n_dis[i][j];
+		n_dis_consweight_multi[i][j] = (float)n_dis[i][j] * consweight_multi;
+		amino_dis_consweight_multi[(int)amino[i]][(int)amino[j]] = (double)n_dis[i][j] * consweight_multi;
+	}
+
+	if( dorp == 'd' )  /* DNA */
+	{
+	    for( i=0; i<5; i++) for( j=0; j<5; j++ )
+        	amino_disLN[(int)amino[i]][(int)amino[j]] = n_dis[i][j] + offset - offsetLN;
+	    for( i=5; i<10; i++) for( j=5; j<10; j++ )
+        	amino_disLN[(int)amino[i]][(int)amino[j]] = n_dis[i][j] + offset - offsetLN;
+	    for( i=0; i<5; i++) for( j=0; j<5; j++ )
+        	n_disFFT[i][j] = n_dis[i][j] + offset - offsetFFT;
+	    for( i=5; i<10; i++) for( j=5; j<10; j++ )
+        	n_disFFT[i][j] = n_dis[i][j] + offset - offsetFFT;
+	}
+	else // protein
+	{
+	    for( i=0; i<20; i++) for( j=0; j<20; j++ )
+        	amino_disLN[(int)amino[i]][(int)amino[j]] = n_dis[i][j] + offset - offsetLN;
+	    for( i=0; i<20; i++) for( j=0; j<20; j++ )
+        	n_disFFT[i][j] = n_dis[i][j] + offset - offsetFFT;
+	}
+
+#if 0
+		fprintf( stderr, "amino_dis (offset = %d): \n", offset );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stderr, "%5d", amino_dis[(int)amino[i]][(int)amino[j]] );
+			}
+			fprintf( stderr, "\n" );
+		}
+
+		fprintf( stderr, "amino_disLN (offsetLN = %d): \n", offsetLN );
+		for( i=0; i<20; i++ )
+		{
+			for( j=0; j<20; j++ ) 
+			{
+				fprintf( stderr, "%5d", amino_disLN[(int)amino[i]][(int)amino[j]] );
+			}
+			fprintf( stderr, "\n" );
+		}
+
+		fprintf( stderr, "n_dis (offset = %d): \n", offset );
+		for( i=0; i<26; i++ )
+		{
+			for( j=0; j<26; j++ ) 
+			{
+				fprintf( stderr, "%5d", n_dis[i][j] );
+			}
+			fprintf( stderr, "\n" );
+		}
+
+		fprintf( stderr, "n_disFFT (offsetFFT = %d): \n", offsetFFT );
+		for( i=0; i<26; i++ )
+		{
+			for( j=0; j<26; j++ ) 
+			{
+				fprintf( stderr, "%5d", n_disFFT[i][j] );
+			}
+			fprintf( stderr, "\n" );
+		}
+exit( 1 );
+#endif
+
+
+	ppid = 0;
+
+
+	if( fftThreshold == NOTSPECIFIED )
+	{
+		fftThreshold = FFT_THRESHOLD;
+	}
+	if( fftWinSize == NOTSPECIFIED )
+	{
+		if( dorp == 'd' ) 
+			fftWinSize = FFT_WINSIZE_D;
+		else    
+			fftWinSize = FFT_WINSIZE_P;
+	}
+
+
+	if( fftscore )
+	{
+		double av, sd;
+
+		for( i=0; i<20; i++ ) polarity[i] = polarity_[i];
+		for( av=0.0, i=0; i<20; i++ ) av += polarity[i];
+		av /= 20.0;
+		for( sd=0.0, i=0; i<20; i++ ) sd += ( polarity[i]-av ) * ( polarity[i]-av );
+		sd /= 20.0; sd = sqrt( sd );
+		for( i=0; i<20; i++ ) polarity[i] -= av;
+		for( i=0; i<20; i++ ) polarity[i] /= sd;
+	
+		for( i=0; i<20; i++ ) volume[i] = volume_[i];
+		for( av=0.0, i=0; i<20; i++ ) av += volume[i];
+		av /= 20.0;
+		for( sd=0.0, i=0; i<20; i++ ) sd += ( volume[i]-av ) * ( volume[i]-av );
+		sd /= 20.0; sd = sqrt( sd );
+		for( i=0; i<20; i++ ) volume[i] -= av;
+		for( i=0; i<20; i++ ) volume[i] /= sd;
+
+#if 0
+		for( i=0; i<20; i++ ) fprintf( stdout, "amino=%c, pol = %f<-%f, vol = %f<-%f\n", amino[i], polarity[i], polarity_[i], volume[i], volume_[i] );
+		for( i=0; i<20; i++ ) fprintf( stdout, "%c %+5.3f %+5.3f\n", amino[i], volume[i], polarity[i] );
+#endif
+	}
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/defs.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/defs.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/defs.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/defs.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,98 @@
+#include <stdio.h>
+#include "dp.h"
+#include "mltaln.h"
+
+int commonAlloc1 = 0;
+int commonAlloc2 = 0;
+int **commonIP = NULL;
+int **commonJP = NULL;
+
+char modelname[100];
+int njob, nlenmax;
+int amino_n[0x80];
+char amino_grp[0x80];
+int amino_dis[0x80][0x80];
+int amino_disLN[0x80][0x80];
+double amino_dis_consweight_multi[0x80][0x80];
+int n_dis[26][26];
+int n_disFFT[26][26];
+float n_dis_consweight_multi[26][26];
+char amino[26];
+double polarity[20];
+double volume[20];
+int ribosumdis[37][37];
+
+int ppid;
+double thrinter;
+double fastathreshold;
+int pslocal, ppslocal;
+int constraint;
+int divpairscore;
+int fmodel; // 1-> fmodel 0->default -1->raw
+int nblosum; // 45, 50, 62, 80
+int kobetsubunkatsu;
+int bunkatsu;
+int dorp;
+int niter;
+int contin;
+int calledByXced;
+int devide;
+int scmtd;
+int weight;
+int utree;
+int tbutree;
+int refine;
+int check;
+double cut;
+int cooling;
+int penalty, ppenalty, penaltyLN;
+int RNApenalty, RNAppenalty;
+int RNApenalty_ex, RNAppenalty_ex;
+int penalty_ex, ppenalty_ex, penalty_exLN;
+int penalty_EX, ppenalty_EX;
+int penalty_OP, ppenalty_OP;
+int RNAthr, RNApthr;
+int offset, poffset, offsetLN, offsetFFT;
+int scoremtx;
+int TMorJTT;
+char use_fft;
+char force_fft;
+int nevermemsave;
+int fftscore;
+int fftWinSize;
+int fftThreshold;
+int fftRepeatStop;
+int fftNoAnchStop;
+int divWinSize;
+int divThreshold;
+int disp;
+int outgap;
+char alg;
+int cnst;
+int mix;
+int tbitr;
+int tbweight;
+int tbrweight;
+int disopt;
+int pamN;
+int checkC;
+float geta2;
+int treemethod;
+int kimuraR;
+char *swopt;
+int fftkeika;
+int score_check;
+int makedistmtx;
+char *inputfile;
+int rnakozo;
+char rnaprediction;
+
+char *signalSM;
+FILE *prep_g;
+FILE *trap_g;
+char **seq_g;
+char **res_g;
+
+float consweight_multi = 1.0;
+float consweight_rna = 0.0;
+char RNAscoremtx = 'n';

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/dp.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/dp.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/dp.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/dp.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,4 @@
+extern int commonAlloc1;
+extern int commonAlloc2;
+extern int **commonIP;
+extern int **commonJP;

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/fft.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/fft.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/fft.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/fft.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,118 @@
+#include "mltaln.h"
+#include "mtxutl.h"
+
+/*
+  {\tt fft()}.
+*/
+static void make_sintbl(int n, float sintbl[])
+{
+        int i, n2, n4, n8;
+        double c, s, dc, ds, t;
+
+        n2 = n / 2;  n4 = n / 4;  n8 = n / 8;
+        t = sin(PI / n);
+        dc = 2 * t * t;  ds = sqrt(dc * (2 - dc));
+        t = 2 * dc;  c = sintbl[n4] = 1;  s = sintbl[0] = 0;
+        for (i = 1; i < n8; i++) {
+                c -= dc;  dc += t * c;
+                s += ds;  ds -= t * s;
+                sintbl[i] = s;  sintbl[n4 - i] = c;
+        }
+        if (n8 != 0) sintbl[n8] = sqrt(0.5);
+        for (i = 0; i < n4; i++)
+                sintbl[n2 - i] = sintbl[i];
+        for (i = 0; i < n2 + n4; i++)
+                sintbl[i + n2] = - sintbl[i];
+}
+/*
+  {\tt fft()}.
+*/
+static void make_bitrev(int n, int bitrev[])
+{
+        int i, j, k, n2;
+
+        n2 = n / 2;  i = j = 0;
+        for ( ; ; ) {
+                bitrev[i] = j;
+                if (++i >= n) break;
+                k = n2;
+                while (k <= j) {  j -= k;  k /= 2;  }
+                j += k;
+        }
+}
+/*
+*/
+int fft(int n, Fukusosuu *x, int dum)
+{
+        static int    last_n = 0;    /*  {\tt n} */
+        static int   *bitrev = NULL; /*  */
+        static float *sintbl = NULL; /*  */
+        int i, j, k, ik, h, d, k2, n4, inverse;
+        float t, s, c, dR, dI;
+
+        /*  */
+        if (n < 0) {
+                n = -n;  inverse = 1;  /*  */
+        } else inverse = 0;
+        n4 = n / 4;
+        if (n != last_n || n == 0) {
+                last_n = n;
+#if 0
+                if (sintbl != NULL) {
+					free(sintbl);
+					sintbl = NULL;
+				}
+                if (bitrev != NULL) {
+					free(bitrev);
+					bitrev = NULL;
+				}
+                if (n == 0) return 0;  /*  */
+                sintbl = (float *)malloc((n + n4) * sizeof(float));
+                bitrev = (int *)malloc(n * sizeof(int));
+#else /* by T. Nishiyama */
+				sintbl = realloc(sintbl, (n + n4) * sizeof(float));
+				bitrev = realloc(bitrev, n * sizeof(int));
+#endif
+                if (sintbl == NULL || bitrev == NULL) {
+                        fprintf(stderr, "\n");  return 1;
+                }
+                make_sintbl(n, sintbl);
+                make_bitrev(n, bitrev);
+        }
+        for (i = 0; i < n; i++) {    /*  */
+                j = bitrev[i];
+                if (i < j) {
+                        t = x[i].R;  x[i].R = x[j].R;  x[j].R = t;
+                        t = x[i].I;  x[i].I = x[j].I;  x[j].I = t;
+                }
+        }
+        for (k = 1; k < n; k = k2) {    /*  */
+#if 0
+				fprintf( stderr, "%d / %d\n", k, n );
+#endif
+                h = 0;  k2 = k + k;  d = n / k2;
+                for (j = 0; j < k; j++) {
+#if 0
+					if( j % 1 == 0 )
+						fprintf( stderr, "%d / %d\r", j, k );
+#endif
+                        c = sintbl[h + n4];
+                        if (inverse) s = - sintbl[h];
+                        else         s =   sintbl[h];
+                        for (i = j; i < n; i += k2) {
+#if 0
+								if( k>=4194000 ) fprintf( stderr, "in loop %d -  %d < %d, k2=%d\r", j, i, n, k2 );
+#endif
+                                ik = i + k;
+                                dR = s * x[ik].I + c * x[ik].R;
+                                dI = c * x[ik].I - s * x[ik].R;
+                                x[ik].R = x[i].R - dR;  x[i].R += dR;
+                                x[ik].I = x[i].I - dI;  x[i].I += dI;
+                        }
+                        h += d;
+                }
+        }
+        if (! inverse)    /* n */
+                for (i = 0; i < n; i++) {  x[i].R /= n;  x[i].I /= n;  }
+        return 0;  /*  */
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/fft.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/fft.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/fft.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/fft.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <math.h>
+#include "mtxutl.h"
+
+#define PI 3.14159265358979323846
+#define END_OF_VEC -1
+
+#define NKOUHO   20
+#define NKOUHO_LONG   100
+
+#define MAX(X,Y)    ( ((X)>(Y))?(X):(Y) )
+#define MIN(X,Y)    ( ((X)<(Y))?(X):(Y) )
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/fftFunctions.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/fftFunctions.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/fftFunctions.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/fftFunctions.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,839 @@
+#include "mltaln.h"
+
+#define SEGMENTSIZE 150
+#define TMPTMPTMP 0
+
+#define DEBUG 0
+
+void keika( char *str, int current, int all )
+{
+	if( current == 0 )
+		fprintf( stderr, "%s :         ", str );
+
+		fprintf( stderr, "\b\b\b\b\b\b\b\b" );
+		fprintf( stderr, "%3d /%3d", current+1, all+1 );
+
+	if( current+1 == all )
+		fprintf( stderr, "\b\b\b\b\b\b\b\bdone.     \n" );
+}
+
+double maxItch( double *soukan, int size )
+{
+	int i;
+	double value = 0.0;
+	double cand;
+	for( i=0; i<size; i++ ) 
+		if( ( cand = soukan[i] ) > value ) value = cand;
+	return( value );
+}
+
+void calcNaiseki( Fukusosuu *value, Fukusosuu *x, Fukusosuu *y )
+{
+	value->R =  x->R * y->R + x->I * y->I;
+	value->I = -x->R * y->I + x->I * y->R;
+}
+
+Fukusosuu *AllocateFukusosuuVec( int l1 )
+{
+	Fukusosuu *value;
+	value = (Fukusosuu *)calloc( l1, sizeof( Fukusosuu ) );
+	if( !value )
+	{
+		fprintf( stderr, "Cannot allocate %d FukusosuuVec\n", l1 );
+		return( NULL );
+	}
+	return( value );
+}
+	
+Fukusosuu **AllocateFukusosuuMtx( int l1, int l2 )
+{
+	Fukusosuu **value;
+	int j;
+//	fprintf( stderr, "allocating %d x %d FukusosuuMtx\n", l1, l2 );
+	value = (Fukusosuu **)calloc( l1+1, sizeof( Fukusosuu * ) );
+	if( !value ) 
+	{
+		fprintf( stderr, "Cannot allocate %d x %d FukusosuuVecMtx\n", l1, l2 );
+		exit( 1 );
+	}
+	for( j=0; j<l1; j++ ) 
+	{
+		value[j] = AllocateFukusosuuVec( l2 );
+		if( !value[j] )
+		{
+			fprintf( stderr, "Cannot allocate %d x %d FukusosuuVecMtx\n", l1, l2 );
+			exit( 1 );
+		}
+	}
+	value[l1] = NULL;
+	return( value );
+}
+
+Fukusosuu ***AllocateFukusosuuCub( int l1, int l2, int l3 )
+{
+	Fukusosuu ***value;
+	int i;
+	value = calloc( l1+1, sizeof( Fukusosuu ** ) );
+	if( !value ) ErrorExit( "Cannot allocate Fukusosuu" );
+	for( i=0; i<l1; i++ ) value[i] = AllocateFukusosuuMtx( l2, l3 );
+	value[l1] = NULL;
+	return( value );
+}
+
+void FreeFukusosuuVec( Fukusosuu *vec )
+{
+	free( (void *)vec );
+}
+
+void FreeFukusosuuMtx( Fukusosuu **mtx )
+{
+	int i;
+
+	for( i=0; mtx[i]; i++ ) 
+		free( (void *)mtx[i] );
+	free( (void *)mtx );
+}
+
+int getKouho( int *kouho, int nkouho, double *soukan, int nlen2 )
+{
+	int i, j;
+	int nlen4 = nlen2 / 2;
+	double max;
+	double tmp;
+	int ikouho = 0; // by D.Mathog, iinoka?
+	for( j=0; j<nkouho; j++ ) 
+	{
+		max = -9999.9;
+		for( i=0; i<nlen2; i++ ) 
+		{
+			if( ( tmp = soukan[i] ) > max )
+			{
+				ikouho = i;
+				max = tmp;
+			}
+		}
+#if 0
+		if( max < 0.15 )
+		{
+			break;
+		}
+#endif
+#if 0
+		fprintf( stderr, "Kouho No.%d, pos=%d, score=%f, lag=%d\n", j, ikouho, soukan[ikouho], ikouho-nlen4 );
+#endif
+		soukan[ikouho] = -9999.9;
+		kouho[j] = ( ikouho - nlen4 );
+	}
+	return( j );
+}
+
+void zurasu2( int lag, int    clus1, int    clus2, 
+                       char  **seq1, char  **seq2, 
+		 			   char **aseq1, char **aseq2 )
+{
+	int i;
+#if 0
+	fprintf( stderr, "### lag = %d\n", lag );
+#endif
+	if( lag > 0 )
+	{
+		for( i=0; i<clus1; i++ ) aseq1[i] = seq1[i];
+		for( i=0; i<clus2; i++ ) aseq2[i] = seq2[i]+lag;
+	}
+	else
+	{
+		for( i=0; i<clus1; i++ ) aseq1[i] = seq1[i]-lag;
+		for( i=0; i<clus2; i++ ) aseq2[i] = seq2[i];
+	}
+}
+
+void zurasu( int lag, int    clus1, int    clus2, 
+                      char  **seq1, char  **seq2, 
+					  char **aseq1, char **aseq2 )
+{
+	int i;
+#if DEBUG
+	fprintf( stderr, "lag = %d\n", lag );
+#endif
+	if( lag > 0 )
+	{
+		for( i=0; i<clus1; i++ ) strcpy( aseq1[i], seq1[i] );
+		for( i=0; i<clus2; i++ ) strcpy( aseq2[i], seq2[i]+lag );
+	}
+	else
+	{
+		for( i=0; i<clus1; i++ ) strcpy( aseq1[i], seq1[i]-lag );
+		for( i=0; i<clus2; i++ ) strcpy( aseq2[i], seq2[i] );
+	}
+}
+
+
+int alignableReagion( int    clus1, int    clus2, 
+					   char  **seq1, char  **seq2,
+					   double *eff1, double *eff2,
+					   Segment *seg )
+{
+	int i, j, k;
+	int status, starttmp = 0; // by D.Mathog, a gess
+	double score;
+	int value = 0;
+	int len, maxlen;
+	int length = 0; // by D.Mathog, a gess
+	static double *stra = NULL;
+	static int alloclen = 0;
+	double totaleff;
+	double cumscore;
+	static double threshold;
+	static double prf1[26], prf2[26];
+	static int hat1[27], hat2[27];
+	int pre1, pre2;
+#if 0
+	char **seq1pt;
+	char **seq2pt;
+	double *eff1pt;
+	double *eff2pt;
+#endif
+
+#if 0
+	fprintf( stderr, "### In alignableRegion, clus1=%d, clus2=%d \n", clus1, clus2 );
+	fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
+	fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
+	fprintf( stderr, "eff1[0] = %f\n", eff1[0] );
+	fprintf( stderr, "eff2[0] = %f\n", eff2[0] );
+#endif
+
+	len = MIN( strlen( seq1[0] ), strlen( seq2[0] ) );
+	maxlen = MAX( strlen( seq1[0] ), strlen( seq2[0] ) ) + fftWinSize;
+	if( alloclen < maxlen )
+	{
+		if( alloclen )
+		{
+			FreeDoubleVec( stra );
+		}
+		else
+		{
+			threshold = (int)fftThreshold / 100.0 * 600.0 * fftWinSize;
+		}
+		stra = AllocateDoubleVec( maxlen );
+		alloclen = maxlen;
+	}
+
+
+	totaleff = 0.0;
+	for( i=0; i<clus1; i++ ) for( j=0; j<clus2; j++ ) totaleff += eff1[i] * eff2[j];
+	for( i=0; i<len; i++ )
+	{
+		/* make prfs */
+		for( j=0; j<26; j++ )
+		{
+			prf1[j] = 0.0;
+			prf2[j] = 0.0;
+		}
+#if 0
+		seq1pt = seq1;
+		eff1pt = eff1;
+		j = clus1;
+		while( j-- ) prf1[amino_n[(*seq1pt++)[i]]] += *eff1pt++;
+#else
+		for( j=0; j<clus1; j++ ) prf1[amino_n[(int)seq1[j][i]]] += eff1[j];
+#endif
+		for( j=0; j<clus2; j++ ) prf2[amino_n[(int)seq2[j][i]]] += eff2[j];
+
+		/* make hats */
+		pre1 = pre2 = 26;
+		for( j=25; j>=0; j-- )
+		{
+			if( prf1[j] )
+			{
+				hat1[pre1] = j;
+				pre1 = j;
+			}
+			if( prf2[j] )
+			{
+				hat2[pre2] = j;
+				pre2 = j;
+			}
+		}
+		hat1[pre1] = -1;
+		hat2[pre2] = -1;
+
+		/* make site score */
+		stra[i] = 0.0;
+		for( k=hat1[26]; k!=-1; k=hat1[k] ) 
+			for( j=hat2[26]; j!=-1; j=hat2[j] ) 
+//				stra[i] += n_dis[k][j] * prf1[k] * prf2[j];
+				stra[i] += n_disFFT[k][j] * prf1[k] * prf2[j];
+		stra[i] /= totaleff;
+	}
+
+	(seg+0)->skipForeward = 0;
+	(seg+1)->skipBackward = 0;
+	status = 0;
+	cumscore = 0.0;
+	score = 0.0;
+	for( j=0; j<fftWinSize; j++ ) score += stra[j];
+
+	for( i=1; i<len-fftWinSize; i++ )
+	{
+		score = score - stra[i-1] + stra[i+fftWinSize-1];
+#if TMPTMPTMP
+		fprintf( stderr, "%d %10.0f   ? %10.0f\n", i, score, threshold );
+#endif
+
+		if( score > threshold )
+		{
+#if 0
+			seg->start = i;
+			seg->end = i;
+			seg->center = ( seg->start + seg->end + fftWinSize ) / 2 ;
+			seg->score = score;
+			status = 0;
+			value++;
+#else
+			if( !status )
+			{
+				status = 1;
+				starttmp = i;
+				length = 0;
+				cumscore = 0.0;
+			}
+			length++;
+			cumscore += score;
+#endif
+		}
+		if( score <= threshold || length > SEGMENTSIZE )
+		{
+			if( status )
+			{
+				if( length > fftWinSize )
+				{
+					seg->start = starttmp;
+					seg->end = i;
+					seg->center = ( seg->start + seg->end + fftWinSize ) / 2 ;
+					seg->score = cumscore;
+#if 0
+					fprintf( stderr, "%d-%d length = %d, score = %f, value = %d\n", seg->start, seg->end, length, cumscore, value );
+#endif
+					if( length > SEGMENTSIZE )
+					{
+						(seg+0)->skipForeward = 1;
+						(seg+1)->skipBackward = 1;
+					}
+					else
+					{
+						(seg+0)->skipForeward = 0;
+						(seg+1)->skipBackward = 0;
+					}
+					value++;
+					seg++;
+				}
+				length = 0;
+				cumscore = 0.0;
+				status = 0;
+				starttmp = i;
+				if( value > MAXSEG - 3 ) ErrorExit( "TOO MANY SEGMENTS!");
+			}
+		}
+	}
+	if( status && length > fftWinSize )
+	{
+		seg->end = i;
+		seg->start = starttmp;
+		seg->center = ( starttmp + i + fftWinSize ) / 2 ;
+		seg->score = cumscore;
+#if 0
+fprintf( stderr, "%d-%d length = %d\n", seg->start, seg->end, length );
+#endif
+		value++;
+	}
+#if TMPTMPTMP
+	exit( 0 );
+#endif
+//	fprintf( stderr, "returning %d\n", value );
+	return( value );
+}
+
+void blockAlign( int *cut1, int *cut2, double **ocrossscore, int *ncut )
+{
+	int i, j, shift, cur1, cur2, count;
+	static int result1[MAXSEG], result2[MAXSEG];
+	static int ocut1[MAXSEG], ocut2[MAXSEG];
+	double maximum;
+	static double max[MAXSEG], maxi;
+	static double point[MAXSEG], pointi;
+	static double **crossscore = NULL;
+	static int **track = NULL;
+
+	if( crossscore == NULL )
+	{
+		crossscore = AllocateDoubleMtx( MAXSEG, MAXSEG );
+		track = AllocateIntMtx( MAXSEG, MAXSEG );
+	}
+
+#if 0
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%#4.0f ", ocrossscore[i][j]/100 );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+	for( i=0; i<*ncut; i++ ) for( j=0; j<*ncut; j++ )  /* mudadanaa */
+		crossscore[i][j] = ocrossscore[i][j];
+	for( i=0; i<*ncut; i++ ) 
+	{
+		ocut1[i] = cut1[i];
+		ocut2[i] = cut2[i];
+	}
+
+	for( j=0; j<*ncut; j++ )
+	{
+		max[j] = 0.0;
+		point[j] = 0;
+	}
+
+	for( i=1; i<*ncut; i++ )
+	{
+		maxi = 0.0;
+		pointi = 0;
+		for( j=1; j<*ncut; j++ )
+		{
+			maximum = crossscore[i-1][j-1];
+			track[i][j] = 0;
+
+			if( maximum < max[j] + penalty )
+			{
+				maximum = max[j] + penalty;
+				track[i][j] = point[j] - i;
+			}
+			if( maximum < maxi + penalty )
+			{
+				maximum = maxi + penalty;
+				track[i][j] = j - pointi;
+			}
+			crossscore[i][j] += maximum;
+
+			if( maxi < crossscore[i-1][j-1] )
+			{
+				maxi = crossscore[i-1][j-1];
+				pointi = j-1;
+			}
+			if( max[j] < crossscore[i-1][j-1] )
+			{
+				max[j] = crossscore[i-1][j-1];
+				point[j] = i-1;
+			}
+		}
+	}
+#if 1
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%3d ", track[i][j] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+
+	result1[MAXSEG-1] = *ncut-1;
+	result2[MAXSEG-1] = *ncut-1;
+
+	for( i=MAXSEG-1; i>=1; i-- )
+	{
+		cur1 = result1[i];
+		cur2 = result2[i];
+		if( cur1 == 0 || cur2 == 0 ) break;
+		shift = track[cur1][cur2];
+		if( shift == 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - 1;
+			continue;
+		}
+		else if( shift > 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - shift;
+		}
+		else if( shift < 0 )
+		{
+			result1[i-1] = cur1 + shift;
+			result2[i-1] = cur2 - 1;
+		}
+	}
+
+	count = 0;
+	for( j=i; j<MAXSEG; j++ )
+	{
+		if( ocrossscore[result1[j]][result2[j]] == 0.0 ) continue;
+
+		if( result1[j] == result1[j-1] || result2[j] == result2[j-1] )
+			if( ocrossscore[result1[j]][result2[j]] > ocrossscore[result1[j-1]][result2[j-1]] )
+				count--;
+				
+		cut1[count] = ocut1[result1[j]];
+		cut2[count] = ocut2[result2[j]];
+		count++;
+	}
+
+	*ncut = count;
+#if 0
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+#endif
+}
+
+static int permit( Segment *seg1, Segment *seg2 )
+{
+	return( 0 );
+	if( seg1->end >= seg2->start ) return( 0 );
+	if( seg1->pair->end >= seg2->pair->start ) return( 0 );
+	else return( 1 );
+}
+
+void blockAlign2( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut )
+{
+	int i, j, k, shift, cur1, cur2, count, klim;
+	static int crossscoresize = 0;
+	static int result1[MAXSEG], result2[MAXSEG];
+	static int ocut1[MAXSEG], ocut2[MAXSEG];
+	double maximum;
+	static double **crossscore = NULL;
+	static int **track = NULL;
+	static double maxj, maxi;
+	static int pointj, pointi;
+
+
+    if( crossscoresize < *ncut+2 )
+    {
+        crossscoresize = *ncut+2;
+		if( fftkeika ) fprintf( stderr, "allocating crossscore and track, size = %d\n", crossscoresize );
+		if( track ) FreeIntMtx( track );
+        if( crossscore ) FreeDoubleMtx( crossscore );
+		track = AllocateIntMtx( crossscoresize, crossscoresize );
+        crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
+    }
+
+#if 0
+	for( i=0; i<*ncut-2; i++ )
+		fprintf( stderr, "%d.start = %d, score = %f\n", i, seg1[i]->start, seg1[i]->score );
+
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%#4.0f ", ocrossscore[i][j] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+	for( i=0; i<*ncut; i++ ) for( j=0; j<*ncut; j++ )  /* mudadanaa */
+		crossscore[i][j] = ocrossscore[i][j];
+	for( i=0; i<*ncut; i++ ) 
+	{
+		ocut1[i] = cut1[i];
+		ocut2[i] = cut2[i];
+	}
+
+	for( i=1; i<*ncut; i++ )
+	{
+#if 0
+		fprintf( stderr, "### i=%d/%d\n", i,*ncut );
+#endif
+		for( j=1; j<*ncut; j++ )
+		{
+			pointi = 0; maxi = 0.0;
+			klim = j-2;
+			for( k=0; k<klim; k++ )
+			{
+/*
+				fprintf( stderr, "k=%d, i=%d\n", k, i );
+*/
+				if( k && k<*ncut-1 && j<*ncut-1 && !permit( seg1[k-1], seg1[j-1] ) ) continue;
+				if( crossscore[i-1][k] > maxj )
+				{
+					pointi = k;
+					maxi = crossscore[i-1][k];
+				}
+			}
+
+			pointj = 0; maxj = 0.0;
+			klim = i-2;
+			for( k=0; k<klim; k++ )
+			{
+				if( k && k<*ncut-1 && i<*ncut-1 && !permit( seg2[k-1], seg2[i-1] ) ) continue;
+				if( crossscore[k][j-1] > maxj )
+				{
+					pointj = k;
+					maxj = crossscore[k][j-1];
+				}
+			}	
+
+			maxi += penalty;
+			maxj += penalty;
+
+			maximum = crossscore[i-1][j-1];
+			track[i][j] = 0;
+
+			if( maximum < maxi )
+			{
+				maximum = maxi ;
+				track[i][j] = j - pointi;
+			}
+
+			if( maximum < maxj )
+			{
+				maximum = maxj ;
+				track[i][j] = pointj - i;
+			}
+
+			crossscore[i][j] += maximum;
+		}
+	}
+#if 0
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%3d ", track[i][j] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+
+	result1[MAXSEG-1] = *ncut-1;
+	result2[MAXSEG-1] = *ncut-1;
+
+	for( i=MAXSEG-1; i>=1; i-- )
+	{
+		cur1 = result1[i];
+		cur2 = result2[i];
+		if( cur1 == 0 || cur2 == 0 ) break;
+		shift = track[cur1][cur2];
+		if( shift == 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - 1;
+			continue;
+		}
+		else if( shift > 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - shift;
+		}
+		else if( shift < 0 )
+		{
+			result1[i-1] = cur1 + shift;
+			result2[i-1] = cur2 - 1;
+		}
+	}
+
+	count = 0;
+	for( j=i; j<MAXSEG; j++ )
+	{
+		if( ocrossscore[result1[j]][result2[j]] == 0.0 ) continue;
+
+		if( result1[j] == result1[j-1] || result2[j] == result2[j-1] )
+			if( ocrossscore[result1[j]][result2[j]] > ocrossscore[result1[j-1]][result2[j-1]] )
+				count--;
+				
+		cut1[count] = ocut1[result1[j]];
+		cut2[count] = ocut2[result2[j]];
+
+		count++;
+	}
+
+	*ncut = count;
+#if 0
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+#endif
+}
+void blockAlign3( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut )
+// memory complexity = O(n^3), time complexity = O(n^2)
+{
+	int i, j, shift, cur1, cur2, count;
+	static int crossscoresize = 0;
+	static int jumpposi, *jumppos;
+	static double jumpscorei, *jumpscore;
+	static int result1[MAXSEG], result2[MAXSEG];
+	static int ocut1[MAXSEG], ocut2[MAXSEG];
+	double maximum;
+	static double **crossscore = NULL;
+	static int **track = NULL;
+
+    if( crossscoresize < *ncut+2 )
+    {
+        crossscoresize = *ncut+2;
+		if( fftkeika ) fprintf( stderr, "allocating crossscore and track, size = %d\n", crossscoresize );
+		if( track ) FreeIntMtx( track );
+        if( crossscore ) FreeDoubleMtx( crossscore );
+        if( jumppos ) FreeIntVec( jumppos );
+        if( jumpscore ) FreeDoubleVec( jumpscore );
+		track = AllocateIntMtx( crossscoresize, crossscoresize );
+        crossscore = AllocateDoubleMtx( crossscoresize, crossscoresize );
+        jumppos = AllocateIntVec( crossscoresize );
+        jumpscore = AllocateDoubleVec( crossscoresize );
+    }
+
+#if 0
+	for( i=0; i<*ncut-2; i++ )
+		fprintf( stderr, "%d.start = %d, score = %f\n", i, seg1[i]->start, seg1[i]->score );
+
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%#4.0f ", ocrossscore[i][j] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+	for( i=0; i<*ncut; i++ ) for( j=0; j<*ncut; j++ )  /* mudadanaa */
+		crossscore[i][j] = ocrossscore[i][j];
+	for( i=0; i<*ncut; i++ ) 
+	{
+		ocut1[i] = cut1[i];
+		ocut2[i] = cut2[i];
+	}
+	for( j=0; j<*ncut; j++ )
+	{
+		jumpscore[j] = -999.999;
+		jumppos[j] = -1;
+	}
+
+	for( i=1; i<*ncut; i++ )
+	{
+
+		jumpscorei = -999.999;
+		jumpposi = -1;
+
+		for( j=1; j<*ncut; j++ )
+		{
+#if 1
+			fprintf( stderr, "in blockalign3, ### i=%d, j=%d\n", i, j );
+#endif
+
+
+#if 0
+			for( k=0; k<j-2; k++ )
+			{
+/*
+				fprintf( stderr, "k=%d, i=%d\n", k, i );
+*/
+				if( k && k<*ncut-1 && j<*ncut-1 && !permit( seg1[k-1], seg1[j-1] ) ) continue;
+				if( crossscore[i-1][k] > maxj )
+				{
+					pointi = k;
+					maxi = crossscore[i-1][k];
+				}
+			}
+
+			pointj = 0; maxj = 0.0;
+			for( k=0; k<i-2; k++ )
+			{
+				if( k && k<*ncut-1 && i<*ncut-1 && !permit( seg2[k-1], seg2[i-1] ) ) continue;
+				if( crossscore[k][j-1] > maxj )
+				{
+					pointj = k;
+					maxj = crossscore[k][j-1];
+				}
+			}	
+
+
+			maxi += penalty;
+			maxj += penalty;
+#endif
+			maximum = crossscore[i-1][j-1];
+			track[i][j] = 0;
+
+			if( maximum < jumpscorei && permit( seg1[jumpposi], seg1[i] ) )
+			{
+				maximum = jumpscorei;
+				track[i][j] = j - jumpposi;
+			}
+
+			if( maximum < jumpscore[j] && permit( seg2[jumppos[j]], seg2[j] ) )
+			{
+				maximum = jumpscore[j];
+				track[i][j] = jumpscore[j] - i;
+			}
+
+			crossscore[i][j] += maximum;
+
+			if( jumpscorei < crossscore[i-1][j] )
+			{
+				jumpscorei = crossscore[i-1][j];
+				jumpposi = j;
+			}
+
+			if( jumpscore[j] < crossscore[i][j-1] )
+			{
+				jumpscore[j] = crossscore[i][j-1];
+				jumppos[j] = i;
+			}
+		}
+	}
+#if 0
+	for( i=0; i<*ncut; i++ ) 
+	{
+		for( j=0; j<*ncut; j++ )
+			fprintf( stderr, "%3d ", track[i][j] );
+		fprintf( stderr, "\n" );
+	}
+#endif
+
+
+	result1[MAXSEG-1] = *ncut-1;
+	result2[MAXSEG-1] = *ncut-1;
+
+	for( i=MAXSEG-1; i>=1; i-- )
+	{
+		cur1 = result1[i];
+		cur2 = result2[i];
+		if( cur1 == 0 || cur2 == 0 ) break;
+		shift = track[cur1][cur2];
+		if( shift == 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - 1;
+			continue;
+		}
+		else if( shift > 0 )
+		{
+			result1[i-1] = cur1 - 1;
+			result2[i-1] = cur2 - shift;
+		}
+		else if( shift < 0 )
+		{
+			result1[i-1] = cur1 + shift;
+			result2[i-1] = cur2 - 1;
+		}
+	}
+
+	count = 0;
+	for( j=i; j<MAXSEG; j++ )
+	{
+		if( ocrossscore[result1[j]][result2[j]] == 0.0 ) continue;
+
+		if( result1[j] == result1[j-1] || result2[j] == result2[j-1] )
+			if( ocrossscore[result1[j]][result2[j]] > ocrossscore[result1[j-1]][result2[j-1]] )
+				count--;
+				
+		cut1[count] = ocut1[result1[j]];
+		cut2[count] = ocut2[result2[j]];
+
+		count++;
+	}
+
+	*ncut = count;
+#if 0
+	for( i=0; i<*ncut; i++ )
+		fprintf( stderr, "i=%d, cut1 = %d, cut2 = %d\n", i, cut1[i], cut2[i] );
+#endif
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/functions.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/functions.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/functions.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/functions.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,293 @@
+extern int intlen( int *num );
+extern char seqcheck( char **seq );
+extern void scmx_calc( int icyc, char **aseq, double *effarr, float **scmx );
+extern void exitall( char arr[] );
+extern void display( char **seq, int nseq );
+extern void intergroup_score( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
+extern void intergroup_score_gapnomi( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
+extern void intergroup_score_new( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value );
+extern double score_calc3( char **seq, int s, double **eff, int ex );
+extern double score_calc5( char **seq, int s, double **eff, int ex );
+extern double score_calc4( char **seq, int s, double **eff, int ex );
+extern void upg2( int nseq, double **eff, int ***topol, double **len );
+//extern void veryfastsupg_float_realloc_nobk_halfmtx( int njob, float **mtx, int ***topol, float **len );
+//extern void veryfastsupg_float_realloc_nobk( int njob, float **mtx, int ***topol, float **len );
+extern void veryfastsupg_int_realloc_nobk( int njob, int **mtx, int ***topol, double **len );
+extern void veryfastsupg( int nseq, double **oeff, int ***topol, double **len );
+extern void veryfastsupg_double( int nseq, double **oeff, int ***topol, double **len );
+extern void veryfastsupg_double_loadtree( int nseq, double **oeff, int ***topol, double **len );
+extern void veryfastsupg_double_loadtop( int nseq, double **oeff, int ***topol, double **len );
+extern void veryfastsupg_int( int nseq, int **oeff, int ***topol, double **len );
+extern void fastsupg( int nseq, double **oeff, int ***topol, double **len );
+extern void supg( int nseq, double **oeff, int ***topol, double **len );
+extern void spg( int nseq, double **oeff, int ***topol, double **len );
+extern double ipower( double x, int n );
+extern void countnode( int nseq, int ***topol, double **node );
+extern void countnode_int( int nseq, int ***topol, int **node );
+extern void counteff_simple( int nseq, int ***topol, double **len, double *node );
+extern void counteff_simple_float( int nseq, int ***topol, float **len, double *node );
+extern void counteff( int nseq, int ***topol, double **len, double **node );
+extern float score_calc1( char *seq1, char *seq2 );
+extern float score_calcp( char *seq1, char *seq2, int len );
+extern float substitution_nid( char *seq1, char *seq2 );
+extern float substitution_score( char *seq1, char *seq2 );
+extern float substitution_hosei( char *seq1, char *seq2 );
+extern float substitution( char *seq1, char *seq2 );
+extern void treeconstruction( char **seq, int nseq, int ***topol, double **len, double **eff );
+extern float bscore_calc( char **seq, int s, double **eff );
+extern void AllocateTmpSeqs( char ***mseq2pt, char **mseq1pt, int locnlenmax );
+extern void FreeTmpSeqs( char **mseq2, char *mseq1 );
+extern void gappick0( char *aseq, char *seq );
+extern void gappick( int nseq, int s, char **aseq, char **mseq2, 
+					 double **eff, double *effarr );
+extern void commongappick_record( int nseq, char **seq, int *map );
+extern void commongappick( int nseq, char **seq );
+extern double score_calc0( char **seq, int s, double **eff, int ex );
+extern void strins( char *str1, char *str2 );
+extern int isaligned( int nseq, char **seq );
+extern double score_calc_for_score( int nseq, char **seq );
+extern void floatncpy( float *vec1, float *vec2, int len );
+extern float score_calc_a( char **seq, int s, double **eff );
+extern float score_calc_s( char **seq, int s, double **eff );
+extern double score_calc_for_score_s( int s, char **seq );
+extern double SSPscore( int s, char **seq );
+extern double DSPscore( int s, char **seq );
+extern int searchAnchors( int nseq, char **seq, Segment *seg );
+extern char *progName( char *str );
+extern void dontcalcimportance( int nseq, double *eff, char **seq, LocalHom **localhom );
+extern void calcimportance( int nseq, double *eff, char **seq, LocalHom **localhom );
+extern void weightimportance2( int nseq, double *eff, LocalHom **localhom );
+extern void weightimportance4( int clus1, int clus2, double *eff1, double *eff2, LocalHom ***localhom );
+extern void extendlocalhom( int nseq, LocalHom **localhom );
+extern void extendlocalhom2( int nseq, LocalHom **localhom, double **mtx );
+extern int makelocal( char *s1, char *s2, int thr );
+extern void mdfymtx( char **pair, int s1, double **partialmtx, double **mtx );
+extern float score_calc( char **seq, int s );
+extern void cpmx_calc( char **seq, float **cpmx, double *eff, int lgth, int clus );
+extern void cpmx_calc_new( char **seq, float **cpmx, double *eff, int lgth, int clus );
+extern void MScpmx_calc_new( char **seq, float **cpmx, double *eff, int lgth, int clus );
+extern void mseqcat( char **seq1, char **seq2, double **eff, double *effarr1, double *effarr2, char name1[M][B], char name2[M][B], int clus1, int clus2 );
+extern void strnbcat( char *s1, char *s2, int m );
+extern int conjuctionforgaln( int s0, int s1, char **seq, char **aseq, double *peff, double *eff, char **name, char **aname, char *d );
+extern int fastconjuction( int *memlist, char **seq, char **aseq, double *peff, double *eff, char name[M][B], char aname[M][B], char *d );
+extern int fastconjuction_noname( int *memlist, char **seq, char **aseq, double *peff, double *eff, char *d );
+extern int fastconjuction_noweight( int *memlist, char **seq, char **aseq, double *peff, char *d );
+extern int conjuctionfortbfast( char **pair, int s, char **seq, char **aseq, double *peff, double *eff, char *d );
+extern int conjuction( char **pair, int s, char **seq, char **aseq, double *peff, double *eff, char name[M][B], char aname[M][B], char *d );
+extern void floatdelete( float **cpmx, int d, int len );
+extern void chardelete( char *seq, int d );
+extern int RootBranchNode( int nseq, int ***topol, int step, int branch );
+extern void BranchLeafNode( int nseq, int ***topol, int *node, int step, int branch );
+extern void RootLeafNode( int nseq, int ***topol, int *node );
+extern void nodeFromABranch( int nseq, int *result, int **pairwisenode, int ***topol, double **len, int step, int num );
+extern void OneClusterAndTheOther( int locnjob, char **pair, int *s1, int *s2, int ***topol, int step, int branch );
+extern void makeEffMtx( int nseq, double **mtx, double *vec );
+extern void node_eff( int nseq, double *eff, int *node );
+extern int shrinklocalhom( char **pair, int s1, int s2, LocalHom **localhom, LocalHom ***localhomshrink );
+extern int msshrinklocalhom( char **pair, int s1, int s2, LocalHom **localhom, LocalHom ***localhomshrink );
+extern int fastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink );
+extern int msfastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink );
+extern int TreeDependentIteration( int locnjob, char name[M][B], int nlen[M], char **aseq, char **bseq, int ***topol, double **len, int alloclen, LocalHom **localhomtable, RNApair ***single );
+extern void checkMinusLength( int nseq, double **len );
+extern void negativeMember2( int *mem, int *query, int locnseq );
+extern int *negativeMember( int *query, int locnseq );
+extern int IntExistsInVec( int query, int *vector );
+extern NodeInCub searchParent( int top, int ***topol, int Start, int End );
+extern void stopolInit( int n, Node *stopol );
+extern void treeCnv( Node *stopol, int locnseq, int ***topol, double **len, double **bw );
+extern int isLeaf( Node node );
+extern double syntheticLength( Node *ob, Node *oppositeNode );
+extern double calcW( Node *ob, Node *op );
+extern void calcBranchWeight( double **bw, int locnseq, Node *stopol, int ***topol, double **len );
+extern void branchWeightToPairWeight( int locnseq, int ***topol, double **pw, double **bw );
+extern void weightFromABranch_rec( double *result, Node *ob, Node *op );
+extern void weightFromABranch( int nseq, double *result, Node *stopol, int ***topol, int step, int LorR );
+extern void keika( char *str, int current, int all );
+extern double maxItch( double *soukan, int size );
+extern void calcNaiseki( Fukusosuu *value, Fukusosuu *x, Fukusosuu *y );
+extern Fukusosuu *AllocateFukusosuuVec( int l1 );
+extern Fukusosuu **AllocateFukusosuuMtx( int l1, int l2 );
+extern Fukusosuu ***AllocateFukusosuuCub( int l1, int l2, int l3 );
+extern void FreeFukusosuuVec( Fukusosuu *vec );
+extern void FreeFukusosuuMtx( Fukusosuu **mtx );
+extern int getKouho( int *kouho, int nkouho, double *soukan, int nlen2 );
+extern void zurasu2( int lag, int    clus1, int    clus2, char  **seq1, char  **seq2, char **aseq1, char **aseq2 );
+extern void zurasu( int lag, int    clus1, int    clus2, char  **seq1, char  **seq2, char **aseq1, char **aseq2 );
+extern int alignableReagion( int    clus1, int    clus2, char  **seq1, char  **seq2, double *eff1, double *eff2, Segment *seg );
+extern void blockAlign( int *cut1, int *cut2, double **ocrossscore, int *ncut );
+extern void blockAlign2( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut );
+extern void blockAlign3( int *cut1, int *cut2, Segment **seg1, Segment **seg2, double **ocrossscore, int *ncut );
+extern float A__align11( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch );
+extern float imp_match_out_scH( int i1, int j1 );
+extern void imp_match_init_strictH( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern float imp_match_out_scQ( int i1, int j1 );
+extern float imp_match_out_scR( int i1, int j1 );
+extern void imp_match_init_strictQ( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern void imp_match_init_strictR( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern void imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom );
+extern float MSalignmm( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char * );
+extern float Lalignmm_hmout( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, float **map );
+extern float Lalign2m2m_hmout( char **seq1, char **seq2, char **seq1r, char **seq2r, char *dir1, char *dir2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, char *, char *, char *, char *, float **map );
+extern float MSalign11( char **seq1, char **seq2, int alloclen );
+//extern float rnalocal( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, RNApair **pair );
+extern float A__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2 );
+extern float H__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2 );
+extern float Q__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2 );
+extern float Q__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2, int *gapmap1, int *gapmap2 );
+extern float R__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2 );
+extern float R__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *gs1, char *gs2, char *ge1, char *ge2 );
+extern float A__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int *gapmap1, int *gapmap2 );
+extern float D__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int *gapmap1, int *gapmap2 );
+extern float translate_and_Calign( char **mseq1, char **mseq2, double *effarr1, double *effarr2, int clus1, int clus2, int alloclen );
+extern double Fgetlag( char  **seq1, char  **seq2, double *eff1, double *eff2, int    clus1, int    clus2, int alloclen );
+extern float Falign( char  **seq1, char  **seq2, double *eff1, double *eff2, int    clus1, int    clus2, int alloclen, int *fftlog );
+extern float Falign_udpari_long( char  **seq1, char  **seq2, double *eff1, double *eff2, int    clus1, int    clus2, int alloclen, int *fftlog );
+extern float part_imp_match_out_sc( int i1, int j1 );
+extern float part_imp_match_out_scQ( int i1, int j1 );
+extern void part_imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern void part_imp_match_init_strictQ( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern void part_imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom );
+extern float partA__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *, char *, char *, char * );
+extern float partQ__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *, char *, char *, char *);
+//extern float MSalign11( char **seq1, char **seq2, int alloclen );
+extern float G__align11( char **seq1, char **seq2, int alloclen );
+extern float G__align11_noalign( int mtx[0x80][0x80], int penal, int penal_ex, char **seq1, char **seq2, int alloclen );
+extern float L__align11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt );
+extern float genL__align11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt );
+extern float genG__align11( char **seq1, char **seq2, int alloclen );
+extern float VAalign11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt, LocalHom *lhmpt );
+extern float suboptalign11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt, LocalHom *lhmpt )
+;
+extern int fft(int n, Fukusosuu *x, int dum);
+extern void topolcpy( int s1[], int s2[], int *mpt1, int *mpt2 );
+extern void topolcat( int s1[], int s2[], int *mpt1, int *mpt2 );
+extern void topolsort( int m, int s[] );
+extern void topolswap( int s1[], int s2[], int *mpt1, int *mpt2 );
+extern void reduc( double **mtx, int nseq, int im, int jm );
+extern void  nj( int nseq, double **omtx, int ***topol, double **dis );
+extern void JTTmtx( double **rsr, double *freq, char locamino[26], char locgrp[26], int isTM );
+extern void BLOSUMmtx( int n, double **matrix, double *freq, char *amino, char *amino_grp );
+extern void putlocalhom2( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa );
+extern void putlocalhom_ext( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa );
+extern void putlocalhom3( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa );
+extern void putlocalhom( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa );
+extern char *cutal( char *al, int al_display_start, int start, int end );
+extern void ErrorExit( char *message );
+extern void strncpy_caseC( char *str1, char *str2, int len );
+extern void seqUpper( int nseq, char **seq );
+extern void seqLower( int nseq, char **seq );
+extern int getaline_fp_eof( char *s, int l, FILE *fp );
+extern int getaline_fp_eof_new(char s[], int l, FILE *fp);
+extern int myfgets(char s[], int l, FILE *fp);
+extern float input_new( FILE *fp, int d );
+extern void PreRead( FILE *fp, int *locnjob, int *locnlenmax );
+extern int allSpace( char *str );
+extern void Read( char name[M][B], int nlen[M], char **seq );
+extern void FRead( FILE *fp, char name[][B], int nlen[], char **seq );
+extern void kake2hiku( char *str );
+extern void readDataforgaln( FILE *fp, char **name, int *nlen, char **seq );
+extern void readData( FILE *fp, char name[][B], int nlen[], char **seq );
+extern void readData_pointer( FILE *fp, char **name, int *nlen, char **seq );
+extern void readData_varlen( FILE *fp, char **name, int *nlen, char **seq );
+extern int countATGC( char *s, int *total );
+extern void getnumlen( FILE *fp );
+extern void getnumlen_nogap( FILE *fp, int *nlenmin );
+extern void WriteGapFill( FILE *fp, int locnjob, char name[][B], int nlen[M], char **aseq );
+extern void writeDataforgaln( FILE *fp, int locnjob, char **name, int *nlen, char **aseq );
+extern void writeData( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq );
+extern void writeData_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq );
+extern void readhat2_floathalf( FILE *fp, int nseq, char name[M][B], float **mtx );
+extern void readhat2_floathalf_pointer( FILE *fp, int nseq, char **name, float **mtx );
+extern void readhat2_float( FILE *fp, int nseq, char name[M][B], float **mtx );
+extern void readhat2_int( FILE *fp, int nseq, char name[M][B], int **mtx );
+extern void readhat2( FILE *fp, int nseq, char name[M][B], double **mtx );
+extern void WriteFloatHat2( FILE *hat2p, int locnjob, char name[M][B], float **mtx );
+extern void WriteHat2_int( FILE *hat2p, int locnjob, char name[M][B], int **mtx );
+extern void WriteHat2( FILE *hat2p, int locnjob, char name[M][B], double **mtx );
+extern void WriteHat2plain( FILE *hat2p, int locnjob, double **mtx );
+extern int ReadFasta_sub( FILE *fp, double *dis, int nseq, char name[M][B] );
+extern int ReadSsearch( FILE *fp, double *dis, int nseq, char name[M][B] );
+extern int ReadBlastm7( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist );
+extern int ReadBlastm7_scoreonly( FILE *fp, double *dis, int nin );
+extern int ReadBlastm7_avscore( FILE *fp, double *dis, int nin );
+extern int ReadFasta34noalign( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist );
+extern int ReadFasta34m10_nuc( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist );
+extern int ReadFasta34m10( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist );
+extern int ReadFasta34m10_scoreonly_nuc( FILE *fp, double *dis, int nin );
+extern int ReadFasta34m10_scoreonly( FILE *fp, double *dis, int nin );
+extern int ReadFasta34( FILE *fp, double *dis, int nseq, char name[M][B], LocalHom *localhomlist );
+extern int ReadFasta3( FILE *fp, double *dis, int nseq, char name[M][B] );
+extern int ReadFasta( FILE *fp, double *dis, int nseq, char name[M][B] );
+extern int ReadOpt( FILE *fp, int opt[M], int nseq, char name[M][B] );
+extern int ReadOpt2( FILE *fp, int opt[M], int nseq, char name[M][B] );
+extern int writePre( int nseq, char name[][B], int nlen[M], char **aseq, int force );
+extern void readOtherOptions( int *ppidptr, int *fftThresholdptr, int *fftWinSizeptr );
+extern void initSignalSM( void );
+extern void initFiles( void );
+extern void WriteForFasta( FILE *fp, int locnjob, char name[][B], int nlen[M], char **aseq );
+extern void readlocalhomtable( FILE*fp, int njob, LocalHom **localhomtable );
+extern void readlocalhomtable2( FILE*fp, int njob, LocalHom **localhomtable );
+extern void outlocalhom( LocalHom **localhom, int nseq );
+extern void outlocalhompt( LocalHom ***localhom, int n1, int n2 );
+extern void FreeLocalHomTable( LocalHom **localhomtable, int n ) ;
+extern void constants( int nseq, char **seq );
+extern void clustalout_pointer( FILE *fp, int nseq, int maxlen, char **seq, char **name, char *mark, char *comment, int *order );
+extern void writeData_reorder( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq, int *order );
+extern void writeData_reorder_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq, int *order );
+
+extern void resetlocalhom( int, LocalHom ** );
+extern int load1SeqWithoutName_new( FILE *fpp, char *cbuf );
+extern char *load1SeqWithoutName_realloc( FILE *fpp );
+extern int disttbfast( char **in, int nlen[M], char name[M][B] );
+extern void searchKUorWA( FILE *fp );
+extern void gapireru( char *res, char *ori, char *gt );
+extern int seqlen( char *seq );
+extern void st_FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len );
+extern void st_OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len );
+extern void st_OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len );
+extern void st_FinalGapCount_zure( float *fgcp, int clus, char **seq, double *eff, int len );
+extern void getdiaminofreq_x( float *freq, int clus, char **seq, double *eff, int len );
+extern void new_FinalGapCount_zure( float *fgcp, int clus, char **seq, double *eff, int len, char *s, char *e );
+extern void new_FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len, char *g );
+extern void new_OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len, char *g );
+extern void new_OpeningGapCount_zure( float *ogcp, int clus, char **seq, double *eff, int len, char *s, char *e );
+extern void getGapPattern( float *fgcp, int clus, char **seq, double *eff, int len, char *g );
+extern void getgapfreq( float *freq, int clus, char **seq, double *eff, int len );
+extern void getgapfreq_zure( float *freq, int clus, char **seq, double *eff, int len );
+//extern void getgapfreq_zure_part( float *freq, int clus, char **seq, double *eff, int len, char *s );
+extern void getgapfreq_zure_part( float *freq, int clus, char **seq, double *eff, int len, char *s );
+extern void getdiaminofreq_part( float *freq, int clus, char **seq, double *eff, int len, char *s, char *e );
+extern void getdigapfreq_part( float *freq, int clus, char **seq, double *eff, int len, char *s, char *e );
+extern void getdiaminofreq_st( float *freq, int clus, char **seq, double *eff, int len );
+extern void getdigapfreq_st( float *freq, int clus, char **seq, double *eff, int len );
+extern void st_getGapPattern( Gappat **gpat, int clus, char **seq, double *eff, int len );
+extern void getkyokaigap( char *g, char **s, int pos, int n );
+extern double *loadaamtx( void );
+extern float naivepairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
+extern int naivepairscore11( char *seq1, char *seq2, int penal );
+extern float naiveQpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
+extern float naiveRpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
+extern float naiveHpairscore( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, int penal );
+extern void foldrna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, float **impmtx, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void foldrna_gappick( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, float **impmtx, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void imp_rnaQ( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void part_imp_rnaQ( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void part_imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void imp_rnaQ_gappick( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***gr1, RNApair ***gr2, int *gapmap1, int *gapmap2, RNApair *pair );
+extern void foldalignedrna( int clus1, int clus2, char **mseq1, char **mseq2, double *effarr1, double *effarr2, RNApair *rnapairboth );
+void readmccaskill( FILE *fp, RNApair **pairprob, int length );
+void makegrouprna( RNApair ***group, RNApair ***all, int *memlist );
+void makegrouprnait( RNApair ***group, RNApair ***all, char **pair, int s );
+extern void fixed_musclesupg_float_realloc_nobk_halfmtx( int nseq, float **eff, int ***topol, float **len );
+extern void loadtree( int nseq, int ***topol, float **len, char **name, int *nlen );
+extern void loadtop( int nseq, float **eff, int ***topol, float **len );
+extern void fixed_musclesupg_float_realloc_nobk_halfmtx_treeout( int nseq, float **eff, int ***topol, float **len, char **name, int *nlen );
+extern void imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore );
+extern void miyataout_reorder_pointer( FILE *fp, int locnjob, int nlenmax, char **name, int *nlen, char **aseq, int *order );
+extern void veryfastsupg_double_outtree( int nseq, double **eff, int ***topol, double **len, char name[][B] );
+extern void cpmx_ribosum( char **seq, char **seqr, char *dir, float **cpmx, double *eff, int lgth, int clus );
+extern void rnaalifoldcall( char **seq, int nseq, RNApair **pairprob );
+extern void readpairfoldalign( FILE *fp, char *seq1, char *seq2, char *aln1, char *aln2, int q1, int q2, int *of1, int *of2, int sumlen );
+extern void write1seq( FILE *fp, char *aseq );
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/genGalign11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/genGalign11.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/genGalign11.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/genGalign11.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,484 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  1
+
+
+#if 1
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 ) 
+{
+	char *seq2 = s2[0];
+	int *intptr = amino_dis[(int)s1[0][i1]];
+
+	while( lgth2-- )
+		*match++ = intptr[(int)*seq2++];
+}
+#else
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 )
+{
+	int j;
+
+	for( j=0; j<lgth2; j++ )
+		match[j] = amino_dis[(*s1)[i1]][(*s2)[j]];
+}
+#endif
+
+static float genGtracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijpi, int **ijpj )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, limk;
+	char gap[] = "-";
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijpi[i][0] = -1;
+		ijpj[i][0] = -1; // ???
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+		ijpi[0][j] = -1; // ???
+        ijpj[0][j] = -1;
+    }
+
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+	iin = lgth1; jin = lgth2;
+	limk = lgth1+lgth2 + 1;
+	for( k=0; k<limk; k++ ) 
+	{
+		ifi = ( ijpi[iin][jin] );
+		jfi = ( ijpj[iin][jin] );
+		l = iin - ifi;
+		while( --l ) 
+		{
+			*--mseq1[0] = seq1[0][ifi+l];
+			*--mseq2[0] = *gap;
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--mseq1[0] = *gap;
+			*--mseq2[0] = seq2[0][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		*--mseq1[0] = seq1[0][ifi];
+		*--mseq2[0] = seq2[0][jfi];
+
+//		fprintf( stdout, "mseq1 = %s\n", mseq1[0] );
+//		fprintf( stdout, "mseq2 = %s\n", mseq2[0] );
+
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+
+float genG__align11( char **seq1, char **seq2, int alloclen )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti;                      /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+	float fpenalty = (float)penalty;
+	float fpenalty_OP = (float)penalty_OP;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+#if 1
+	float *wtmp;
+	int *ijpipt;
+	int *ijpjpt;
+	float *mjpt, *Mjpt, *prept, *curpt;
+	int *mpjpt, *Mpjpt;
+#endif
+	static float mi, *m;
+	static float Mi, *largeM;
+	static int **ijpi;
+	static int **ijpj;
+	static int mpi, *mp;
+	static int Mpi, *Mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float tbk;
+	int tbki, tbkj;
+
+	wm = 0.0;
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+
+
+	if( lgth1 <= 0 || lgth2 <= 0 )
+	{
+		fprintf( stderr, "WARNING (g11): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
+	}
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+			FreeFloatVec( largeM );
+			FreeIntVec( Mp );
+
+			FreeCharMtx( mseq );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+		largeM = AllocateFloatVec( ll2+2 );
+		Mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+			FreeIntMtx( commonJP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+		commonJP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijpi = commonIP;
+	ijpj = commonJP;
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc( initverticalw, seq2, seq1, 0, lgth1 );
+
+
+	match_calc( currentw, seq1, seq2, 0, lgth2 );
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += fpenalty;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += fpenalty;
+		}
+	}
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1]; mp[j] = 0;
+		largeM[j] = currentw[j-1]; Mp[j] = 0;
+	}
+
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0;               // lgth2==0 no toki error
+	else
+		lastverticalw[0] = currentw[lgth2-1]; // lgth2==0 no toki error
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, seq1, seq2, i, lgth2 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0]; mpi = 0;
+		Mi = previousw[0]; Mpi = 0;
+
+		ijpipt = ijpi[i] + 1;
+		ijpjpt = ijpj[i] + 1;
+		mjpt = m + 1;
+		Mjpt = largeM + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		Mpjpt = Mp + 1;
+		tbk = -9999999.9;
+		tbki = 0;
+		tbkj = 0;
+		for( j=1; j<lgth2+1; j++ )
+		{
+			wm = *prept;
+			*ijpipt = i-1;
+			*ijpjpt = j-1;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+fpenalty) > wm )
+			{
+				wm = g;
+//				*ijpipt = i - 1; // iranai
+				*ijpjpt = mpi;
+			}
+			if( (g=*prept) >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt + fpenalty) > wm )
+			{
+				wm = g;
+				*ijpipt = *mpjpt;
+				*ijpjpt = j - 1; //IRU!
+			}
+			if( (g=*prept) >= *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if USE_PENALTY_EX
+			m[j] += fpenalty_ex;
+#endif
+
+#if 1
+			g =  tbk + fpenalty_OP;
+			if( g > wm )
+			{
+				wm = g;
+				*ijpipt = tbki;
+				*ijpjpt = tbkj;
+//				fprintf( stderr, "hit! i%d, j%d, ijpi = %d, ijpj = %d\n", i, j, *ijpipt, *ijpjpt );
+			}
+			if( Mi > tbk )
+			{
+				tbk = Mi; //error desu.
+				tbki = i-1;
+				tbkj = Mpi;
+			}
+			if( *Mjpt > tbk )
+			{
+				tbk = *Mjpt;
+				tbki = *Mpjpt;
+				tbkj = j-1;
+			}
+
+			if( *prept > *Mjpt )
+			{
+				*Mjpt = *prept;
+				*Mpjpt = i-1;
+			}
+			if( *prept > Mi )
+			{
+				Mi = *prept;
+				Mpi = j-1;
+			}
+
+#endif
+
+
+#if 0
+			fprintf( stderr, "%5.0f ", wm );
+#endif
+			*curpt++ += wm;
+			ijpipt++;
+			ijpjpt++;
+			mjpt++;
+			Mjpt++;
+			prept++;
+			mpjpt++;
+			Mpjpt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1]; // lgth2==0 no toki error
+	}
+#if 0
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<lgth2; j++ )
+		{
+			fprintf( stdout, "i,j=%d,%d - ijpi,ijpj=%d,%d\n", i, j, ijpi[i][j], ijpj[i][j] );
+		}
+	}
+	fflush( stdout );
+#endif
+
+	genGtracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijpi, ijpj );
+
+	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" );
+	}
+
+
+	strcpy( seq1[0], mseq1[0] );
+	strcpy( seq2[0], mseq2[0] );
+#if 0
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+	fprintf( stderr, "wm = %f\n", wm );
+#endif
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/genalign11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/genalign11.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/genalign11.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/genalign11.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,627 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define DEBUG 0
+#define DEBUG2 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  1
+
+static int localstop;
+
+#if 1
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 ) 
+{
+	char tmpc = s1[0][i1];
+	char *seq2 = s2[0];
+
+	while( lgth2-- )
+		*match++ = amino_dis[(int)tmpc][(int)*seq2++];
+}
+#else
+static void match_calc( float *match, char **s1, char **s2, int i1, int lgth2 )
+{
+	int j;
+
+	for( j=0; j<lgth2; j++ )
+		match[j] = amino_dis[(*s1)[i1]][(*s2)[j]];
+}
+#endif
+
+#if 0
+static void match_calc_bk( 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[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+#if 0 
+	{
+		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[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+#endif
+
+static float gentracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijpi, int **ijpj, int *off1pt, int *off2pt, int endi, int endj )
+{
+	int i, j, l, iin, jin, lgth1, lgth2, k, limk;
+	int ifi=0, jfi=0; // by D.Mathog
+	char gap[] = "-";
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+    for( i=0; i<lgth1+1; i++ ) 
+    {
+        ijpi[i][0] = localstop;
+        ijpj[i][0] = localstop;
+    }
+    for( j=0; j<lgth2+1; j++ ) 
+    {
+        ijpi[0][j] = localstop;
+        ijpj[0][j] = localstop;
+    }
+
+	mseq1[0] += lgth1+lgth2;
+	*mseq1[0] = 0;
+	mseq2[0] += lgth1+lgth2;
+	*mseq2[0] = 0;
+	iin = endi; jin = endj;
+	limk = lgth1+lgth2;
+	for( k=0; k<=limk; k++ ) 
+	{
+
+		ifi = ( ijpi[iin][jin] );
+		jfi = ( ijpj[iin][jin] );
+		l = iin - ifi;
+//		if( ijpi[iin][jin] < 0 || ijpj[iin][jin] < 0 )
+//		{
+//			fprintf( stderr, "skip! %d-%d\n", ijpi[iin][jin], ijpj[iin][jin] );
+//			fprintf( stderr, "1: %c-%c\n", seq1[0][iin], seq1[0][ifi] );
+//			fprintf( stderr, "2: %c-%c\n", seq2[0][jin], seq2[0][jfi] );
+//		}
+		while( --l ) 
+		{
+			*--mseq1[0] = seq1[0][ifi+l];
+			*--mseq2[0] = *gap;
+			k++;
+		}
+		l= jin - jfi;
+		while( --l )
+		{
+			*--mseq1[0] = *gap;
+			*--mseq2[0] = seq2[0][jfi+l];
+			k++;
+		}
+
+		if( iin <= 0 || jin <= 0 ) break;
+		*--mseq1[0] = seq1[0][ifi];
+		*--mseq2[0] = seq2[0][jfi];
+
+		if( ijpi[ifi][jfi] == localstop ) break;
+		if( ijpj[ifi][jfi] == localstop ) break; 
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	if( ifi == -1 ) *off1pt = 0; else *off1pt = ifi;
+	if( jfi == -1 ) *off2pt = 0; else *off2pt = jfi;
+
+//	fprintf( stderr, "ifn = %d, jfn = %d\n", ifi, jfi );
+
+
+	return( 0.0 );
+}
+
+
+float genL__align11( char **seq1, char **seq2, int alloclen, int *off1pt, int *off2pt )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj; 
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if 1
+	float *wtmp;
+	int *ijpipt;
+	int *ijpjpt;
+	float *mjpt, *Mjpt, *prept, *curpt;
+	int *mpjpt, *Mpjpt;
+#endif
+	static float mi, *m;
+	static float Mi, *largeM;
+	static int **ijpi;
+	static int **ijpj;
+	static int mpi, *mp;
+	static int Mpi, *Mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float maxwm;
+	float tbk;
+	int tbki, tbkj;
+	int endali, endalj;
+//	float localthr = 0.0;
+//	float localthr2 = 0.0;
+	float fpenalty = (float)penalty;
+	float fpenalty_OP = (float)penalty_OP;
+	float fpenalty_ex = (float)penalty_ex;
+//	float fpenalty_EX = (float)penalty_EX;
+	float foffset = (float)offset;
+	float localthr = -foffset;
+	float localthr2 = -foffset;
+
+
+//	fprintf( stderr, "@@@@@@@@@@@@@ penalty_OP = %f, penalty_EX = %f, pelanty = %f\n", fpenalty_OP, fpenalty_EX, fpenalty );
+
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+			FreeFloatVec( largeM );
+			FreeIntVec( Mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+		largeM = AllocateFloatVec( ll2+2 );
+		Mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	mseq1[0] = mseq[0];
+	mseq2[0] = mseq[1];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+			FreeIntMtx( commonJP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+		commonJP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijpi = commonIP;
+	ijpj = commonJP;
+
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+	match_calc( initverticalw, seq2, seq1, 0, lgth1 );
+
+	match_calc( currentw, seq1, seq2, 0, lgth2 );
+
+
+	lasti = lgth2+1;
+	for( j=1; j<lasti; ++j ) 
+	{
+		m[j] = currentw[j-1]; mp[j] = 0;
+		largeM[j] = currentw[j-1]; Mp[j] = 0;
+	}
+
+	lastverticalw[0] = currentw[lgth2-1];
+
+
+#if 0
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if DEBUG2
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "       " );
+	for( j=0; j<lgth2+1; j++ )
+		fprintf( stderr, "%c     ", seq2[0][j] );
+	fprintf( stderr, "\n" );
+#endif
+
+	localstop = lgth1+lgth2+1;
+	maxwm = -999999999.9;
+	endali = endalj = 0;
+#if DEBUG2
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "%c   ", seq1[0][0] );
+
+	for( j=0; j<lgth2+1; j++ )
+		fprintf( stderr, "%5.0f ", currentw[j] );
+	fprintf( stderr, "\n" );
+#endif
+
+	lasti = lgth1+1;
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, seq1, seq2, i, lgth2 );
+#if DEBUG2
+		fprintf( stderr, "%c   ", seq1[0][i] );
+		fprintf( stderr, "%5.0f ", currentw[0] );
+#endif
+
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mi = previousw[0]; mpi = 0;
+		Mi = previousw[0]; Mpi = 0;
+
+#if 0
+		if( mi < localthr ) mi = localthr2;
+#endif
+
+		ijpipt = ijpi[i] + 1;
+		ijpjpt = ijpj[i] + 1;
+		mjpt = m + 1;
+		Mjpt = largeM + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		Mpjpt = Mp + 1;
+		tbk = -999999.9;
+		tbki = 0;
+		tbkj = 0;
+		lastj = lgth2+1;
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+			*ijpipt = i-1;
+			*ijpjpt = j-1;
+
+
+//			fprintf( stderr, "i,j=%d,%d %c-%c\n", i, j, seq1[0][i], seq2[0][j] );
+//			fprintf( stderr, "wm=%f\n", wm );
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+			g = mi + fpenalty;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+//				*ijpipt = i - 1; 
+				*ijpjpt = mpi;
+			}
+			g = *prept;
+			if( g > mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+			g = *mjpt + fpenalty;
+#if 0
+			fprintf( stderr, "m%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijpipt = *mpjpt;
+				*ijpjpt = j - 1; //IRU!
+			}
+			g = *prept;
+			if( g > *mjpt )
+			{
+				*mjpt = g;
+				*mpjpt = i-1;
+			}
+#if USE_PENALTY_EX
+			*mjpt += fpenalty_ex;
+#endif
+
+
+			g =  tbk + fpenalty_OP; 
+//			g =  tbk; 
+			if( g > wm )
+			{
+				wm = g;
+				*ijpipt = tbki;
+				*ijpjpt = tbkj;
+//				fprintf( stderr, "hit! i%d, j%d, ijpi = %d, ijpj = %d\n", i, j, *ijpipt, *ijpjpt );
+			}
+//			g = Mi;
+			if( Mi > tbk )
+			{
+				tbk = Mi; //error desu.
+				tbki = i-1;
+				tbkj = Mpi;
+			}
+//			g = *Mjpt;
+			if( *Mjpt > tbk )
+			{
+				tbk = *Mjpt;
+				tbki = *Mpjpt;
+				tbkj = j-1;
+			}
+//			tbk += fpenalty_EX;// + foffset;
+
+//			g = *prept;
+			if( *prept > *Mjpt )
+			{
+				*Mjpt = *prept;
+				*Mpjpt = i-1;
+			}
+//			*Mjpt += fpenalty_EX;// + foffset;
+
+//			g = *prept;
+			if( *prept > Mi )
+			{
+				Mi = *prept;
+				Mpi = j-1;
+			}
+//			Mi += fpenalty_EX;// + foffset;
+
+
+//			fprintf( stderr, "wm=%f, tbk=%f(%c-%c), mi=%f, *mjpt=%f\n", wm, tbk, seq1[0][tbki], seq2[0][tbkj], mi, *mjpt );
+//			fprintf( stderr, "ijp = %c,%c\n", seq1[0][abs(*ijpipt)], seq2[0][abs(*ijpjpt)] );
+
+
+			if( maxwm < wm )
+			{
+				maxwm = wm;
+				endali = i;
+				endalj = j;
+			}
+#if 1
+			if( wm < localthr )
+			{
+//				fprintf( stderr, "stop i=%d, j=%d, curpt=%f\n", i, j, *curpt );
+				*ijpipt = localstop;
+//				*ijpjpt = localstop; 
+				wm = localthr2;
+			}
+#endif
+#if 0
+			fprintf( stderr, "%5.0f ", *curpt );
+#endif
+#if DEBUG2
+			fprintf( stderr, "%5.0f ", wm );
+//			fprintf( stderr, "%c-%c *ijppt = %d, localstop = %d\n", seq1[0][i], seq2[0][j], *ijppt, localstop );
+#endif
+
+			*curpt += wm;
+			ijpipt++;
+			ijpjpt++;
+			mjpt++;
+			Mjpt++;
+			prept++;
+			mpjpt++;
+			Mpjpt++;
+			curpt++;
+		}
+#if DEBUG2
+		fprintf( stderr, "\n" );
+#endif
+
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+
+#if DEBUG2
+	fprintf( stderr, "maxwm = %f\n", maxwm );
+	fprintf( stderr, "endali = %d\n", endali );
+	fprintf( stderr, "endalj = %d\n", endalj );
+#endif
+
+	if( ijpi[endali][endalj] == localstop ) // && ijpj[endali][endalj] == localstop )
+	{
+		strcpy( seq1[0], "" );
+		strcpy( seq2[0], "" );
+		*off1pt = *off2pt = 0;
+		return( 0.0 );
+	}
+
+
+	gentracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijpi, ijpj, off1pt, off2pt, endali, endalj );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	strcpy( seq1[0], mseq1[0] );
+	strcpy( seq2[0], mseq2[0] );
+
+#if 0
+	fprintf( stderr, "\n" );
+	fprintf( stderr, ">\n%s\n", mseq1[0] );
+	fprintf( stderr, ">\n%s\n", mseq2[0] );
+#endif
+
+
+	return( maxwm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/io.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/io.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/io.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/io.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,3813 @@
+#include "mltaln.h"
+
+static int upperCase = 0;
+
+#define DEBUG   0
+#define IODEBUG 0
+
+#if 0
+
+static int addlocalhom2( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, int skip )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	int iscore;
+	int isumscore;
+	int sumoverlap;
+	LocalHom *tmppt;
+	int st;
+	int nlocalhom = 0;
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+	isumscore = 0;
+	sumoverlap = 0;
+
+#if 0
+	fprintf( stderr, "nlocalhom = %d in addlocalhom\n", nlocalhom );
+	fprintf( stderr, "al1 = %s, al2 = %s\n", al1, al2 );
+	fprintf( stderr, "off1 = %d, off2 = %d\n", off1, off2 );
+	fprintf( stderr, "localhopt = %p, skip = %d\n", localhompt, skip );
+	fprintf( stderr, "pt1 = \n%s\n, pt2 = \n%s\n", pt1, pt2 );
+#endif
+
+	if( skip )
+	{
+		while( --skip > 0 ) localhompt = localhompt->next;
+		localhompt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+		localhompt = localhompt->next;
+//		fprintf( stderr, "tmppt = %p, localhompt = %p\n", tmppt, localhompt );
+	}
+	tmppt = localhompt;
+
+	st = 0;
+	iscore = 0;
+	while( *pt1 != 0 )
+	{
+//		fprintf( stderr, "In in while loop\n" );
+//		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( nlocalhom++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			isumscore += iscore;
+			sumoverlap += end2-start2+1;
+#else
+			tmppt->overlapaa   = end2-start2+1;
+			tmppt->opt = iscore * 5.8 / 600;
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+#if 0
+			fprintf( stderr, "iscore (1)= %d\n", iscore );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+			iscore = 0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			iscore += n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]];
+//			fprintf( stderr, "%c-%c, score(0) = %d\n", *pt1, *pt2, iscore );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+
+	if( st )
+	{
+		if( nlocalhom++ > 0 )
+		{
+//			fprintf( stderr, "reallocating ...\n" );
+			tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//			fprintf( stderr, "done\n" );
+			tmppt = tmppt->next;
+			tmppt->next = NULL;
+		}
+		end1 = pos1 - 1;
+		end2 = pos2 - 1;
+		tmppt->start1 = start1;
+		tmppt->start2 = start2;
+		tmppt->end1   = end1  ;
+		tmppt->end2   = end2  ;
+
+#if 1
+		isumscore += iscore;
+		sumoverlap += end2-start2+1;
+#else
+		tmppt->overlapaa   = end2-start2+1;
+		tmppt->opt = (double)iscore * 5.8 / 600;
+		tmppt->overlapaa   = overlapaa;
+		tmppt->opt = (double)opt;
+#endif
+#if 0
+		fprintf( stderr, "score (2)= %d\n", iscore );
+		fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+		fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+	}
+
+	for( tmppt=localhompt; tmppt; tmppt=tmppt->next )
+	{
+		tmppt->overlapaa = sumoverlap;
+		tmppt->opt = (double)sumscore * 5.8 / 600 / sumoverlap;
+	}
+	return( nlocalhom );
+}
+
+#endif
+
+
+
+static int addlocalhom_r( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa, int skip )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	double score;
+	double sumscore;
+	int sumoverlap;
+	LocalHom *tmppt = NULL; // by D.Mathog, a guess
+	int st;
+	int nlocalhom = 0;
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+	sumscore = 0.0;
+	sumoverlap = 0;
+	start1 = 0; // by D.Mathog, a guess
+	start2 = 0; // by D.Mathog, a guess
+
+#if 0
+	fprintf( stderr, "nlocalhom = %d in addlocalhom\n", nlocalhom );
+	fprintf( stderr, "al1 = %s, al2 = %s\n", al1, al2 );
+	fprintf( stderr, "off1 = %d, off2 = %d\n", off1, off2 );
+	fprintf( stderr, "localhopt = %p, skip = %d\n", localhompt, skip );
+#endif
+	fprintf( stderr, "pt1 = \n%s\n, pt2 = \n%s\n", pt1, pt2 );
+
+	if( skip )
+	{
+		while( --skip > 0 ) localhompt = localhompt->next;
+		localhompt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+		localhompt = localhompt->next;
+		fprintf( stderr, "tmppt = %p, localhompt = %p\n", (void *)tmppt, (void *)localhompt );
+	}
+	tmppt = localhompt;
+
+	st = 0;
+	score = 0.0;
+	while( *pt1 != 0 )
+	{
+		fprintf( stderr, "In in while loop\n" );
+		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( nlocalhom++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			sumscore += score;
+			sumoverlap += end2-start2+1;
+#else
+			tmppt->overlapaa   = end2-start2+1;
+			tmppt->opt = score * 5.8 / 600;
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+			fprintf( stderr, "score (1)= %f\n", score );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+			score = 0.0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			score += (double)n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]];
+//			fprintf( stderr, "%c-%c, score(0) = %f\n", *pt1, *pt2, score );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+	if( nlocalhom++ > 0 )
+	{
+//		fprintf( stderr, "reallocating ...\n" );
+		tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//		fprintf( stderr, "done\n" );
+		tmppt = tmppt->next;
+		tmppt->next = NULL;
+	}
+	end1 = pos1 - 1;
+	end2 = pos2 - 1;
+	tmppt->start1 = start1;
+	tmppt->start2 = start2;
+	tmppt->end1   = end1  ;
+	tmppt->end2   = end2  ;
+
+#if 1
+	sumscore += score;
+	sumoverlap += end2-start2+1;
+#else
+	tmppt->overlapaa   = end2-start2+1;
+	tmppt->opt = score * 5.8 / 600;
+	tmppt->overlapaa   = overlapaa;
+	tmppt->opt = (double)opt;
+#endif
+
+	fprintf( stderr, "score (2)= %f\n", score );
+	fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+	fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+
+	for( tmppt=localhompt; tmppt; tmppt=tmppt->next )
+	{
+		tmppt->overlapaa = sumoverlap;
+		tmppt->opt = sumscore * 5.8 / 600 / sumoverlap;
+	}
+	return( nlocalhom );
+}
+void putlocalhom3( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	double score;
+	double sumscore;
+	int sumoverlap;
+	LocalHom *tmppt;
+	LocalHom *subnosento;
+	int st;
+	int saisho;
+
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+	sumscore = 0.0;
+	sumoverlap = 0;
+	start1 = 0; // by Mathog, a guess
+	start2 = 0; // by Mathog, a guess
+
+	subnosento = localhompt;
+	while( subnosento->next ) subnosento = subnosento->next;
+	tmppt = subnosento;
+
+	saisho = ( localhompt->nokori == 0 );
+
+	fprintf( stderr, "localhompt = %p\n", (void *)localhompt );
+	fprintf( stderr, "tmppt = %p\n", (void *)tmppt );
+	fprintf( stderr, "subnosento = %p\n", (void *)subnosento );
+
+	st = 0;
+	score = 0.0;
+	while( *pt1 != 0 )
+	{
+//		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( localhompt->nokori++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			if( divpairscore )
+			{
+				tmppt->overlapaa   = end2-start2+1;
+				tmppt->opt = score / tmppt->overlapaa * 5.8 / 600;
+			}
+			else
+			{
+				sumscore += score;
+				sumoverlap += end2-start2+1;
+			}
+#else
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+#if 0
+			fprintf( stderr, "score (1)= %f\n", score );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+			score = 0.0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			score += (double)n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]]; // - offset ¤Ï¤¤¤é¤Ê¤¤¤«¤â
+//			fprintf( stderr, "%c-%c, score(0) = %f\n", *pt1, *pt2, score );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+	if( *(pt1-1) != '-' && *(pt2-1) != '-'  )
+	{
+		if( localhompt->nokori++ > 0 )
+		{
+//			fprintf( stderr, "reallocating ...\n" );
+			tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//			fprintf( stderr, "done\n" );
+			tmppt = tmppt->next;
+			tmppt->next = NULL;
+		}
+
+		end1 = pos1 - 1;
+		end2 = pos2 - 1;
+		tmppt->start1 = start1;
+		tmppt->start2 = start2;
+		tmppt->end1   = end1  ;
+		tmppt->end2   = end2  ;
+
+
+#if 1
+		if( divpairscore )
+		{
+			tmppt->overlapaa   = end2-start2+1;
+			tmppt->opt = score / tmppt->overlapaa * 5.8 / 600;
+		}
+		else
+		{
+			sumscore += score;
+			sumoverlap += end2-start2+1;
+		}
+#else
+		tmppt->overlapaa   = overlapaa;
+		tmppt->opt = (double)opt;
+#endif
+
+#if 0
+		fprintf( stderr, "score (2)= %f\n", score );
+		fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+		fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+	}
+
+	fprintf( stderr, "sumscore = %f\n", sumscore );
+	if( !divpairscore )
+	{
+
+		if( !saisho ) subnosento = subnosento->next;
+		for( tmppt=subnosento; tmppt; tmppt=tmppt->next )
+		{
+			tmppt->overlapaa = sumoverlap;
+			tmppt->opt = sumscore * 5.8 / 600 / sumoverlap;
+			fprintf( stderr, "tmpptr->opt = %f\n", tmppt->opt );
+		}
+	}
+}
+void putlocalhom_ext( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	int iscore;
+	int isumscore;
+	int sumoverlap;
+	LocalHom *tmppt = localhompt;
+	int nlocalhom = 0;
+	int st;
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+
+	isumscore = 0;
+	sumoverlap = 0;
+	start1 = 0; // by D.Mathog, a guess
+	start2 = 0; // by D.Mathog, a guess
+
+	st = 0;
+	iscore = 0;
+	while( *pt1 != 0 )
+	{
+//		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( nlocalhom++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			if( divpairscore )
+			{
+				tmppt->overlapaa   = end2-start2+1;
+				tmppt->opt = (double)iscore / tmppt->overlapaa * 5.8 / 600;
+			}
+			else
+			{
+				isumscore += iscore;
+				sumoverlap += end2-start2+1;
+			}
+#else
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+#if 0
+			fprintf( stderr, "iscore (1)= %d\n", iscore );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+			iscore = 0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			iscore += n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]]; // - offset ¤Ï¤¤¤é¤Ê¤¤¤«¤â
+//			fprintf( stderr, "%c-%c, iscore(0) = %d\n", *pt1, *pt2, iscore );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+	if( *(pt1-1) != '-' && *(pt2-1) != '-'  )
+	{
+		if( nlocalhom++ > 0 )
+		{
+//			fprintf( stderr, "reallocating ...\n" );
+			tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//			fprintf( stderr, "done\n" );
+			tmppt = tmppt->next;
+			tmppt->next = NULL;
+		}
+		end1 = pos1 - 1;
+		end2 = pos2 - 1;
+		tmppt->start1 = start1;
+		tmppt->start2 = start2;
+		tmppt->end1   = end1  ;
+		tmppt->end2   = end2  ;
+	
+#if 1
+		if( divpairscore )
+		{
+			tmppt->overlapaa   = end2-start2+1;
+			tmppt->opt = (double)iscore / tmppt->overlapaa * 5.8 / 600;
+		}
+		else
+		{
+			isumscore += iscore;
+			sumoverlap += end2-start2+1;
+		}
+#else
+		tmppt->overlapaa   = overlapaa;
+		tmppt->opt = (double)opt;
+#endif
+
+#if 0
+		fprintf( stderr, "iscore (2)= %d\n", iscore );
+		fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+		fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+	}
+
+	if( !divpairscore )
+	{
+		for( tmppt=localhompt; tmppt; tmppt=tmppt->next )
+		{
+			tmppt->overlapaa = sumoverlap;
+//			tmppt->opt = (double)isumscore * 5.8 / ( 600 * sumoverlap );
+			tmppt->opt = (double)600 * 5.8 / 600;
+//			fprintf( stderr, "tmpptr->opt = %f\n", tmppt->opt );
+		}
+	}
+}
+void putlocalhom2( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	int iscore;
+	int isumscore;
+	int sumoverlap;
+	LocalHom *tmppt = localhompt;
+	int nlocalhom = 0;
+	int st;
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+
+	isumscore = 0;
+	sumoverlap = 0;
+	start1 = 0; // by D.Mathog, a guess
+	start2 = 0; // by D.Mathog, a guess
+
+	st = 0;
+	iscore = 0;
+	while( *pt1 != 0 )
+	{
+//		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( nlocalhom++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			if( divpairscore )
+			{
+				tmppt->overlapaa   = end2-start2+1;
+				tmppt->opt = (double)iscore / tmppt->overlapaa * 5.8 / 600;
+			}
+			else
+			{
+				isumscore += iscore;
+				sumoverlap += end2-start2+1;
+			}
+#else
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+#if 0
+			fprintf( stderr, "iscore (1)= %d\n", iscore );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+			iscore = 0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			iscore += n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]]; // - offset ¤Ï¤¤¤é¤Ê¤¤¤«¤â
+//			fprintf( stderr, "%c-%c, iscore(0) = %d\n", *pt1, *pt2, iscore );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+	if( *(pt1-1) != '-' && *(pt2-1) != '-'  )
+	{
+		if( nlocalhom++ > 0 )
+		{
+//			fprintf( stderr, "reallocating ...\n" );
+			tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//			fprintf( stderr, "done\n" );
+			tmppt = tmppt->next;
+			tmppt->next = NULL;
+		}
+		end1 = pos1 - 1;
+		end2 = pos2 - 1;
+		tmppt->start1 = start1;
+		tmppt->start2 = start2;
+		tmppt->end1   = end1  ;
+		tmppt->end2   = end2  ;
+	
+#if 1
+		if( divpairscore )
+		{
+			tmppt->overlapaa   = end2-start2+1;
+			tmppt->opt = (double)iscore / tmppt->overlapaa * 5.8 / 600;
+		}
+		else
+		{
+			isumscore += iscore;
+			sumoverlap += end2-start2+1;
+		}
+#else
+		tmppt->overlapaa   = overlapaa;
+		tmppt->opt = (double)opt;
+#endif
+
+#if 0
+		fprintf( stderr, "iscore (2)= %d\n", iscore );
+		fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+		fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+	}
+
+	if( !divpairscore )
+	{
+		for( tmppt=localhompt; tmppt; tmppt=tmppt->next )
+		{
+			tmppt->overlapaa = sumoverlap;
+			tmppt->opt = (double)isumscore * 5.8 / ( 600 * sumoverlap );
+//			fprintf( stderr, "tmpptr->opt = %f\n", tmppt->opt );
+		}
+	}
+}
+void putlocalhom( char *al1, char *al2, LocalHom *localhompt, int off1, int off2, int opt, int overlapaa )
+{
+	int pos1, pos2, start1, start2, end1, end2;
+	char *pt1, *pt2;
+	double score;
+	double sumscore;
+	int sumoverlap;
+	LocalHom *tmppt = localhompt;
+	int nlocalhom = 0;
+	int st;
+	pt1 = al1; pt2 = al2;
+	pos1 = off1; pos2 = off2;
+
+
+	sumscore = 0.0;
+	sumoverlap = 0;
+	start1 = 0; // by D.Mathog, a guess
+	start2 = 0; // by D.Mathog, a guess
+
+	st = 0;
+	score = 0.0;
+	while( *pt1 != 0 )
+	{
+//		fprintf( stderr, "pt = %c, %c, st=%d\n", *pt1, *pt2, st );
+		if( st == 1 && ( *pt1 == '-' || *pt2 == '-' ) )
+		{
+			end1 = pos1 - 1;
+			end2 = pos2 - 1;
+
+			if( nlocalhom++ > 0 )
+			{
+//				fprintf( stderr, "reallocating ...\n" );
+				tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//				fprintf( stderr, "done\n" );
+				tmppt = tmppt->next;
+				tmppt->next = NULL;
+			}
+			tmppt->start1 = start1;
+			tmppt->start2 = start2;
+			tmppt->end1   = end1  ;
+			tmppt->end2   = end2  ;
+
+#if 1
+			if( divpairscore )
+			{
+				tmppt->overlapaa   = end2-start2+1;
+				tmppt->opt = score / tmppt->overlapaa * 5.8 / 600;
+			}
+			else
+			{
+				sumscore += score;
+				sumoverlap += end2-start2+1;
+			}
+#else
+			tmppt->overlapaa   = overlapaa;
+			tmppt->opt = (double)opt;
+#endif
+
+#if 0
+			fprintf( stderr, "score (1)= %f\n", score );
+			fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+			fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+			score = 0.0;
+			st = 0;
+		}
+		else if( *pt1 != '-' && *pt2 != '-' )
+		{
+			if( st == 0 )
+			{
+				start1 = pos1; start2 = pos2;
+				st = 1;
+			}
+			score += (double)n_dis[(int)amino_n[(int)*pt1]][(int)amino_n[(int)*pt2]]; // - offset ¤Ï¤¤¤é¤Ê¤¤¤«¤â
+//			fprintf( stderr, "%c-%c, score(0) = %f\n", *pt1, *pt2, score );
+		}
+		if( *pt1++ != '-' ) pos1++;
+		if( *pt2++ != '-' ) pos2++;
+	}
+	if( nlocalhom++ > 0 )
+	{
+//		fprintf( stderr, "reallocating ...\n" );
+		tmppt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+//		fprintf( stderr, "done\n" );
+		tmppt = tmppt->next;
+		tmppt->next = NULL;
+	}
+	end1 = pos1 - 1;
+	end2 = pos2 - 1;
+	tmppt->start1 = start1;
+	tmppt->start2 = start2;
+	tmppt->end1   = end1  ;
+	tmppt->end2   = end2  ;
+
+#if 1
+	if( divpairscore )
+	{
+		tmppt->overlapaa   = end2-start2+1;
+		tmppt->opt = score / tmppt->overlapaa * 5.8 / 600;
+	}
+	else
+	{
+		sumscore += score;
+		sumoverlap += end2-start2+1;
+	}
+#else
+	tmppt->overlapaa   = overlapaa;
+	tmppt->opt = (double)opt;
+#endif
+
+#if 0
+	fprintf( stderr, "score (2)= %f\n", score );
+	fprintf( stderr, "al1: %d - %d\n", start1, end1 );
+	fprintf( stderr, "al2: %d - %d\n", start2, end2 );
+#endif
+
+	if( !divpairscore )
+	{
+		for( tmppt=localhompt; tmppt; tmppt=tmppt->next )
+		{
+			tmppt->overlapaa = sumoverlap;
+			tmppt->opt = sumscore * 5.8 / 600 / sumoverlap;
+//			fprintf( stderr, "tmpptr->opt = %f\n", tmppt->opt );
+		}
+	}
+}
+
+char *cutal( char *al, int al_display_start, int start, int end )
+{
+	int pos;
+	char *pt = al;
+	char *val = NULL;
+
+	pos = al_display_start;
+	do
+	{
+		if( start == pos ) val = pt;
+		if( end == pos ) break;
+//		fprintf( stderr, "pos=%d, *pt=%c, val=%p\n", pos, *pt, val );
+		if( *pt != '-' ) pos++;
+	} while( *pt++ != 0 );
+	*(pt+1) = 0;
+	return( val );
+}
+
+void ErrorExit( char *message )
+{
+	fprintf( stderr, "%s\n", message );
+	exit( 1 );
+}
+
+void strncpy_caseC( char *str1, char *str2, int len )
+{
+	if( dorp == 'd' && upperCase > 0 ) 
+	{
+		while( len-- )
+			*str1++ = toupper( *str2++ );
+	}
+	else strncpy( str1, str2, len );
+}
+	
+void seqUpper( int nseq, char **seq ) /* not used */
+{
+	int i, j, len;
+	for( i=0; i<nseq; i++ ) 
+	{
+		len = strlen( seq[i] );
+		for( j=0; j<len; j++ ) 
+			seq[i][j] = toupper( seq[i][j] );
+	}
+}
+
+void seqLower( int nseq, char **seq )
+{
+	int i, j, len;
+	for( i=0; i<nseq; i++ ) 
+	{
+		len = strlen( seq[i] );
+		for( j=0; j<len; j++ ) 
+			seq[i][j] = tolower( seq[i][j] );
+	}
+}
+
+int getaline_fp_eof( char *s, int l, FILE *fp )  /* end of file -> return 1 */
+{
+    int c, i = 0 ;
+    int noteofflag = 0;
+    for( i=0; i<l && ( noteofflag = ( (c=getc(fp)) != EOF ) ) && c != '\n'; i++ ) 
+    	*s++ = c;
+    *s = '\0' ;
+     return( !noteofflag );
+}
+
+int getaline_fp_eof_new(s, l, fp)  /* end of file -> return 1 */
+char    s[] ; int l ; FILE *fp ;
+{
+        int c = 0, i = 0 ;
+		int noteofflag = 0;
+
+		if( feof( fp ) ) return( 1 );
+
+		for( i=0; i<l && ( noteofflag = ( (c=getc(fp)) != EOF ) ) && c != '\n'; i++ ) 
+        { *s++ = c ; }
+        *s = '\0' ;
+		if( c != '\n' && c != EOF ) while( getc(fp) != '\n' )
+			;
+		return( !noteofflag );
+}
+
+int myfgets(s, l, fp)  /* l°Ê¾å¤Ï¡¢¹ÔËö¤Þ¤ÇÆɤßÈô¤Ð¤¹ */
+char    s[] ; int l ; FILE *fp ;
+{
+        int     c = 0, i = 0 ;
+
+		if( feof( fp ) ) return( 1 );
+
+		for( i=0; i<l && ( c=getc( fp ) ) != '\n'; i++ ) 
+        	*s++ = c;
+        *s = '\0' ;
+		if( c != '\n' ) 
+			while( getc(fp) != '\n' )
+				;
+		return( 0 );
+}
+
+float input_new( FILE *fp, int d )
+{
+	char mojiretsu[10];
+	int i, c;
+
+	c = getc( fp );
+	if( c != '\n' )
+		ungetc( c, fp );
+
+	for( i=0; i<d; i++ )
+		mojiretsu[i] = getc( fp );
+	mojiretsu[i] = 0;
+
+	return( atof( mojiretsu ) );
+}
+
+
+void PreRead( FILE *fp, int *locnjob, int *locnlenmax )
+{
+	int i, nleni;
+	char b[B];
+
+	fgets( b, B-1, fp ); *locnjob = atoi( b );
+	*locnlenmax = 0;
+	i=0; 
+	while( i<*locnjob )
+	{
+		fgets( b, B-1, fp );
+		if( !strncmp( b, "=", 1 ) )
+		{
+			i++;
+			fgets( b, B-1, fp ); nleni = atoi( b );
+			if( nleni > *locnlenmax ) *locnlenmax = nleni;
+		}
+	}
+	if( *locnlenmax > N )
+	{
+		fprintf( stderr, "TOO LONG SEQUENCE!\n" );
+		exit( 1 );
+	}
+	if( njob > M  ) 
+	{
+		fprintf( stderr, "TOO MANY SEQUENCE!\n" );
+		fprintf( stderr, "%d > %d\n", njob, M );
+		exit( 1 );
+	}
+}	
+
+int allSpace( char *str )
+{
+	int value = 1;
+	while( *str ) value *= ( !isdigit( *str++ ) );
+	return( value );
+}
+	
+void Read( char name[M][B], int nlen[M], char **seq )
+{
+	extern void FRead( FILE *x, char y[M][B], int z[M], char **w );
+	FRead( stdin, name, nlen, seq );
+}
+
+
+void FRead( FILE *fp, char name[][B], int nlen[], char **seq )
+{
+	int i, j; 
+	char b[B];
+
+	fgets( b, B-1, fp );
+#if DEBUG
+	fprintf( stderr, "b = %s\n", b );
+#endif
+
+    if( strstr( b, "onnet" ) ) scoremtx = 1;
+    else if( strstr( b, "DnA" ) ) 
+	{
+		scoremtx = -1; 
+		upperCase = -1;
+	}
+    else if( strstr( b, "dna" ) ) 
+	{
+		scoremtx = -1; 
+		upperCase = 0;
+	}
+	else if( strstr( b, "DNA" ) )
+	{
+		scoremtx = -1; 
+		upperCase = 1;
+	}
+    else if( strstr( b, "M-Y" ) || strstr( b, "iyata" ) ) scoremtx = 2; 
+    else scoremtx = 0;
+#if DEBUG
+	fprintf( stderr, " %s->scoremtx = %d\n", b, scoremtx );
+#endif
+
+	geta2 = GETA2;
+
+#if 0
+	if( strlen( b ) >=25 )
+	{
+		b[25] = 0;
+	#if DEBUG
+		fprintf( stderr, "kimuraR = %s\n", b+20 );
+	#endif
+		kimuraR = atoi( b+20 );
+
+		if( kimuraR < 0 || 20 < kimuraR ) ErrorExit( "Illeagal kimuraR value.\n" );
+		if( allSpace( b+20 ) ) kimuraR = NOTSPECIFIED;
+	}
+	else kimuraR = NOTSPECIFIED;
+	#if DEBUG
+	fprintf( stderr, "kimuraR = %d\n", kimuraR );
+	#endif
+
+	if( strlen( b ) >=20 )
+	{
+		b[20] = 0;
+	#if DEBUG
+		fprintf( stderr, "pamN = %s\n", b+15 );
+	#endif
+		pamN = atoi( b+15 );
+		if( pamN < 0 || 400 < pamN ) ErrorExit( "Illeagal pam value.\n" );
+		if( allSpace( b+15 ) ) pamN = NOTSPECIFIED;
+	}
+	else pamN = NOTSPECIFIED;
+
+	if( strlen( b ) >= 15 )
+	{
+		b[15] = 0;
+	#if DEBUG
+		fprintf( stderr, "poffset = %s\n", b+10 );
+	#endif
+		poffset = atoi( b+10 );
+		if( poffset > 500 ) ErrorExit( "Illegal extending gap ppenalty\n" );
+		if( allSpace( b+10 ) ) poffset = NOTSPECIFIED;
+	}
+	else poffset = NOTSPECIFIED;
+
+	if( strlen( b ) >= 10 )
+	{
+		b[10] = 0;
+	#if DEBUG
+		fprintf( stderr, "ppenalty = %s\n", b+5 );
+	#endif
+		ppenalty = atoi( b+5 );
+		if( ppenalty > 0 ) ErrorExit( "Illegal opening gap ppenalty\n" );
+		if( allSpace( b+5 ) ) ppenalty = NOTSPECIFIED;
+	}
+	else ppenalty = NOTSPECIFIED;
+#endif
+
+	for( i=0; i<njob; i++ )
+	{
+		getaline_fp_eof_new( b, B-1, fp );
+		strcpy( name[i], b );
+#if DEBUG
+		fprintf( stderr, "name[%d] = %s\n", i, name[i] );
+#endif
+		fgets( b, B-1, fp ); nlen[i] = atoi( b );      /* seq i no nagasa */
+		seq[i][0] = 0;
+		if( nlen[i] ) for( j=0; j <= (nlen[i]-1)/C; j++ )
+		{
+			getaline_fp_eof_new( b, B-1, fp );
+			/*	b[C] = 0;  */
+			strcat( seq[i], b );
+		} 
+		seq[i][nlen[i]] = 0;
+	}
+	if( scoremtx == -1 && upperCase != -1 ) seqLower( njob, seq );
+}
+
+
+static int countKUorWA( FILE *fp )
+{
+	int value;
+	int c, b;
+
+	value= 0;
+	b = '\n';
+	while( ( c = getc( fp ) ) != EOF )
+	{
+		if( b == '\n' && ( c == '=' || c == '>' ) )
+			value++;
+		b = c;
+	}
+	rewind( fp );
+	return( value );
+}
+
+void searchKUorWA( FILE *fp )
+{
+	int c, b;
+	b = '\n';
+	while( !( ( ( c = getc( fp ) ) == '>' || c == '=' || c == EOF ) && b == '\n' ) )
+		b = c;
+	ungetc( c, fp );
+}
+
+static int onlyAlpha_lower( char *str )
+{
+	char tmp;
+	char *res = str;
+	char *bk = str;
+
+	while( (tmp=*str++) )
+		if( isalpha( tmp ) || tmp == '-' || tmp == '*' || tmp == '.' )
+			*res++ = tolower( tmp );
+	*res = 0;
+	return( res - bk );
+}
+static int onlyAlpha_upper( char *str )
+{
+	char tmp;
+	char *res = str;
+	char *bk = str;
+
+	while( (tmp=*str++) )
+		if( isalpha( tmp ) || tmp == '-' || tmp == '*' || tmp == '.' )
+			*res++ = toupper( tmp );
+	*res = 0;
+	return( res - bk );
+}
+
+void kake2hiku( char *str )
+{
+	do
+		if( *str == '*' ) *str = '-';
+	while( *str++ );
+}
+
+char *load1SeqWithoutName_realloc( FILE *fpp )
+{
+	int c, b;
+	char *cbuf;
+	int size = N;
+	char *val;
+
+	val = malloc( (size+1) * sizeof( char ) );
+	cbuf = val;
+
+	b = '\n';
+	while( ( c = getc( fpp ) ) != EOF &&           
+          !( ( c == '>' || c == '=' || c == '(' || c == EOF ) && b == '\n' ) )
+	{
+		*cbuf++ = (char)c;  /* Ť¹¤®¤Æ¤â¤·¤é¤Ê¤¤ */
+		if( cbuf - val == size )
+		{
+			size += N;
+			fprintf( stderr, "reallocating...\n" );
+			val = (char *)realloc( val, (size+1) * sizeof( char ) );
+			if( !val )
+			{
+				fprintf( stderr, "Allocation error in load1SeqWithoutName_realloc \n" );
+				exit( 1 );
+			}
+			fprintf( stderr, "done.\n" );
+			cbuf = val + size-N;
+		}
+		b = c;
+	}
+	ungetc( c, fpp );
+	*cbuf = 0;
+	if( dorp == 'd' )
+		onlyAlpha_lower( val );
+	else
+		onlyAlpha_upper( val );
+	kake2hiku( val );
+	return( val );
+}
+
+int load1SeqWithoutName_new( FILE *fpp, char *cbuf )
+{
+	int c, b;
+	char *bk = cbuf;
+
+	b = '\n';
+	while( ( c = getc( fpp ) ) != EOF &&                    /* by T. Nishiyama */
+          !( ( c == '>' || c == '=' || c == '(' || c == EOF ) && b == '\n' ) )
+	{
+		*cbuf++ = (char)c;  /* Ť¹¤®¤Æ¤â¤·¤é¤Ê¤¤ */
+		b = c;
+	}
+	ungetc( c, fpp );
+	*cbuf = 0;
+	if( dorp == 'd' )
+		onlyAlpha_lower( bk );
+	else
+		onlyAlpha_upper( bk );
+	kake2hiku( bk );
+	return( 0 );
+}
+
+
+void readDataforgaln( FILE *fp, char **name, int *nlen, char **seq )
+{
+	int i; 
+	static char *tmpseq = NULL;
+
+#if 0
+	if( !tmpseq )
+	{
+		tmpseq = AllocateCharVec( N );
+	}
+#endif
+
+	rewind( fp );
+	searchKUorWA( fp );
+
+	for( i=0; i<njob; i++ )
+	{
+		name[i][0] = '='; getc( fp ); 
+#if 0
+		fgets( name[i]+1, B-2, fp ); 
+		j = strlen( name[i] );
+		if( name[i][j-1] != '\n' )
+			ErrorExit( "Too long name\n" );
+		name[i][j-1] = 0;
+#else
+		myfgets( name[i]+1, B-2, fp ); 
+#endif
+#if 0
+		fprintf( stderr, "name[%d] = %s\n", i, name[i] );
+#endif
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		strcpy( seq[i], tmpseq );
+		nlen[i] = strlen( seq[i] );
+		free( tmpseq );
+	}
+	if( dorp == 'd' && upperCase != -1 ) seqLower( njob, seq );
+#if 0
+	free( tmpseq );
+#endif
+}
+
+void readData_varlen( FILE *fp, char **name, int *nlen, char **seq )
+{
+	int i; 
+	static char *tmpseq = NULL;
+
+	rewind( fp );
+	searchKUorWA( fp );
+
+	for( i=0; i<njob; i++ )
+	{
+		name[i][0] = '='; getc( fp ); 
+#if 0
+		fgets( name[i]+1, B-2, fp ); 
+		j = strlen( name[i] );
+		if( name[i][j-1] != '\n' )
+			ErrorExit( "Too long name\n" );
+		name[i][j-1] = 0;
+#else
+		myfgets( name[i]+1, B-2, fp ); 
+#endif
+#if 0
+		fprintf( stderr, "name[%d] = %s\n", i, name[i] );
+#endif
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		nlen[i] = strlen( tmpseq );
+//		fprintf( stderr, "nlen[%d] = %d\n", i+1, nlen[i] );
+		seq[i] = calloc( nlen[i]+1, sizeof( char ) );
+		strcpy( seq[i], tmpseq );
+		free( tmpseq );
+	}
+	if( dorp == 'd' && upperCase != -1 ) seqLower( njob, seq );
+#if 0
+	free( tmpseq );
+#endif
+}
+
+void readData_pointer( FILE *fp, char **name, int *nlen, char **seq )
+{
+	int i; 
+	static char *tmpseq = NULL;
+
+#if 0
+	if( !tmpseq )
+	{
+		tmpseq = AllocateCharVec( N );
+	}
+#endif
+
+	rewind( fp );
+	searchKUorWA( fp );
+
+	for( i=0; i<njob; i++ )
+	{
+		name[i][0] = '='; getc( fp ); 
+#if 0
+		fgets( name[i]+1, B-2, fp ); 
+		j = strlen( name[i] );
+		if( name[i][j-1] != '\n' )
+			ErrorExit( "Too long name\n" );
+		name[i][j-1] = 0;
+#else
+		myfgets( name[i]+1, B-2, fp ); 
+#endif
+#if 0
+		fprintf( stderr, "name[%d] = %s\n", i, name[i] );
+#endif
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		strcpy( seq[i], tmpseq );
+		free( tmpseq );
+		nlen[i] = strlen( seq[i] );
+	}
+	if( dorp == 'd' && upperCase != -1 ) seqLower( njob, seq );
+#if 0
+	free( tmpseq );
+#endif
+}
+
+void readData( FILE *fp, char name[][B], int nlen[], char **seq )
+{
+	int i; 
+	static char *tmpseq = NULL;
+
+#if 0
+	if( !tmpseq )
+	{
+		tmpseq = AllocateCharVec( N );
+	}
+#endif
+
+	rewind( fp );
+	searchKUorWA( fp );
+
+	for( i=0; i<njob; i++ )
+	{
+		name[i][0] = '='; getc( fp ); 
+#if 0
+		fgets( name[i]+1, B-2, fp ); 
+		j = strlen( name[i] );
+		if( name[i][j-1] != '\n' )
+			ErrorExit( "Too long name\n" );
+		name[i][j-1] = 0;
+#else
+		myfgets( name[i]+1, B-2, fp ); 
+#endif
+#if 0
+		fprintf( stderr, "name[%d] = %s\n", i, name[i] );
+#endif
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		strcpy( seq[i], tmpseq );
+		nlen[i] = strlen( seq[i] );
+		free( tmpseq );
+	}
+	if( dorp == 'd' && upperCase != -1 ) seqLower( njob, seq );
+#if 0
+	free( tmpseq );
+#endif
+}
+
+
+int countATGC( char *s, int *total )
+{
+	int nATGC;
+	int nChar;
+	char c;
+	nATGC = nChar = 0;
+
+	if( *s == 0 ) 
+	{
+		total = 0;
+		return( 0 );
+	}
+
+	do
+	{
+		c = tolower( *s );
+		if( isalpha( c ) )
+		{
+			nChar++;
+			if( c == 'a' || c == 't' || c == 'g' || c == 'c' || c == 'u' || c == 'n' )
+				nATGC++;
+		}
+	}
+	while( *++s );
+
+	*total = nChar;
+	return( nATGC );
+}
+
+double countATGCbk( char *s )
+{
+	int nATGC;
+	int nChar;
+	char c;
+	nATGC = nChar = 0;
+
+	do
+	{
+		c = tolower( *s );
+		if( isalpha( c ) )
+		{
+			nChar++;
+			if( c == 'a' || c == 't' || c == 'g' || c == 'c' || c == 'u' || c == 'n' )
+				nATGC++;
+		}
+	}
+	while( *++s );
+	return( (double)nATGC / nChar );
+}
+
+
+int countalpha( char *seq )
+{
+	int val = 0;
+	while( *seq )
+		if( isalpha( *seq++ ) ) val++;
+	return( val );
+}
+
+void getnumlen_nogap( FILE *fp, int *nlenminpt )
+{
+	int total;
+	int nsite;
+	int atgcnum;
+	int i, tmp;
+	char *tmpseq, *tmpname;
+	double atgcfreq;
+	tmpname = AllocateCharVec( N );
+	njob = countKUorWA( fp );
+	searchKUorWA( fp );
+	nlenmax = 0;
+	*nlenminpt = 99999999;
+	atgcnum = 0;
+	total = 0;
+	for( i=0; i<njob; i++ )
+	{
+		myfgets( tmpname, N-1, fp );
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		tmp = countalpha( tmpseq );
+		if( tmp > nlenmax ) nlenmax  = tmp;
+		if( tmp < *nlenminpt ) *nlenminpt  = tmp;
+		atgcnum += countATGC( tmpseq, &nsite );
+		total += nsite;
+		free( tmpseq );
+	}
+	free( tmpname );
+	atgcfreq = (double)atgcnum / total;
+	fprintf( stderr, "##### atgcfreq = %f\n", atgcfreq );
+	if( dorp == NOTSPECIFIED )
+	{
+		if( atgcfreq > 0.75 ) 	
+		{
+			dorp = 'd';
+			upperCase = -1;
+		}
+		else                  
+		{
+			dorp = 'p';
+			upperCase = 0;
+		}
+	}
+}
+
+void getnumlen( FILE *fp )
+{
+	int total;
+	int nsite;
+	int atgcnum;
+	int i, tmp;
+	char *tmpseq;
+	char *tmpname;
+	double atgcfreq;
+	tmpname = AllocateCharVec( N );
+	njob = countKUorWA( fp );
+	searchKUorWA( fp );
+	nlenmax = 0;
+	atgcnum = 0;
+	total = 0;
+	for( i=0; i<njob; i++ )
+	{
+		myfgets( tmpname, N-1, fp );
+		tmpseq = load1SeqWithoutName_realloc( fp );
+		tmp = strlen( tmpseq );
+		if( tmp > nlenmax ) nlenmax  = tmp;
+		atgcnum += countATGC( tmpseq, &nsite );
+		total += nsite;
+//		fprintf( stderr, "##### total = %d\n", total );
+		free( tmpseq );
+	}
+
+	atgcfreq = (double)atgcnum / total;
+//	fprintf( stderr, "##### atgcfreq = %f\n", atgcfreq );
+	if( dorp == NOTSPECIFIED )
+	{
+		if( atgcfreq > 0.75 ) 	
+		{
+			dorp = 'd';
+			upperCase = -1;
+		}
+		else                  
+		{
+			dorp = 'p';
+			upperCase = 0;
+		}
+	}
+	free( tmpname );
+}
+	
+
+
+void WriteGapFill( FILE *fp, int locnjob, char name[][B], int nlen[M], char **aseq )
+{
+	static char b[N];
+	int i, j;
+	int nalen[M];
+	static char gap[N];
+	static char buff[N];
+
+#if IODEBUG
+	fprintf( stderr, "IMAKARA KAKU\n" );
+#endif
+	nlenmax = 0;
+	for( i=0; i<locnjob; i++ )
+	{
+		int len = strlen( aseq[i] );
+		if( nlenmax < len ) nlenmax = len;
+	}
+
+	for( i=0; i<nlenmax; i++ ) gap[i] = '-';
+	gap[nlenmax] = 0;
+
+	fprintf( fp, "%5d", locnjob );
+	fprintf( fp, "\n" );
+
+	for( i=0; i<locnjob; i++ )
+	{
+		strcpy( buff, aseq[i] );
+		strncat( buff, gap, nlenmax-strlen( aseq[i] ) );
+		buff[nlenmax] = 0;
+		nalen[i] = strlen( buff );
+		fprintf( fp, "%s\n", name[i] );
+		fprintf( fp, "%5d\n", nalen[i] );
+		for( j=0; j<nalen[i]; j=j+C )
+		{
+			strncpy_caseC( b, buff+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+		}
+	}
+#if DEBUG
+	fprintf( stderr, "nalen[0] = %d\n", nalen[0] );
+#endif
+#if IODEBUG
+	fprintf( stderr, "KAKIOWATTA\n" );
+#endif
+}
+
+void writeDataforgaln( FILE *fp, int locnjob, char **name, int *nlen, char **aseq )
+{
+	int i, j;
+	int nalen;
+
+	for( i=0; i<locnjob; i++ )
+	{
+		nalen = strlen( aseq[i] );
+		fprintf( fp, ">%s\n", name[i]+1 );
+		for( j=0; j<nalen; j=j+C )
+		{
+#if 0
+			strncpy( b, aseq[i]+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+#else
+			fprintf( fp, "%.*s\n", C, aseq[i]+j );
+#endif
+		}
+	}
+}
+
+void writeData_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq )
+{
+	int i, j;
+	int nalen;
+
+	for( i=0; i<locnjob; i++ )
+	{
+#if DEBUG
+		fprintf( stderr, "i = %d in writeData\n", i );
+#endif
+		nalen = strlen( aseq[i] );
+		fprintf( fp, ">%s\n", name[i]+1 );
+		for( j=0; j<nalen; j=j+C )
+		{
+#if 0
+			strncpy( b, aseq[i]+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+#else
+			fprintf( fp, "%.*s\n", C, aseq[i]+j );
+#endif
+		}
+	}
+}
+
+void writeData( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq )
+{
+	int i, j;
+	int nalen;
+
+	for( i=0; i<locnjob; i++ )
+	{
+#if DEBUG
+		fprintf( stderr, "i = %d in writeData\n", i );
+#endif
+		nalen = strlen( aseq[i] );
+		fprintf( fp, ">%s\n", name[i]+1 );
+		for( j=0; j<nalen; j=j+C )
+		{
+#if 0
+			strncpy( b, aseq[i]+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+#else
+			fprintf( fp, "%.*s\n", C, aseq[i]+j );
+#endif
+		}
+	}
+}
+
+
+void write1seq( FILE *fp, char *aseq )
+{
+	int j;
+	int nalen;
+
+	nalen = strlen( aseq );
+	for( j=0; j<nalen; j=j+C )
+		fprintf( fp, "%.*s\n", C, aseq+j );
+}
+
+
+
+void readhat2_floathalf_pointer( FILE *fp, int nseq, char **name, float **mtx )
+{
+    int i, j, nseq0;
+    char b[B];
+
+    fgets( b, B, fp );
+    fgets( b, B, fp ); b[5] = 0; nseq0 = atoi( b ); if( nseq != nseq0 ) ErrorExit( "hat2 is wrong." );
+    fgets( b, B, fp );
+    for( i=0; i<nseq; i++ )
+    {
+#if 0
+        getaline_fp_eof( b, B, fp ); 
+#else
+		myfgets( b, B-2, fp );
+#endif
+#if 0
+		j = MIN( strlen( b+6 ), 10 );
+        if( strncmp( name[i], b+6 , j ) ) 
+		{
+			fprintf( stderr, "Error in hat2\n" );
+			fprintf( stderr, "%s != %s\n", b, name[i] );
+			exit( 1 );
+		}
+#endif
+    }
+    for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+    {
+        mtx[i][j-i] = ( input_new( fp, D ) );
+    }
+}
+void readhat2_floathalf( FILE *fp, int nseq, char name[M][B], float **mtx )
+{
+    int i, j, nseq0;
+    char b[B];
+
+    fgets( b, B, fp );
+    fgets( b, B, fp ); b[5] = 0; nseq0 = atoi( b ); if( nseq != nseq0 ) ErrorExit( "hat2 is wrong." );
+    fgets( b, B, fp );
+    for( i=0; i<nseq; i++ )
+    {
+#if 0
+        getaline_fp_eof( b, B, fp ); 
+#else
+		myfgets( b, B-2, fp );
+#endif
+#if 0
+		j = MIN( strlen( b+6 ), 10 );
+        if( strncmp( name[i], b+6 , j ) ) 
+		{
+			fprintf( stderr, "Error in hat2\n" );
+			fprintf( stderr, "%s != %s\n", b, name[i] );
+			exit( 1 );
+		}
+#endif
+    }
+    for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+    {
+        mtx[i][j-i] = ( input_new( fp, D ) );
+    }
+}
+void readhat2_float( FILE *fp, int nseq, char name[M][B], float **mtx )
+{
+    int i, j, nseq0;
+    char b[B];
+
+    fgets( b, B, fp );
+    fgets( b, B, fp ); b[5] = 0; nseq0 = atoi( b ); if( nseq != nseq0 ) ErrorExit( "hat2 is wrong." );
+    fgets( b, B, fp );
+    for( i=0; i<nseq; i++ )
+    {
+#if 0
+        getaline_fp_eof( b, B, fp ); 
+#else
+		myfgets( b, B-2, fp );
+#endif
+#if 0
+		j = MIN( strlen( b+6 ), 10 );
+        if( strncmp( name[i], b+6 , j ) ) 
+		{
+			fprintf( stderr, "Error in hat2\n" );
+			fprintf( stderr, "%s != %s\n", b, name[i] );
+			exit( 1 );
+		}
+#endif
+    }
+    for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+    {
+        mtx[i][j] = ( input_new( fp, D ) );
+    }
+}
+void readhat2_int( FILE *fp, int nseq, char name[M][B], int **mtx )
+{
+    int i, j, nseq0;
+    char b[B];
+
+    fgets( b, B, fp );
+    fgets( b, B, fp ); b[5] = 0; nseq0 = atoi( b ); if( nseq != nseq0 ) ErrorExit( "hat2 is wrong." );
+    fgets( b, B, fp );
+    for( i=0; i<nseq; i++ )
+    {
+#if 0
+        getaline_fp_eof( b, B, fp ); 
+#else
+		myfgets( b, B-2, fp );
+#endif
+#if 0
+		j = MIN( strlen( b+6 ), 10 );
+        if( strncmp( name[i], b+6 , j ) ) 
+		{
+			fprintf( stderr, "Error in hat2\n" );
+			fprintf( stderr, "%s != %s\n", b, name[i] );
+			exit( 1 );
+		}
+#endif
+    }
+    for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+    {
+        mtx[i][j] = (int)( input_new( fp, D ) * INTMTXSCALE + 0.5 );
+    }
+}
+void readhat2( FILE *fp, int nseq, char name[M][B], double **mtx )
+{
+    int i, j, nseq0;
+    char b[B];
+
+    fgets( b, B, fp );
+    fgets( b, B, fp ); b[5] = 0; nseq0 = atoi( b ); if( nseq != nseq0 ) ErrorExit( "hat2 is wrong." );
+    fgets( b, B, fp );
+    for( i=0; i<nseq; i++ )
+    {
+#if 0
+        getaline_fp_eof( b, B, fp ); 
+#else
+		myfgets( b, B-2, fp );
+#endif
+#if 0
+		j = MIN( strlen( b+6 ), 10 );
+        if( strncmp( name[i], b+6 , j ) ) 
+		{
+			fprintf( stderr, "Error in hat2\n" );
+			fprintf( stderr, "%s != %s\n", b, name[i] );
+			exit( 1 );
+		}
+#endif
+    }
+    for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+    {
+        mtx[i][j] = (double)input_new( fp, D);
+    }
+}
+
+void WriteFloatHat2_pointer( FILE *hat2p, int locnjob, char **name, float **mtx )
+{
+	int i, j;
+	double max = 0.0;
+	for( i=0; i<locnjob-1; i++ ) for( j=1; j<locnjob-i; j++ ) if( mtx[i][j] > max ) max = mtx[i][j];
+
+	fprintf( hat2p, "%5d\n", 1 );
+	fprintf( hat2p, "%5d\n", locnjob );
+	fprintf( hat2p, " %#6.3f\n", max * 2.5 );
+
+	for( i=0; i<locnjob; i++ ) fprintf( hat2p, "%4d. %s\n", i+1, name[i] );
+	for( i=0; i<locnjob; i++ )
+	{
+		for( j=1; j<locnjob-i; j++ ) 
+		{
+			fprintf( hat2p, "%#6.3f", mtx[i][j] );
+			if( j % 12 == 0 || j == locnjob-i-1 ) fprintf( hat2p, "\n" );
+		}
+	}
+}
+
+void WriteFloatHat2( FILE *hat2p, int locnjob, char name[M][B], float **mtx )
+{
+	int i, j;
+	double max = 0.0;
+	for( i=0; i<locnjob-1; i++ ) for( j=1; j<locnjob-i; j++ ) if( mtx[i][j] > max ) max = mtx[i][j];
+
+	fprintf( hat2p, "%5d\n", 1 );
+	fprintf( hat2p, "%5d\n", locnjob );
+	fprintf( hat2p, " %#6.3f\n", max * 2.5 );
+
+	for( i=0; i<locnjob; i++ ) fprintf( hat2p, "%4d. %s\n", i+1, name[i] );
+	for( i=0; i<locnjob; i++ )
+	{
+		for( j=1; j<locnjob-i; j++ ) 
+		{
+			fprintf( hat2p, "%#6.3f", mtx[i][j] );
+			if( j % 12 == 0 || j == locnjob-i-1 ) fprintf( hat2p, "\n" );
+		}
+	}
+}
+
+void WriteHat2_int( FILE *hat2p, int locnjob, char name[M][B], int **mtx )
+{
+	int i, j;
+	double max = 0.0;
+	for( i=0; i<locnjob-1; i++ ) for( j=i+1; j<locnjob; j++ ) if( mtx[i][j] > max ) max = mtx[i][j];
+	max /= INTMTXSCALE;
+
+	fprintf( hat2p, "%5d\n", 1 );
+	fprintf( hat2p, "%5d\n", locnjob );
+	fprintf( hat2p, " %#6.3f\n", max * 2.5 );
+
+	for( i=0; i<locnjob; i++ ) fprintf( hat2p, "%4d. %s\n", i+1, name[i] );
+	for( i=0; i<locnjob-1; i++ )
+	{
+		for( j=i+1; j<locnjob; j++ ) 
+		{
+			fprintf( hat2p, "%#6.3f", (float)mtx[i][j] / INTMTXSCALE );
+			if( (j-i) % 12 == 0 || j == locnjob-1 ) fprintf( hat2p, "\n" );
+		}
+	}
+}
+void WriteHat2( FILE *hat2p, int locnjob, char name[M][B], double **mtx )
+{
+	int i, j;
+	double max = 0.0;
+	for( i=0; i<locnjob-1; i++ ) for( j=i+1; j<locnjob; j++ ) if( mtx[i][j] > max ) max = mtx[i][j];
+
+	fprintf( hat2p, "%5d\n", 1 );
+	fprintf( hat2p, "%5d\n", locnjob );
+	fprintf( hat2p, " %#6.3f\n", max * 2.5 );
+
+	for( i=0; i<locnjob; i++ ) fprintf( hat2p, "%4d. %s\n", i+1, name[i] );
+	for( i=0; i<locnjob-1; i++ )
+	{
+		for( j=i+1; j<locnjob; j++ ) 
+		{
+			fprintf( hat2p, "%#6.3f", mtx[i][j] );
+			if( (j-i) % 12 == 0 || j == locnjob-1 ) fprintf( hat2p, "\n" );
+		}
+	}
+}
+
+void WriteHat2plain( FILE *hat2p, int locnjob, double **mtx )
+{
+	int i, j;
+
+	for( i=0; i<locnjob-1; i++ )
+	{
+		for( j=i+1; j<locnjob; j++ ) 
+		{
+			fprintf( hat2p, "%d-%d d=%.3f\n", i+1, j+1, mtx[i][j] );
+		}
+	}
+}
+
+int ReadFasta_sub( FILE *fp, double *dis, int nseq, char name[M][B] )
+{
+    int i, count=0;
+    char b[B];
+    int junban[M];
+
+    count = 0;
+    for( i=0; i<10000000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+            count++;
+        }
+    }
+
+	for( i=0; i<nseq; i++ ) dis[i] = 0.0;
+    count = 0;
+    for( i=0; i<100000 && count<nseq; i++ )
+    {
+		if( fgets( b, B-1, fp ) ) break;
+        if( !strncmp( name[junban[count]], b, 20  ) )
+        {
+            fgets( b, B-1, fp );
+            dis[junban[count]] = atof( b );
+            count++;
+        }
+    }
+    return 0;
+}
+
+
+int ReadSsearch( FILE *fp, double *dis, int nseq, char name[M][B] )
+{
+    int i, count=0;
+    char b[B];
+    int junban[M];
+	int opt;
+
+    count = 0;
+    for( i=0; i<10000000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+			sscanf( b+75, "%d", &opt ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+        }
+    }
+
+/*
+    count = 0;
+    for( i=0; i<100000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( name[junban[count]], b, 20  ) )
+        {
+            dis[junban[count]] = atof( b+65 );
+            count++;
+        }
+    }
+*/
+    return 0;
+}
+
+int ReadBlastm7_avscore( FILE *fp, double *dis, int nin )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int *junban;
+	double score, sumscore;
+	double len, sumlen;
+	int qstart, qend, tstart, tend;
+	double scorepersite;
+	static char qal[N], tal[N], al[N];
+	int nlocalhom;
+
+	junban = calloc( nin, sizeof( int ) );
+
+	count = 0;
+	sumscore = 0.0;
+	sumlen = 0.0;
+	score = 0.0;
+	len = 0.0;
+	scorepersite = 0.0; // by D.Mathog, a guess
+    while( 1 )
+	{
+
+		if( feof( fp ) ) break;
+
+		while( fgets( b, B-1, fp ) )
+		{
+			if( !strncmp( "          <Hit_def>", b, 19 ) || !strncmp( "              <Hsp_num>", b, 23 ) ) break;
+		}
+
+		if( !strncmp( "          <Hit_def>", b, 19 ) )
+		{
+			junban[count] = atoi( b+31 );
+			nlocalhom = 0;
+		}
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_score>", b, 25 ) ) break;
+		pt = b + 25;
+		score = atof( pt );
+		sumscore += score;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-from>", b, 30 ) ) break;
+		pt = b + 30;
+		qstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-to>", b, 28 ) ) break;
+		pt = b + 28;
+		qend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-from>", b, 28 ) ) break;
+		pt = b + 28;
+		tstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-to>", b, 26 ) ) break;
+		pt = b + 26;
+		tend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_align-len>", b, 29 ) ) break;
+		pt = b + 29;
+		len = atoi( pt );
+		sumlen += len;
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_qseq>", al, 24 ) ) break;
+
+		strcpy( qal, al+24 );
+		pt = qal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_hseq>", al, 24 ) ) break;
+
+		strcpy( tal, al+24 );
+		pt = tal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+//		fprintf( stderr, "t=%d, score = %f, qstart=%d, qend=%d, tstart=%d, tend=%d, overlapaa=%d\n", junban[count], score, qstart, qend, tstart, tend, overlapaa );
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "            </Hsp>:", b, 18 ) ) break;
+
+
+		fgets( b, B-1, fp );
+
+
+		if( !strncmp( "          </Hit_hsps>", b, 21 ) )
+		{
+			dis[junban[count++]] = sumscore;
+			sumscore = 0.0;
+			fgets( b, B-1, fp );
+			fgets( b, B-1, fp );
+			scorepersite = sumscore / sumlen;
+			if( scorepersite != (int)scorepersite )
+			{
+				fprintf( stderr, "ERROR! sumscore=%f, sumlen=%f, and scorepersite=%f\n", sumscore, sumlen, scorepersite );
+				exit( 1 );
+			}
+
+			if( !strncmp( "      </Iteration_hits>", b, 23 ) ) break;
+		}
+	}
+
+	free( junban );
+
+    return (int)scorepersite;
+}
+int ReadBlastm7_scoreonly( FILE *fp, double *dis, int nin )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int *junban;
+	int overlapaa;
+	double score, sumscore;
+	int qstart, qend, tstart, tend;
+	static char qal[N], tal[N], al[N];
+	int nlocalhom;
+
+	junban = calloc( nin, sizeof( int ) );
+
+	count = 0;
+	sumscore = 0.0;
+	score = 0.0;
+    while( 1 )
+	{
+
+		if( feof( fp ) ) break;
+
+		while( fgets( b, B-1, fp ) )
+		{
+			if( !strncmp( "          <Hit_def>", b, 19 ) || !strncmp( "              <Hsp_num>", b, 23 ) ) break;
+		}
+
+		if( !strncmp( "          <Hit_def>", b, 19 ) )
+		{
+			junban[count] = atoi( b+31 );
+			nlocalhom = 0;
+		}
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_score>", b, 25 ) ) break;
+		pt = b + 25;
+		score = atof( pt );
+		sumscore += score;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-from>", b, 30 ) ) break;
+		pt = b + 30;
+		qstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-to>", b, 28 ) ) break;
+		pt = b + 28;
+		qend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-from>", b, 28 ) ) break;
+		pt = b + 28;
+		tstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-to>", b, 26 ) ) break;
+		pt = b + 26;
+		tend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_align-len>", b, 29 ) ) break;
+		pt = b + 29;
+		overlapaa = atoi( pt );
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_qseq>", al, 24 ) ) break;
+
+		strcpy( qal, al+24 );
+		pt = qal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_hseq>", al, 24 ) ) break;
+
+		strcpy( tal, al+24 );
+		pt = tal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+//		fprintf( stderr, "t=%d, score = %f, qstart=%d, qend=%d, tstart=%d, tend=%d, overlapaa=%d\n", junban[count], score, qstart, qend, tstart, tend, overlapaa );
+
+//		nlocalhom += addlocalhom_r( qal, tal, localhomlist+junban[count], qstart, tstart, score, overlapaa, nlocalhom );
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "            </Hsp>:", b, 18 ) ) break;
+
+
+		fgets( b, B-1, fp );
+
+
+		if( !strncmp( "          </Hit_hsps>", b, 21 ) )
+		{
+			dis[junban[count++]] = sumscore;
+			sumscore = 0.0;
+			fgets( b, B-1, fp );
+			fgets( b, B-1, fp );
+			if( !strncmp( "      </Iteration_hits>", b, 23 ) ) break;
+		}
+	}
+
+	free( junban );
+
+    return count;
+}
+
+int ReadBlastm7( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    static int junban[M];
+	int overlapaa;
+	double score, sumscore;
+	int qstart, qend, tstart, tend;
+	static char qal[N], tal[N], al[N];
+	int nlocalhom;
+
+
+
+	count = 0;
+	sumscore = 0.0;
+	score = 0.0;
+	nlocalhom = 0;
+    while( 1 )
+	{
+
+		if( feof( fp ) ) break;
+
+		while( fgets( b, B-1, fp ) )
+		{
+			if( !strncmp( "          <Hit_def>", b, 19 ) || !strncmp( "              <Hsp_num>", b, 23 ) ) break;
+		}
+
+		if( !strncmp( "          <Hit_def>", b, 19 ) )
+		{
+			junban[count] = atoi( b+31 );
+			nlocalhom = 0;
+		}
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_score>", b, 25 ) ) break;
+		pt = b + 25;
+		score = atof( pt );
+		sumscore += score;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-from>", b, 30 ) ) break;
+		pt = b + 30;
+		qstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_query-to>", b, 28 ) ) break;
+		pt = b + 28;
+		qend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-from>", b, 28 ) ) break;
+		pt = b + 28;
+		tstart = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_hit-to>", b, 26 ) ) break;
+		pt = b + 26;
+		tend = atoi( pt ) - 1;
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "              <Hsp_align-len>", b, 29 ) ) break;
+		pt = b + 29;
+		overlapaa = atoi( pt );
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_qseq>", al, 24 ) ) break;
+
+		strcpy( qal, al+24 );
+		pt = qal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+		while( fgets( al, N-100, fp ) )
+			if( !strncmp( "              <Hsp_hseq>", al, 24 ) ) break;
+
+		strcpy( tal, al+24 );
+		pt = tal;
+		while( *++pt != '<' )
+			;
+		*pt = 0;
+
+
+//		fprintf( stderr, "t=%d, score = %f, qstart=%d, qend=%d, tstart=%d, tend=%d, overlapaa=%d\n", junban[count], score, qstart, qend, tstart, tend, overlapaa );
+
+		nlocalhom += addlocalhom_r( qal, tal, localhomlist+junban[count], qstart, tstart, score, overlapaa, nlocalhom );
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "            </Hsp>:", b, 18 ) ) break;
+
+
+		fgets( b, B-1, fp );
+
+
+		if( !strncmp( "          </Hit_hsps>", b, 21 ) )
+		{
+			dis[junban[count++]] = sumscore;
+			sumscore = 0.0;
+			fgets( b, B-1, fp );
+			fgets( b, B-1, fp );
+			if( !strncmp( "      </Iteration_hits>", b, 23 ) ) break;
+		}
+	}
+    return count;
+}
+
+int ReadFasta34noalign( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    static int junban[M];
+	int opt;
+	double z, bits;
+
+
+    count = 0;
+#if 0
+    for( i=0; i<10000000 && count<nseq; i++ )
+#else
+    while( !feof( fp ) )
+#endif
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			pt = strchr( b, ')' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+
+        }
+    }
+
+    return count;
+}
+int ReadFasta34m10_nuc( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    static int junban[M];
+	int overlapaa;
+	int opt, qstart, qend, tstart, tend;
+	double z, bits;
+	int qal_display_start, tal_display_start;
+	static char qal[N], tal[N];
+	char *qal2, *tal2;
+	int c;
+
+
+    count = 0;
+#if 0
+    for( i=0; i<10000000 && count<nseq; i++ )
+#else
+    while( !feof( fp ) )
+#endif
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			if( strchr( b, 'r' ) ) continue;
+
+			pt = strchr( b, ']' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+
+        }
+		else if( 0 == strncmp( ">>+==========+", b, 14 ) )
+		{
+			break;
+		}
+
+    }
+	if( !count ) return -1;
+
+	count = 0;
+    while( 1 )
+	{
+		if( strncmp( ">>+==========+", b, 14 ) )
+		{
+			fgets( b, B-1, fp );
+			if( feof( fp ) ) break;
+			continue;
+		}
+		junban[count++] = atoi( b+14 );
+//		fprintf( stderr, "t = %d\n", atoi( b+14 ) );
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "; fa_opt:", b, 9 ) || !strncmp( "; sw_s-w opt:", b, 13 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		opt = atoi( pt );
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_overlap:", b+4, 9 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		overlapaa = atoi( pt );
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_start:", b+4, 7 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qstart = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_stop:", b+4, 6 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qend = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_display_start:", b+4, 15 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qal_display_start = atoi( pt ) - 1;
+
+		pt = qal;
+		while( (c = fgetc( fp )) )
+		{
+			if( c == '>' ) 
+			{
+				ungetc( c, fp );
+				break;
+			}
+			if( isalpha( c ) || c == '-' ) 
+			*pt++ = c;
+		}
+		*pt = 0;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_start:", b+4, 7 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tstart = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_stop:", b+4, 6 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tend = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_display_start:", b+4, 15 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tal_display_start = atoi( pt ) - 1;
+
+		pt = tal;
+		while( ( c = fgetc( fp ) ) )
+		{
+			if( c == '>' ) 
+			{
+				ungetc( c, fp );
+				break;
+			}
+			if( isalpha( c ) || c == '-' ) 
+			*pt++ = c;
+		}
+		*pt = 0;
+
+//		fprintf( stderr, "(%d-%d:%d-%d)\n", qstart, qend, tstart, tend );
+//		fprintf( stderr, "qal_display_start = %d, tal_display_start = %d\n", qal_display_start, tal_display_start );
+
+//		fprintf( stderr, "qal = %s\n", qal );
+//		fprintf( stderr, "tal = %s\n", tal );
+
+		qal2 = cutal( qal, qal_display_start, qstart, qend );
+		tal2 = cutal( tal, tal_display_start, tstart, tend );
+
+//		fprintf( stderr, "qal2 = %s\n", qal2 );
+//		fprintf( stderr, "tal2 = %s\n", tal2 );
+
+//		fprintf( stderr, "putting   %d - %d, opt = %d\n", qmem, junban[count-1], opt );
+		putlocalhom( qal2, tal2, localhomlist+junban[count-1], qstart, tstart, opt, overlapaa );
+	}
+//	fprintf( stderr, "count = %d\n", count );
+    return count;
+}
+int ReadFasta34m10( FILE *fp, double *dis, int qmem, char name[M][B], LocalHom *localhomlist )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    static int junban[M];
+	int overlapaa;
+	int opt, qstart, qend, tstart, tend;
+	double z, bits;
+	int qal_display_start, tal_display_start;
+	static char qal[N], tal[N];
+	char *qal2, *tal2;
+	int c;
+
+
+    count = 0;
+#if 0
+    for( i=0; i<10000000 && count<nseq; i++ )
+#else
+    while( !feof( fp ) )
+#endif
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			pt = strchr( b, ')' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+
+        }
+		else if( 0 == strncmp( ">>+==========+", b, 14 ) )
+		{
+			break;
+		}
+
+    }
+	if( !count ) return -1;
+
+	count = 0;
+    while( 1 )
+	{
+		if( strncmp( ">>+==========+", b, 14 ) )
+		{
+			fgets( b, B-1, fp );
+			if( feof( fp ) ) break;
+			continue;
+		}
+		junban[count++] = atoi( b+14 );
+//		fprintf( stderr, "t = %d\n", atoi( b+14 ) );
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "; fa_opt:", b, 9 ) || !strncmp( "; sw_s-w opt:", b, 13 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		opt = atoi( pt );
+
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_overlap:", b+4, 9 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		overlapaa = atoi( pt );
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_start:", b+4, 7 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qstart = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_stop:", b+4, 6 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qend = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_display_start:", b+4, 15 ) ) break;
+		pt = strstr( b, ":" ) +1;
+		qal_display_start = atoi( pt ) - 1;
+
+		pt = qal;
+		while( (c = fgetc( fp )) )
+		{
+			if( c == '>' ) 
+			{
+				ungetc( c, fp );
+				break;
+			}
+			if( isalpha( c ) || c == '-' ) 
+			*pt++ = c;
+		}
+		*pt = 0;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_start:", b+4, 7 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tstart = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_stop:", b+4, 6 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tend = atoi( pt ) - 1;
+
+		while( fgets( b, B-1, fp ) )
+			if( !strncmp( "_display_start:", b+4, 15 ) ) break;
+		pt = strstr( b, ":" ) + 1;
+		tal_display_start = atoi( pt ) - 1;
+
+		pt = tal;
+		while( ( c = fgetc( fp ) ) )
+		{
+			if( c == '>' ) 
+			{
+				ungetc( c, fp );
+				break;
+			}
+			if( isalpha( c ) || c == '-' ) 
+			*pt++ = c;
+		}
+		*pt = 0;
+
+//		fprintf( stderr, "(%d-%d:%d-%d)\n", qstart, qend, tstart, tend );
+//		fprintf( stderr, "qal_display_start = %d, tal_display_start = %d\n", qal_display_start, tal_display_start );
+
+//		fprintf( stderr, "qal = %s\n", qal );
+//		fprintf( stderr, "tal = %s\n", tal );
+
+		qal2 = cutal( qal, qal_display_start, qstart, qend );
+		tal2 = cutal( tal, tal_display_start, tstart, tend );
+
+//		fprintf( stderr, "qal2 = %s\n", qal2 );
+//		fprintf( stderr, "tal2 = %s\n", tal2 );
+
+//		fprintf( stderr, "putting   %d - %d, opt = %d\n", qmem, junban[count-1], opt );
+		putlocalhom( qal2, tal2, localhomlist+junban[count-1], qstart, tstart, opt, overlapaa );
+	}
+//	fprintf( stderr, "count = %d\n", count );
+    return count;
+}
+int ReadFasta34m10_scoreonly_nucbk( FILE *fp, double *dis, int nin )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int pos;
+	int opt;
+	double z, bits;
+
+    count = 0;
+    while( !feof( fp ) )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+===========+", b, 13 ) )
+        {
+            pos = atoi( b+13 );
+
+			if( strchr( b, 'r' ) ) continue;
+
+//			pt = strchr( b, ')' ) + 1;
+			pt = strchr( b, ']' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+            dis[pos] += (double)opt;
+            count++;
+#if 0
+			fprintf( stderr, "b=%s\n", b );
+			fprintf( stderr, "opt=%d\n", opt );
+			fprintf( stderr, "pos=%d\n", pos );
+			fprintf( stderr, "dis[pos]=%f\n", dis[pos] );
+#endif
+
+        }
+		else if( 0 == strncmp( ">>><<<", b, 6 ) )
+		{
+			break;
+		}
+
+    }
+	if( !count ) return -1;
+
+    return count;
+}
+
+int ReadFasta34m10_scoreonly_nuc( FILE *fp, double *dis, int nin )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int pos;
+	int opt;
+	double z, bits;
+	int c;
+	int *yonda;
+
+
+	yonda = AllocateIntVec( nin );
+	for( c=0; c<nin; c++ ) yonda[c] = 0;
+	for( c=0; c<nin; c++ ) dis[c] = 0.0;
+
+    count = 0;
+    while( !feof( fp ) )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+===========+", b, 13 ) )
+        {
+            pos = atoi( b+13 );
+
+			if( strchr( b, 'r' ) ) continue;
+
+//			pt = strchr( b, ')' ) + 1;
+			pt = strchr( b, ']' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+			if( yonda[pos] == 0 )
+			{
+	            dis[pos] += (double)opt;
+				yonda[pos] = 1;
+			}
+            count++;
+#if 0
+			fprintf( stderr, "b=%s\n", b );
+			fprintf( stderr, "opt=%d\n", opt );
+			fprintf( stderr, "pos=%d\n", pos );
+			fprintf( stderr, "dis[pos]=%f\n", dis[pos] );
+#endif
+
+        }
+        else if( !strncmp( ">>>", b, 3 ) )
+		{
+			for( c=0; c<nin; c++ ) yonda[c] = 0;
+		}
+		else if( 0 == strncmp( ">>><<<", b, 6 ) )
+		{
+			break;
+		}
+
+    }
+
+	free( yonda );
+
+	if( !count ) return -1;
+
+    return count;
+}
+
+int ReadFasta34m10_scoreonly( FILE *fp, double *dis, int nin )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int pos;
+	int opt;
+	double z, bits;
+	int c;
+	int *yonda;
+
+
+	yonda = AllocateIntVec( nin );
+	for( c=0; c<nin; c++ ) yonda[c] = 0;
+	for( c=0; c<nin; c++ ) dis[c] = 0.0;
+
+    count = 0;
+    while( !feof( fp ) )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+===========+", b, 13 ) )
+        {
+            pos = atoi( b+13 );
+
+			pt = strchr( b, ')' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+			if( yonda[pos] == 0 )
+			{
+	            dis[pos] += (double)opt;
+				yonda[pos] = 1;
+			}
+            count++;
+#if 0
+			fprintf( stderr, "b=%s\n", b );
+			fprintf( stderr, "opt=%d\n", opt );
+			fprintf( stderr, "pos=%d\n", pos );
+			fprintf( stderr, "dis[pos]=%f\n", dis[pos] );
+#endif
+
+        }
+        else if( !strncmp( ">>>", b, 3 ) )
+		{
+			for( c=0; c<nin; c++ ) yonda[c] = 0;
+		}
+		else if( 0 == strncmp( ">>><<<", b, 6 ) )
+		{
+			break;
+		}
+
+    }
+
+	free( yonda );
+
+	if( !count ) return -1;
+
+    return count;
+}
+int ReadFasta34( FILE *fp, double *dis, int nseq, char name[M][B], LocalHom *localhomlist )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    static int junban[M];
+	int overlapaa;
+	int opt, qstart, qend, tstart, tend;
+	double z, bits;
+
+
+    count = 0;
+#if 0
+    for( i=0; i<10000000 && count<nseq; i++ )
+#else
+    while( !feof( fp ) )
+#endif
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			pt = strchr( b, ')' ) + 1;
+			sscanf( pt, "%d %lf %lf",  &opt, &bits, &z ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+
+        }
+		else if( 0 == strncmp( ">>+==========+", b, 14 ) )
+		{
+			break;
+		}
+
+    }
+	if( !count ) return -1;
+
+	count = 0;
+    while( !feof( fp ) )
+	{
+		if( !strncmp(">>+==========+", b, 14 ) )
+		{
+            junban[count] = atoi( b+14 );
+            count++;
+        	fgets( b, B-1, fp ); // initn:
+			pt = strstr( b, "opt: " ) + 5;
+			localhomlist[junban[count-1]].opt = atof( pt );
+        	fgets( b, B-1, fp ); // Smith-Waterman score
+			pt = strstr( b, "ungapped) in " ) + 13;
+			sscanf( pt, "%d", &overlapaa ); 
+			fprintf( stderr, "pt = %s, overlapaa = %d\n", pt, overlapaa );
+			pt = strstr( b, "overlap (" ) + 8;
+			sscanf( pt, "(%d-%d:%d-%d)", &qstart, &qend, &tstart, &tend ); 
+			localhomlist[junban[count-1]].overlapaa = overlapaa;
+			localhomlist[junban[count-1]].start1 = qstart-1;
+			localhomlist[junban[count-1]].end1   = qend-1;
+			localhomlist[junban[count-1]].start2 = tstart-1;
+			localhomlist[junban[count-1]].end2   = tend-1;
+		}
+        fgets( b, B-1, fp );
+	}
+	fprintf( stderr, "count = %d\n", count );
+    return count;
+}
+
+int ReadFasta3( FILE *fp, double *dis, int nseq, char name[M][B] )
+{
+    int count=0;
+    char b[B];
+	char *pt;
+    int junban[M];
+	int initn, init1, opt;
+	double z;
+
+    count = 0;
+#if 0
+    for( i=0; i<10000000 && count<nseq; i++ )
+#else
+    while( !feof( fp ) )
+#endif
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			pt = strchr( b, ')' ) + 1;
+			sscanf( pt, "%d %d %d %lf", &initn, &init1, &opt, &z ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+        }
+    }
+    return 0;
+}
+
+int ReadFasta( FILE *fp, double *dis, int nseq, char name[M][B] )
+{
+    int i, count=0;
+    char b[B];
+    int junban[M];
+	int initn, init1, opt;
+
+    count = 0;
+	for( i=0; i<nseq; i++ ) dis[i] = 0.0;
+    for( i=0; !feof( fp ) && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+
+			sscanf( b+50, "%d %d %d", &initn, &init1, &opt ); 
+            dis[junban[count]] = (double)opt;
+            count++;
+        }
+    }
+
+/*
+    count = 0;
+    for( i=0; i<100000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( name[junban[count]], b, 20  ) )
+        {
+            dis[junban[count]] = atof( b+65 );
+            count++;
+        }
+    }
+*/
+    return 0;
+}
+
+
+int ReadOpt( FILE *fp, int opt[M], int nseq, char name[M][B] )
+{
+    int i, count=0;
+    char b[B];
+    int junban[M];
+	int optt, initn, init1;
+
+    count = 0;
+    for( i=0; i<10000000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+			sscanf( b+50, "%d %d %d", &initn, &init1, &optt ); 
+            opt[junban[count]] = (double)optt;
+            count++;
+        }
+    }
+    return 0;
+}
+
+int ReadOpt2( FILE *fp, int opt[M], int nseq, char name[M][B] )
+{
+    int i, count=0;
+    char b[B];
+    int junban[M];
+
+    count = 0;
+    for( i=0; i<10000000 && count<nseq; i++ )
+    {
+        fgets( b, B-1, fp );
+        if( !strncmp( "+==========+", b, 12 ) )
+        {
+            junban[count] = atoi( b+12 );
+            opt[junban[count]] = atoi( b+65 );
+            count++;
+        }
+    }
+    return 0;
+}
+
+
+
+int writePre( int nseq, char name[][B], int nlen[M], char **aseq, int force )
+{
+#if USE_XCED
+	int i, value;
+	if( !signalSM )
+	{
+		if( force ) 
+		{
+			rewind( prep_g );
+			if( devide ) dvWrite( prep_g, nseq, name, nlen, aseq );
+#if 0
+			else    WriteGapFill( prep_g, nseq, name, nlen, aseq );
+#else
+			else    writeData( prep_g, nseq, name, nlen, aseq );
+#endif
+		}
+		return( 0 );
+	}
+	for( i=0; i<10; i++ )
+	{
+#if IODEBUG
+		fprintf( stderr, "SEMAPHORE = %d\n", signalSM[SEMAPHORE] );
+#endif
+		if( signalSM[SEMAPHORE]-- > 0 )
+		{
+#if 0 /* /tmp/pre ¤Î´Ø·¸¤Ç¤Ï¤º¤·¤¿ */
+			if( ferror( prep_g ) ) prep_g = fopen( "pre", "w" );
+			if( !prep_g ) ErrorExit( "Cannot re-open pre." ); 
+#endif
+			rewind( prep_g );
+			signalSM[STATUS] = IMA_KAITERU;
+#if IODEBUG
+			if( force ) fprintf( stderr, "FINAL " );
+#endif
+			if( devide ) dvWrite( prep_g, nseq, name, nlen, aseq );
+			else    WriteGapFill( prep_g, nseq, name, nlen, aseq );
+			/*
+			fprintf( prep_g, '\EOF' );
+			*/
+			fflush( prep_g );
+			if( force ) signalSM[STATUS] = OSHIMAI;
+			else        signalSM[STATUS] = KAKIOWATTA;
+			value = 1;
+			signalSM[SEMAPHORE]++;
+#if IODEBUG
+			fprintf( stderr, "signalSM[STATUS] = %c\n", signalSM[STATUS] );
+#endif
+			break;
+		}
+		else
+		{
+#if IODEBUG
+			fprintf( stderr, "YONDERUKARA_AKIRAMERU\n" );
+#endif
+			value = 0;
+			signalSM[SEMAPHORE]++;
+			if( !force ) break;
+#if IODEBUG
+			fprintf( stderr, "MATSU\n" );
+#endif
+			sleep( 1 );
+		}
+	}
+	if( force && !value ) ErrorExit( "xced ga pre wo hanasanai \n" );
+	return( value );
+#else
+	if( force ) 
+	{
+		rewind( prep_g );
+			writeData( prep_g, nseq, name, nlen, aseq );
+	}
+#endif
+	return( 0 );
+}
+
+
+void readOtherOptions( int *ppidptr, int *fftThresholdptr, int *fftWinSizeptr )
+{
+	if( calledByXced )
+	{
+		FILE *fp = fopen( "pre", "r" );
+		char b[B];
+		if( !fp ) ErrorExit( "Cannot open pre.\n" );
+		fgets( b, B-1, fp );
+		sscanf( b, "%d %d %d", ppidptr, fftThresholdptr, fftWinSizeptr );
+		fclose( fp );
+#if IODEBUG
+	fprintf( stderr, "b = %s\n", b );
+	fprintf( stderr, "ppid = %d\n", ppid );
+	fprintf( stderr, "fftThreshold = %d\n", fftThreshold );
+	fprintf( stderr, "fftWinSize = %d\n", fftWinSize );
+#endif
+	}
+	else
+	{
+		*ppidptr = 0;
+		*fftThresholdptr = FFT_THRESHOLD;
+		if( dorp == 'd' )
+			*fftWinSizeptr = FFT_WINSIZE_D;
+		else
+			*fftWinSizeptr = FFT_WINSIZE_P;
+	}
+#if 0
+	fprintf( stderr, "fftThresholdptr=%d\n", *fftThresholdptr );
+	fprintf( stderr, "fftWinSizeptr=%d\n", *fftWinSizeptr );
+#endif
+}
+
+void initSignalSM( void )
+{
+//	int signalsmid;
+
+#if IODEBUG
+	if( ppid ) fprintf( stderr, "PID of xced = %d\n", ppid );
+#endif
+	if( !ppid )
+	{
+		signalSM = NULL;
+		return;
+	}
+
+#if 0
+	signalsmid = shmget( (key_t)ppid, 3, IPC_ALLOC | 0666 );
+	if( signalsmid == -1 ) ErrorExit( "Cannot get Shared memory for signal.\n" );
+	signalSM = shmat( signalsmid, 0, 0 );
+	if( (int)signalSM == -1 ) ErrorExit( "Cannot attatch Shared Memory for signal!\n" );
+	signalSM[STATUS] = IMA_KAITERU;
+	signalSM[SEMAPHORE] = 1;
+#endif
+}
+
+void initFiles( void )
+{
+	char pname[100];
+	if( ppid )
+		sprintf( pname, "/tmp/pre.%d", ppid );
+	else
+		sprintf( pname, "pre" );
+	prep_g = fopen( pname, "w" );
+	if( !prep_g ) ErrorExit( "Cannot open pre" );
+
+	trap_g = fopen( "trace", "w" );
+	if( !trap_g ) ErrorExit( "cannot open trace" );
+	fprintf( trap_g, "PID = %d\n", getpid() );
+	fflush( trap_g );
+}
+
+
+void WriteForFasta( FILE *fp, int locnjob, char name[][B], int nlen[M], char **aseq )
+{
+    static char b[N];
+    int i, j;
+    int nalen[M];
+
+    for( i=0; i<locnjob; i++ )
+    {
+        nalen[i] = strlen( aseq[i] );
+        fprintf( fp, ">%s\n", name[i] );
+        for( j=0; j<nalen[i]; j=j+C ) 
+        {
+            strncpy( b, aseq[i]+j, C ); b[C] = 0;
+            fprintf( fp, "%s\n",b );
+        }
+    }
+}
+
+void readlocalhomtable2( FILE*fp, int njob, LocalHom **localhomtable )
+{
+	double opt;
+	static char buff[B];
+	int i, j, overlapaa, start1, end1, start2, end2;
+	LocalHom *tmpptr1, *tmpptr2;
+
+//	for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) nlocalhom[i][j] = 0;
+
+	while ( NULL != fgets( buff, B-1, fp ) )
+	{
+//		fprintf( stderr, "\n" );
+		sscanf( buff, "%d %d %d %lf %d %d %d %d",  &i, &j, &overlapaa, &opt, &start1, &end1, &start2, &end2 );
+
+#if 0
+		if( start1 == end1 || start2 == end2 ) continue; //mondai ari
+#endif
+
+//		if( i < j )
+		{
+			if( localhomtable[i][j].nokori++ > 0 )
+			{
+				tmpptr1 = localhomtable[i][j].last;
+//				fprintf( stderr, "reallocating, localhomtable[%d][%d].nokori = %d\n", i, j, localhomtable[i][j].nokori );
+				tmpptr1->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+				tmpptr1 = tmpptr1->next;
+				tmpptr1->extended = -1;
+				tmpptr1->next = NULL;
+				localhomtable[i][j].last = tmpptr1;
+//				fprintf( stderr, "### i,j = %d,%d, nokori=%d\n", i, j, localhomtable[i][j].nokori );
+			}
+			else
+			{
+				tmpptr1 = localhomtable[i]+j;
+//				fprintf( stderr, "### i,j = %d,%d, nokori=%d\n", i, j, localhomtable[i][j].nokori );
+			}
+	
+			tmpptr1->start1 = start1;
+			tmpptr1->start2 = start2;
+			tmpptr1->end1 = end1;
+			tmpptr1->end2 = end2;
+//			tmpptr1->opt = ( opt / overlapaa + 0.00 ) / 5.8  * 600;
+//			tmpptr1->opt = opt;
+			tmpptr1->opt = ( opt + 0.00 ) / 5.8  * 600;
+			tmpptr1->overlapaa = overlapaa;
+		}
+//		else
+		{
+			if( localhomtable[j][i].nokori++ > 0 )
+			{
+				tmpptr2 = localhomtable[j][i].last;
+				tmpptr2->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+				tmpptr2 = tmpptr2->next;
+				tmpptr2->extended = -1;
+				tmpptr2->next = NULL;
+				localhomtable[j][i].last = tmpptr2;
+//				fprintf( stderr, "### i,j = %d,%d, nokori=%d\n", j, i, localhomtable[j][i].nokori );
+			}
+			else
+			{
+				tmpptr2 = localhomtable[j]+i;
+//				fprintf( stderr, "### i,j = %d,%d, nokori=%d\n", j, i, localhomtable[j][i].nokori );
+			}
+	
+			tmpptr2->start2 = start1;
+			tmpptr2->start1 = start2;
+			tmpptr2->end2 = end1;
+			tmpptr2->end1 = end2;
+//			tmpptr2->opt = ( opt / overlapaa + 0.00 ) / 5.8  * 600;
+//			tmpptr2->opt = opt;
+			tmpptr2->opt = ( opt + 0.00 ) / 5.8  * 600;
+			tmpptr2->overlapaa = overlapaa;
+	
+//			fprintf( stderr, "i=%d, j=%d, st1=%d, en1=%d, opt = %f\n", i, j, tmpptr1->start1, tmpptr1->end1, opt );
+		}
+
+	}
+}
+void readlocalhomtable( FILE*fp, int njob, LocalHom **localhomtable )
+{
+	double opt;
+	static char buff[B];
+	int i, j, overlapaa, start1, end1, start2, end2;
+	int **nlocalhom = NULL;
+	LocalHom *tmpptr1=NULL, *tmpptr2=NULL; // by D.Mathog, a guess
+
+	nlocalhom = AllocateIntMtx( njob, njob );
+	for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) nlocalhom[i][j] = 0;
+
+	while ( NULL != fgets( buff, B-1, fp ) )
+	{
+//		fprintf( stderr, "\n" );
+		sscanf( buff, "%d %d %d %lf %d %d %d %d",  &i, &j, &overlapaa, &opt, &start1, &end1, &start2, &end2 );
+
+#if 0
+		if( start1 == end1 || start2 == end2 ) continue; //mondai ari
+#endif
+
+
+//		if( i < j )
+		{
+			if( nlocalhom[i][j]++ > 0 )
+			{
+//				fprintf( stderr, "reallocating, nlocalhom[%d][%d] = %d\n", i, j, nlocalhom[i][j] );
+				tmpptr1->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+				tmpptr1 = tmpptr1->next;
+				tmpptr1->next = NULL;
+			}
+			else
+			{
+				tmpptr1 = localhomtable[i]+j;
+//				fprintf( stderr, "nlocalhom[%d][%d] = %d\n", i, j, nlocalhom[i][j] );
+			}
+	
+			tmpptr1->start1 = start1;
+			tmpptr1->start2 = start2;
+			tmpptr1->end1 = end1;
+			tmpptr1->end2 = end2;
+//			tmpptr1->opt = ( opt / overlapaa + 0.00 ) / 5.8  * 600;
+//			tmpptr1->opt = opt;
+			tmpptr1->opt = ( opt + 0.00 ) / 5.8  * 600;
+			tmpptr1->overlapaa = overlapaa;
+	
+//			fprintf( stderr, "i=%d, j=%d, opt = %f\n", i, j, opt );
+		}
+//		else
+		{
+			if( nlocalhom[j][i]++ > 0 )
+			{
+				tmpptr2->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+				tmpptr2 = tmpptr2->next;
+				tmpptr2->next = NULL;
+			}
+			else
+				tmpptr2 = localhomtable[j]+i;
+	
+			tmpptr2->start2 = start1;
+			tmpptr2->start1 = start2;
+			tmpptr2->end2 = end1;
+			tmpptr2->end1 = end2;
+//			tmpptr2->opt = ( opt / overlapaa + 0.00 ) / 5.8  * 600;
+//			tmpptr2->opt = opt;
+			tmpptr2->opt = ( opt + 0.00 ) / 5.8  * 600;
+			tmpptr2->overlapaa = overlapaa;
+		}
+
+	}
+	FreeIntMtx( nlocalhom );
+}
+
+void outlocalhom( LocalHom **localhom, int nseq )
+{
+	int i, j;
+	LocalHom *tmpptr;
+	for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ )
+	{
+		tmpptr = localhom[i]+j;
+		fprintf( stderr, "%d-%d\n", i, j );
+		do
+		{
+			fprintf( stderr, "reg1=%d-%d, reg2=%d-%d, imp=%f, opt=%f\n", tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->importance, tmpptr->opt );
+		}
+		while( (tmpptr=tmpptr->next) );
+	}
+}
+
+void outlocalhompt( LocalHom ***localhom, int n1, int n2 )
+{
+	int i, j;
+	LocalHom *tmpptr;
+	for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
+	{
+		tmpptr = localhom[i][j];
+		fprintf( stderr, "%d-%d\n", i, j );
+		do
+		{
+			fprintf( stderr, "reg1=%d-%d, reg2=%d-%d, imp=%f, opt=%f, wimp=%f\n", tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->importance, tmpptr->opt, tmpptr->wimportance );
+		}
+		while( (tmpptr=tmpptr->next) );
+	}
+}
+
+void FreeLocalHomTable( LocalHom **localhomtable, int n ) 
+{
+	int i, j;
+	LocalHom *ppp, *tmpptr;
+	fprintf( stderr, "freeing localhom\n" );
+	for( i=0; i<n; i++ ) 
+	{
+		for( j=0; j<n; j++ )
+		{
+			tmpptr=localhomtable[i]+j;
+			ppp = tmpptr->next;
+			for( ; tmpptr; tmpptr=ppp )
+			{
+#if DEBUG
+				fprintf( stderr, "i=%d, j=%d\n", i, j ); 
+#endif
+				ppp = tmpptr->next;
+				if( tmpptr!=localhomtable[i]+j ) 
+				{
+#if DEBUG
+					fprintf( stderr, "freeing %p\n", tmpptr );
+#endif
+					free( tmpptr );
+				}
+			}
+		}
+#if DEBUG
+		fprintf( stderr, "freeing localhomtable[%d]\n", i );
+#endif
+		free( localhomtable[i] );
+	}
+#if DEBUG
+	fprintf( stderr, "freeing localhomtable\n" );
+#endif
+	free( localhomtable );
+#if DEBUG
+	fprintf( stderr, "freed\n" );
+#endif
+}
+
+char *progName( char *str )
+{
+    char *value; 
+    if( ( value = strrchr( str, '/' ) ) != NULL )
+        return( value+1 );
+    else    
+        return( str );
+}
+
+static void tabtospace( char *str )
+{
+	char *p;
+//	fprintf( stderr, "before = %s\n", str );
+	while( NULL != ( p = strchr( str , '\t' ) ) )
+	{
+		*p = ' ';
+	}
+//	fprintf( stderr, "after = %s\n", str );
+}
+
+static char *extractfirstword( char *str )
+{
+	char *val = str;
+
+	tabtospace( str );
+	while( *str )
+	{
+		if( val == str && *str == ' ' )
+		{
+			val++; str++;
+		}
+		else if( *str != ' ' )
+		{
+			str++;
+		}
+		else if( *str == ' ' )
+		{
+			*str = 0;
+		}
+	}
+	return( val );
+}
+
+
+void clustalout_pointer( FILE *fp, int nseq, int maxlen, char **seq, char **name, char *mark, char *comment, int *order )
+{
+	int pos, j;
+	pos = 0;
+	if( comment == NULL )
+		fprintf( fp, "CLUSTAL format alignment by MAFFT (v%s)\n\n", VERSION );
+	else
+		fprintf( fp, "CLUSTAL format alignment by MAFFT %s (v%s)\n\n", comment, VERSION );
+	
+	while( pos < maxlen )
+	{
+		fprintf( fp, "\n" );
+		for( j=0; j<nseq; j++ )
+		{
+			fprintf( fp, "%-15.15s ", extractfirstword( name[order[j]]+1 ) );
+			fprintf( fp, "%.60s\n", seq[order[j]]+pos ); // Ťµ¤¬°ã¤¦¤È¤À¤á¡£
+		}
+		if( mark )
+		{
+			fprintf( fp, "%-15.15s ", "" );
+			fprintf( fp, "%.60s\n", mark + pos ); // Ťµ¤¬°ã¤¦¤È¤À¤á¡£
+		}
+		pos += 60;
+	}
+}
+
+
+void writeData_reorder_pointer( FILE *fp, int locnjob, char **name, int *nlen, char **aseq, int *order )
+{
+	int i, j, k;
+	int nalen;
+
+	for( i=0; i<locnjob; i++ )
+	{
+		k = order[i];
+#if DEBUG
+		fprintf( stderr, "i = %d in writeData\n", i );
+#endif
+		nalen = strlen( aseq[k] );
+		fprintf( fp, ">%s\n", name[k]+1 );
+		for( j=0; j<nalen; j=j+C )
+		{
+#if 0
+			strncpy( b, aseq[k]+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+#else
+			fprintf( fp, "%.*s\n", C, aseq[k]+j );
+#endif
+		}
+	}
+}
+void writeData_reorder( FILE *fp, int locnjob, char name[][B], int nlen[], char **aseq, int *order )
+{
+	int i, j, k;
+	int nalen;
+
+	for( i=0; i<locnjob; i++ )
+	{
+		k = order[i];
+#if DEBUG
+		fprintf( stderr, "i = %d in writeData\n", i );
+#endif
+		nalen = strlen( aseq[k] );
+		fprintf( fp, ">%s\n", name[k]+1 );
+		for( j=0; j<nalen; j=j+C )
+		{
+#if 0
+			strncpy( b, aseq[k]+j, C ); b[C] = 0;
+			fprintf( fp, "%s\n",b );
+#else
+			fprintf( fp, "%.*s\n", C, aseq[k]+j );
+#endif
+		}
+	}
+}
+static void showaamtxexample()
+{
+	fprintf( stderr, "Format error in aa matrix\n" );
+	fprintf( stderr, "# Example:\n" );
+	fprintf( stderr, "# comment\n" );
+	fprintf( stderr, "   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V\n" );
+	fprintf( stderr, "A  4 -1 -2 -2  0 -1 -1  0 -2 -1 -1 -1 -1 -2 -1  1  0 -3 -2  0\n" );
+	fprintf( stderr, "R -1  5  0 -2 -3  1  0 -2  0 -3 -2  2 -1 -3 -2 -1 -1 -3 -2 -3\n" );
+	fprintf( stderr, "...\n" );
+	fprintf( stderr, "V  0 -3 -3 -3 -1 -2 -2 -3 -3  3  1 -2  1 -1 -2 -2  0 -3 -1  4\n" );
+	fprintf( stderr, "frequency 0.07 0.05 0.04 0.05 0.02 .. \n" );
+	fprintf( stderr, "# Example end\n" );
+	fprintf( stderr, "Only the lower half is loaded\n" );
+	fprintf( stderr, "The last line (frequency) is optional.\n" );
+	exit( 1 );
+}
+
+double *loadaamtx( void )
+{
+	int i, j, k, ii, jj;
+	double *val;
+	double **raw;
+	int *map;
+	char *aaorder = "ARNDCQEGHILKMFPSTWYV";
+	char *inorder;
+	char *line;
+	char *ptr1;
+	char *ptr2;
+	char *mtxfname = "_aamtx";
+	FILE *mf;
+
+	raw = AllocateDoubleMtx( 21, 20 );
+	val = AllocateDoubleVec( 420 );
+	map = AllocateIntVec( 20 );
+
+	if( dorp != 'p' )
+	{
+		fprintf( stderr, "User-defined matrix is not supported for DNA\n" );
+		exit( 1 );
+	}
+
+	mf = fopen( mtxfname, "r" );
+	if( mf == NULL )
+	{
+		fprintf( stderr, "Cannot open the _aamtx file\n" );
+		exit( 1 );
+	}
+
+	inorder = calloc( 1000, sizeof( char ) );
+	line = calloc( 1000, sizeof( char ) );
+	
+
+	while( !feof( mf ) )
+	{
+		fgets( inorder, 999, mf );
+		if( inorder[0] != '#' ) break;
+	}
+	ptr1 = ptr2 = inorder;
+	while( *ptr2 )
+	{
+		if( isalpha( *ptr2 ) )
+		{
+			*ptr1 = toupper( *ptr2 );
+			ptr1++;
+		}
+		ptr2++;
+	}
+	inorder[20] = 0;
+
+	for( i=0; i<20; i++ )
+	{
+		ptr2 = strchr( inorder, aaorder[i] );
+		if( ptr2 == NULL )
+		{
+			fprintf( stderr, "%c: not found in the first 20 letters.\n", aaorder[i] );
+			showaamtxexample();
+		}
+		else
+		{
+			map[i] = ptr2 - inorder;
+		}
+	}
+
+	i = 0;
+	while( !feof( mf ) )
+	{
+		fgets( line, 999, mf );
+//		fprintf( stderr, "line = %s\n", line );
+		if( line[0] == '#' ) continue;
+		ptr1 = line;
+//		fprintf( stderr, "line = %s\n", line );
+		for( j=0; j<=i; j++ )
+		{
+			while( !isdigit( *ptr1 ) && *ptr1 != '-' && *ptr1 != '.' )
+				ptr1++;
+
+			raw[i][j] = atof( ptr1 );
+//			fprintf( stderr, "raw[][]=%f, %c-%c %d-%d\n", raw[i][j], inorder[i], inorder[j], i, j );
+			ptr1 = strchr( ptr1, ' ' );
+			if( ptr1 == NULL && j<i) showaamtxexample();
+		}
+		i++;
+		if( i > 19 ) break;
+	}
+
+	for( i=0; i<20; i++ ) raw[20][i] = -1.0;
+	while( !feof( mf ) )
+	{
+		fgets( line, 999, mf );
+		if( line[0] == 'f' )
+		{
+//			fprintf( stderr, "line = %s\n", line );
+			ptr1 = line;
+			for( j=0; j<20; j++ )
+			{
+				while( !isdigit( *ptr1 ) && *ptr1 != '-' && *ptr1 != '.' )
+					ptr1++;
+	
+				raw[20][j] = atof( ptr1 );
+//				fprintf( stderr, "raw[20][]=%f, %c %d\n", raw[20][j], inorder[i], j );
+				ptr1 = strchr( ptr1, ' ' );
+				if( ptr1 == NULL && j<19) showaamtxexample();
+			}
+			break;
+		}
+	}
+
+	k = 0;
+	for( i=0; i<20; i++ )
+	{
+		for( j=0; j<=i; j++ )
+		{
+			if( i != j )
+			{
+				ii = MAX( map[i], map[j] );
+				jj = MIN( map[i], map[j] );
+			}
+			else ii = jj = map[i];
+			val[k++] = raw[ii][jj];
+//			fprintf( stderr, "%c-%c, %f\n", aaorder[i], aaorder[j], val[k-1] );
+		}
+	}
+	for( i=0; i<20; i++ ) val[400+i] = raw[20][map[i]];
+
+	fprintf( stderr, "inorder = %s\n", inorder );
+	fclose( mf );
+	free( inorder );
+	free( line );
+	FreeDoubleMtx( raw );
+	free( map );
+	return( val );
+}
+
+void miyataout_reorder_pointer( FILE *fp, int locnjob, int nlenmax, char **name, int *nlen, char **aseq, int *order )
+{
+	int i, j, k;
+	int nalen;
+
+	fprintf( fp, "%5d\n", 1 );
+	fprintf( fp, "%5d\n", 1 );
+	fprintf( fp, "%5d%5d\n", 1, nlenmax );
+	fprintf( fp, "%5d\n", 0 );
+	fprintf( fp, "%5d\n", locnjob );
+	for( i=0; i<locnjob; i++ )
+	{
+		k = order[i];
+		nalen = strlen( aseq[k] );
+		fprintf( fp, "=%s\n%d\n", name[k]+1, nalen );
+		for( j=0; j<nalen; j=j+C )
+		{
+			fprintf( fp, "%.*s\n", C, aseq[k]+j );
+		}
+	}
+}
+
+void readmccaskill( FILE *fp, RNApair **pairprob, int length )
+{
+	char gett[1000];
+	int *pairnum;
+	int i;
+	int left, right;
+	float prob;
+	int c;
+
+	pairnum = (int *)calloc( length, sizeof( int ) );
+	for( i=0; i<length; i++ ) pairnum[i] = 0;
+
+	c = getc( fp );
+	{
+		if( c != '>' )
+		{
+			fprintf( stderr, "format error in hat4\n" );
+			exit( 1 );
+		}
+	}
+	fgets( gett, 999, fp );
+	while( 1 )
+	{
+		if( feof( fp ) ) break;
+		c = getc( fp );
+		ungetc( c, fp );
+		if( c == '>' )
+		{
+			break;
+		}
+		fgets( gett, 999, fp );
+//		fprintf( stderr, "gett = %s\n", gett );
+		sscanf( gett, "%d %d %f", &left, &right, &prob );
+
+		if( left >= length || right >= length )
+		{
+			fprintf( stderr, "format error in hat4\n" );
+			exit( 1 );
+		}
+
+		if( prob < 0.01 ) continue; // 080607, mafft ni dake eikyou
+
+		if( left != right && prob > 0.0 )
+		{
+			pairprob[left] = (RNApair *)realloc( pairprob[left], (pairnum[left]+2) * sizeof( RNApair ) );
+			pairprob[left][pairnum[left]].bestscore = prob;
+			pairprob[left][pairnum[left]].bestpos = right;
+			pairnum[left]++;
+			pairprob[left][pairnum[left]].bestscore = -1.0;
+			pairprob[left][pairnum[left]].bestpos = -1;
+//			fprintf( stderr, "%d-%d, %f\n", left, right, prob );
+
+			pairprob[right] = (RNApair *)realloc( pairprob[right], (pairnum[right]+2) * sizeof( RNApair ) );
+			pairprob[right][pairnum[right]].bestscore = prob;
+			pairprob[right][pairnum[right]].bestpos = left;
+			pairnum[right]++;
+			pairprob[right][pairnum[right]].bestscore = -1.0;
+			pairprob[right][pairnum[right]].bestpos = -1;
+//			fprintf( stderr, "%d-%d, %f\n", right, left, prob );
+		}
+	}
+	free( pairnum );
+}
+
+void readpairfoldalign( FILE *fp, char *s1, char *s2, char *aln1, char *aln2, int q1, int q2, int *of1, int *of2, int sumlen )
+{
+	char gett[1000];
+	int *maptoseq1;
+	int *maptoseq2;
+	char dumc;
+	int dumi;
+	char sinseq[100], sinaln[100];
+	int posinseq, posinaln;
+	int alnlen;
+	int i;
+	int pos1, pos2;
+	char *pa1, *pa2;
+	char qstr[1000];
+
+	*of1 = -1;
+	*of2 = -1;
+
+	maptoseq1 = AllocateIntVec( sumlen+1 );
+	maptoseq2 = AllocateIntVec( sumlen+1 );
+
+	posinaln = 0; // foldalign ga alingment wo kaesanaitok no tame.
+
+	while( !feof( fp ) )
+	{
+		fgets( gett, 999, fp );
+		if( !strncmp( gett, "; ALIGNING", 10 ) ) break;
+	}
+	sprintf( qstr, "; ALIGNING            %d against %d\n", q1+1, q2+1 );
+	if( strcmp( gett, qstr ) )
+	{
+		fprintf( stderr, "Error in FOLDALIGN\n" );
+		fprintf( stderr, "qstr = %s, but gett = %s\n", qstr, gett );
+		exit( 1 );
+	}
+
+	while( !feof( fp ) )
+	{
+		fgets( gett, 999, fp );
+		if( !strncmp( gett, "; --------", 10 ) ) break;
+	}
+
+
+	while( !feof( fp ) )
+	{
+		fgets( gett, 999, fp );
+		if( !strncmp( gett, "; ********", 10 ) ) break;
+//		fprintf( stderr, "gett = %s\n", gett );
+		sscanf( gett, "%c %c %s %s %d %d", &dumc, &dumc, sinseq, sinaln, &dumi, &dumi );
+		posinaln = atoi( sinaln );
+		posinseq = atoi( sinseq );
+//		fprintf( stderr, "posinseq = %d\n", posinseq );
+//		fprintf( stderr, "posinaln = %d\n", posinaln );
+		maptoseq1[posinaln-1] = posinseq-1;
+	}
+	alnlen = posinaln;
+
+	while( !feof( fp ) )
+	{
+		fgets( gett, 999, fp );
+		if( !strncmp( gett, "; --------", 10 ) ) break;
+	}
+
+	while( !feof( fp ) )
+	{
+		fgets( gett, 999, fp );
+		if( !strncmp( gett, "; ********", 10 ) ) break;
+//		fprintf( stderr, "gett = %s\n", gett );
+		sscanf( gett, "%c %c %s %s %d %d", &dumc, &dumc, sinseq, sinaln, &dumi, &dumi );
+		posinaln = atof( sinaln );
+		posinseq = atof( sinseq );
+//		fprintf( stderr, "posinseq = %d\n", posinseq );
+//		fprintf( stderr, "posinaln = %d\n", posinaln );
+		maptoseq2[posinaln-1] = posinseq-1;
+	}
+	if( alnlen != posinaln )
+	{
+		fprintf( stderr, "Error in foldalign?\n" );
+		exit( 1 );
+	}
+
+	pa1 = aln1;
+	pa2 = aln2;
+	for( i=0; i<alnlen; i++ )
+	{
+		pos1 = maptoseq1[i];
+		pos2 = maptoseq2[i];
+
+		if( pos1 > -1 )
+			*pa1++ = s1[pos1];
+		else
+			*pa1++ = '-';
+
+		if( pos2 > -1 )
+			*pa2++ = s2[pos2];
+		else
+			*pa2++ = '-';
+	}
+	*pa1 = 0;
+	*pa2 = 0;
+
+	*of1 = 0;
+	for( i=0; i<alnlen; i++ )
+	{
+		*of1 = maptoseq1[i];
+		if( *of1 > -1 ) break;
+	}
+	*of2 = 0;
+	for( i=0; i<alnlen; i++ )
+	{
+		*of2 = maptoseq2[i];
+		if( *of2 > -1 ) break;
+	}
+
+//	fprintf( stderr, "*of1=%d, aln1 = :%s:\n", *of1, aln1 );
+//	fprintf( stderr, "*of2=%d, aln2 = :%s:\n", *of2, aln2 );
+
+	free( maptoseq1 );
+	free( maptoseq2 );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/license
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/license?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/license (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/license Thu Feb 19 06:37:59 2009
@@ -0,0 +1,48 @@
+============================================================
+
+If you have the './extensions' directory, please also see
+license.extensions file.
+
+============================================================
+
+The codes in the './core' directory is distributed with 
+the BSD license.
+
+MAFFT: multiple sequence alignment program
+Copyright (c) 2007 Kazutaka Katoh
+
+Redistribution and use in source and binary forms,
+with or without modification, are permitted provided
+that the following conditions are met:
+
+Redistributions of source code must retain the
+above copyright notice, this list of conditions
+and the following disclaimer.  Redistributions in
+binary form must reproduce the above copyright
+notice, this list of conditions and the following
+disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+The name of the author may not be used to endorse
+or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+---------------------------------------------------------------------------------
+
+
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/miyata.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/miyata.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/miyata.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/miyata.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,47 @@
+double polarity_[] =
+{
+	 8.1,  /* A */
+	10.5,  /* R */
+	11.6,  /* N */
+	13.0,  /* D */
+	 5.5,  /* C */
+	10.5,  /* Q */
+	12.3,  /* E */
+	 9.0,  /* G */
+	10.4,  /* H */
+	 5.2,  /* I */
+	 4.9,  /* L */
+	11.3,  /* K */
+	 5.7,  /* M */
+	 5.2,  /* F */
+	 8.0,  /* P */
+	 9.2,  /* S */
+	 8.6,  /* T */
+	 5.4,  /* W */
+	 6.2,  /* Y */
+	 5.9,  /* V */
+};
+
+double volume_[] =
+{
+	 31.0,  /* A */
+	124.0,  /* R */
+	 56.0,  /* N */
+	 54.0,  /* D */
+	 55.0,  /* C */
+	 85.0,  /* Q */
+	 83.0,  /* E */
+	  3.0,  /* G */
+	 96.0,  /* H */
+	111.0,  /* I */
+	111.0,  /* L */
+	119.0,  /* K */
+	105.0,  /* M */
+	132.0,  /* F */
+	 32.5,  /* P */
+	 32.0,  /* S */
+	 61.0,  /* T */
+	170.0,  /* W */
+	136.0,  /* Y */
+	 84.0,  /* V */
+};

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/miyata5.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/miyata5.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/miyata5.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/miyata5.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,166 @@
+int locpenaltym = -1440;
+int exgpm = +0;  /* != 0 nisuruto kowareru. exgp ha constants.c de kurikomu */
+char locaminom[] = "ARNDCQEGHILKMFPSTWYVBZX.-U";
+char locgrpm[] = 
+{
+	0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2,
+	6, 6, 6, 6,
+};
+int locn_dism[26][26] = 
+    {
+	{
+  600, -235,   91,  -78,  202,   51, -103,  340,  -21, -169,
+ -189, -246,  -92, -323,  582,  454,  342, -400, -309,   71,
+    7,  -26,  -15, -400,    0,-1400,
+	},
+
+	{
+ -235,  600,   17,  -69, -275,  277,  185, -400,  365, -112,
+ -149,  485,  -55, -106, -229, -183,   20, -178,   22,  -95,
+  -26,  231,  -15, -400,    0,-1400,
+	},
+
+	{
+   91,   17,  600,  414, -209,  317,  357,   39,  231, -363,
+ -398,   74, -280, -400,   85,  225,  200, -400, -378, -189,
+  507,  337,  -15, -400,    0,-1400,
+	},
+
+	{
+  -78,  -69,  414,  600, -395,  179,  342,  -78,  108, -400,
+ -400,   14, -400, -400,  -86,   65,   14, -400, -400, -372,
+  507,  261,  -15, -400,    0,-1400,
+	},
+
+	{
+  202, -275, -209, -395,  600, -109, -332,  -35, -132,  134,
+  128, -335,  182,  -40,  220,   74,  185, -355,  -81,  354,
+ -302, -220,  -15, -400,    0,-1400,
+	},
+
+	{
+   51,  277,  317,  179, -109,  600,  360, -109,  508, -135,
+ -172,  297,  -58, -203,   51,  128,  280, -378, -109,   -9,
+  248,  480,  -15, -400,    0,-1400,
+	},
+
+	{
+ -103,  185,  357,  342, -332,  360,  600, -195,  325, -369,
+ -400,  274, -295, -400, -109,   11,   77, -400, -321, -249,
+  350,  480,  -15, -400,    0,-1400,
+	},
+
+	{
+  340, -400,   39,  -78,  -35, -109, -195,  600, -195, -400,
+ -400, -400, -355, -400,  322,  357,  114, -400, -400, -189,
+  -19, -152,  -15, -400,    0,-1400,
+	},
+
+	{
+  -21,  365,  231,  108, -132,  508,  325, -195,  600, -100,
+ -141,  374,  -26, -152,  -15,   45,  222, -303,  -49,   -3,
+  169,  417,  -15, -400,    0,-1400,
+	},
+
+	{
+ -169, -112, -363, -400,  134, -135, -369, -400, -100,  600,
+  560, -212,  517,  425, -149, -243,  -12,  108,  354,  357,
+ -400, -252,  -15, -400,    0,-1400,
+	},
+
+	{
+ -189, -149, -398, -400,  128, -172, -400, -400, -141,  560,
+  600, -252,  482,  420, -172, -269,  -43,  105,  331,  340,
+ -400, -290,  -15, -400,    0,-1400,
+	},
+
+	{
+ -246,  485,   74,   14, -335,  297,  274, -400,  374, -212,
+ -252,  600, -152, -215, -240, -175,   -1, -289,  -92, -172,
+   44,  285,  -15, -400,    0,-1400,
+	},
+
+	{
+  -92,  -55, -280, -400,  182,  -58, -295, -355,  -26,  517,
+  482, -152,  600,  365,  -75, -163,   68,   59,  334,  422,
+ -368, -176,  -15, -400,    0,-1400,
+	},
+
+	{
+ -323, -106, -400, -400,  -40, -203, -400, -400, -152,  425,
+  420, -215,  365,  600, -306, -386, -143,  282,  462,  191,
+ -400, -315,  -15, -400,    0,-1400,
+	},
+
+	{
+  582, -229,   85,  -86,  220,   51, -109,  322,  -15, -149,
+ -172, -240,  -75, -306,  600,  440,  351, -400, -292,   88,
+    0,  -29,  -15, -400,    0,-1400,
+	},
+
+	{
+  454, -183,  225,   65,   74,  128,   11,  357,   45, -243,
+ -269, -175, -163, -386,  440,  600,  345, -400, -352,  -15,
+  145,   70,  -15, -400,    0,-1400,
+	},
+
+	{
+  342,   20,  200,   14,  185,  280,   77,  114,  222,  -12,
+  -43,   -1,   68, -143,  351,  345,  600, -400, -100,  194,
+  107,  178,  -15, -400,    0,-1400,
+	},
+
+	{
+ -400, -178, -400, -400, -355, -378, -400, -400, -303,  108,
+  105, -289,   59,  282, -400, -400, -400,  600,  297, -118,
+ -400, -400,  -15, -400,    0,-1400,
+	},
+
+	{
+ -309,   22, -378, -400,  -81, -109, -321, -400,  -49,  354,
+  331,  -92,  334,  462, -292, -352, -100,  297,  600,  165,
+ -400, -215,  -15, -400,    0,-1400,
+	},
+
+	{
+   71,  -95, -189, -372,  354,   -9, -249, -189,   -3,  357,
+  340, -172,  422,  191,   88,  -15,  194, -118,  165,  600,
+ -280, -129,  -15, -400,    0,-1400,
+	},
+
+	{
+    7,  -26,  507,  507, -302,  248,  350,  -19,  169, -400,
+ -400,   44, -368, -400,    0,  145,  107, -400, -400, -280,
+  507,  299, -400, -400,    0,-1400,
+	},
+
+	{
+  -26,  231,  337,  261, -220,  480,  480, -152,  417, -252,
+ -290,  285, -176, -315,  -29,   70,  178, -400, -215, -129,
+  299,  480, -400, -400,    0,-1400,
+	},
+
+	{
+  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
+  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
+ -400, -400, -400, -400,    0,-1400,
+	},
+
+	{
+ -400, -400, -400, -400, -400, -400, -400, -400, -400, -400,
+ -400, -400, -400, -400, -400, -400, -400, -400, -400, -400,
+ -400, -400, -400, -400,    0,-1400,
+	},
+
+	{
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,
+	},
+
+	{
+-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,
+-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,-1400,
+-1400,-1400,-1400,-1400,    0, 1600,
+	},
+    };

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,271 @@
+#define USE_XCED 0
+
+#if USE_XCED
+#include "config.h"
+#include "share.h"
+#else
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+#include <ctype.h>
+#include "mtxutl.h"
+#include <float.h>
+
+#define VERSION "6.624b"
+#ifdef LLVM
+#define SHOWVERSION fprintf( stderr, "%s (%s) Version " VERSION " alg=%c, model=%s\n", "<progname>", (dorp=='d')?"nuc":"aa", alg, modelname )
+#else
+#define SHOWVERSION fprintf( stderr, "%s (%s) Version " VERSION " alg=%c, model=%s\n", progName( argv[0] ), (dorp=='d')?"nuc":"aa", alg, modelname )
+#endif
+
+#define FFT_THRESHOLD  80
+#define FFT_WINSIZE_P   20
+#define FFT_WINSIZE_D   100
+#define DISPSEQF  60
+#define DISPSITEI    0
+#define MAXITERATION 500
+#define M   50000       /* njob no saidaiti */
+#define N 5000000       /* nlen no saidaiti */
+#define MAXSEG 100000
+#define B     256
+#define C     60       /*  1 gyou no mojisuu */
+#define D      6
+#define rnd() ( ( 1.0 / ( RAND_MAX + 1.0 ) ) * rand() )
+#define MAX(X,Y)    ( ((X)>(Y))?(X):(Y) )
+#define MIN(X,Y)    ( ((X)<(Y))?(X):(Y) )
+#define G(X)        ( ((X)>(0))?(X):(0) )
+#define BEFF   1.0   /* 0.6 ni suruto zureru */
+#define WIN   3
+#define SGAPP -1000
+#define GETA2 0.001
+#define GETA3 0.001
+#define NOTSPECIFIED  100009
+#define SUEFF   0.1  /* upg/(spg+upg)  -> sueff.sed */ 
+#define DIVLOCAL 0
+#define INTMTXSCALE 1000000.0
+#define JTT 201
+#define TM  202
+
+extern char modelname[100];
+extern int njob, nlenmax;
+extern int amino_n[0x80];
+extern char amino_grp[0x80];
+extern int amino_dis[0x80][0x80];
+extern int amino_disLN[0x80][0x80];
+extern double amino_dis_consweight_multi[0x80][0x80];
+extern int n_dis[26][26];
+extern int n_disFFT[26][26];
+extern float n_dis_consweight_multi[26][26];
+extern char amino[26];
+extern double polarity[20];
+extern double volume[20];
+extern int ribosumdis[37][37];
+
+extern int ppid;
+extern double thrinter;
+extern double fastathreshold;
+extern int pslocal, ppslocal;
+extern int constraint;
+extern int divpairscore;
+extern int fmodel; // 1-> fmodel 0->default -1->raw
+extern int nblosum; // 45, 50, 62, 80
+extern int kobetsubunkatsu;
+extern int bunkatsu;
+extern int dorp;
+extern int niter;
+extern int contin;
+extern int calledByXced;
+extern int devide;
+extern int scmtd;
+extern int weight;
+extern int utree;
+extern int tbutree;
+extern int refine;
+extern int check;
+extern double cut;
+extern int cooling;
+extern int penalty, ppenalty, penaltyLN;
+extern int RNApenalty, RNAppenalty;
+extern int RNApenalty_ex, RNAppenalty_ex;
+extern int penalty_ex, ppenalty_ex, penalty_exLN;
+extern int penalty_EX, ppenalty_EX;
+extern int penalty_OP, ppenalty_OP;
+extern int offset, poffset, offsetLN, offsetFFT;
+extern int RNAthr, RNApthr;
+extern int scoremtx;
+extern int TMorJTT;
+extern char use_fft;
+extern char force_fft;
+extern int nevermemsave;
+extern int fftscore;
+extern int fftWinSize;
+extern int fftThreshold;
+extern int fftRepeatStop;
+extern int fftNoAnchStop;
+extern int divWinSize;
+extern int divThreshold;
+extern int disp;
+extern int outgap;
+extern char alg;
+extern int cnst;
+extern int mix;
+extern int tbitr;
+extern int tbweight;
+extern int tbrweight;
+extern int disopt;
+extern int pamN;
+extern int checkC;
+extern float geta2;
+extern int treemethod;
+extern int kimuraR;
+extern char *swopt;
+extern int fftkeika;
+extern int score_check;
+extern char *inputfile;
+extern float consweight_multi;
+extern float consweight_rna;
+extern char RNAscoremtx;
+
+extern char *signalSM;
+extern FILE *prep_g;
+extern FILE *trap_g;
+extern char **seq_g;
+extern char **res_g;
+extern int rnakozo;
+extern char rnaprediction;
+
+/* sengen no ichi ha koko dake de ha nai */
+extern void constants();
+extern char **Calignm1();
+extern char **Dalignm1();
+extern char **align0();
+extern double Cscore_m_1( char **, int, int, double ** );
+extern double score_m_1(  char **, int, int, double ** );
+extern double score_calc0( char **, int, double **, int );
+extern char seqcheck( char ** );
+extern float substitution( char *, char * );
+extern float substitution_score( char *, char * );
+extern float substitution_nid( char *, char * );
+extern float substitution_hosei( char *, char * );
+extern double ipower( double, int );
+extern float translate_and_Calign();
+extern float A__align();
+extern float A__align11();
+extern float A__align_gapmap();
+extern float partA__align();
+extern float L__align11();
+extern float G__align11();
+extern float Falign();
+extern float Falign_localhom();
+extern float Conalign();
+extern float Aalign();
+extern float imp_match_out_sc( int, int );
+extern float part_imp_match_out_sc( int, int );
+extern void ErrorExit();
+extern void cpmx_calc();
+extern void intergroup_score( char **, char **, double *, double *, int, int, int, double * );
+extern int conjuctionfortbfast();
+extern int fastconjuction();
+extern char seqcheck( char ** );
+
+typedef struct _LocalHom
+{
+	int nokori;
+	struct _LocalHom *next;
+	struct _LocalHom *last;
+	int start1;
+	int end1;
+	int start2;
+	int end2;
+	double opt;
+	int overlapaa;
+	int extended;
+	double importance;
+	float fimportance;
+	double wimportance;
+} LocalHom;
+
+typedef struct _NodeInCub
+{
+	int step;
+	int LorR;
+} NodeInCub;
+
+typedef struct _Node
+{
+	struct _Node *children[3];
+	int tmpChildren[3];
+	double length[3];
+	double *weightptr[3];
+	int top[3];
+	int *members[3];
+} Node;
+
+typedef struct _Segment
+{
+	int start;
+	int end;
+	int center;
+	double score;
+	int skipForeward;
+	int skipBackward;
+	struct _Segment *pair;
+	int  number;
+} Segment;
+
+typedef struct _Segments
+{
+	Segment group1;
+	Segment group2;
+	int number1;
+	int number2;
+} Segments;
+
+typedef struct _Bchain
+{
+	struct _Bchain *next;
+	struct _Bchain *prev;
+	int pos;
+} Bchain;
+
+typedef struct _Achain
+{
+	int next;
+	int prev;
+//	int curr;
+} Achain;
+
+
+typedef struct _Fukusosuu
+{
+    double R;
+    double I;
+} Fukusosuu;
+
+typedef struct _Gappattern
+{
+	int len;
+	float freq;
+} Gappat;
+
+typedef struct _RNApair
+{
+	int uppos;
+	float upscore;
+	int downpos;
+	float downscore;
+	int bestpos;
+	float bestscore;
+} RNApair;
+
+
+#include "fft.h"
+#include "dp.h"
+#include "functions.h"
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln9.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln9.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln9.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/mltaln9.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,7001 @@
+#include "mltaln.h"
+
+#define DEBUG 0
+
+int seqlen( char *seq )
+{
+	int val = 0;
+	while( *seq )
+		if( *seq++ != '-' ) val++;
+	return( val );
+}
+
+int intlen( int *num )
+{
+	int value = 0;
+	while( *num++ != -1 ) value++;
+	return( value );
+}
+
+char seqcheck( char **seq )
+{
+	int i, len;
+	char **seqbk = seq;
+	while( *seq )	
+	{
+		len = strlen( *seq );
+		for( i=0; i<len; i++ ) 
+		{
+			if( amino_n[(int)(*seq)[i]] == -1 ) 
+			{
+
+				fprintf( stderr, "========================================================================= \n" );
+				fprintf( stderr, "========================================================================= \n" );
+				fprintf( stderr, "========================================================================= \n" );
+				fprintf( stderr, "=== \n" );
+				fprintf( stderr, "=== Alphabet '%c' is unknown.\n", (*seq)[i] );
+				fprintf( stderr, "=== Please check site %d in sequence %d.\n", i+1, (int)(seq-seqbk+1) );
+				fprintf( stderr, "=== \n" );
+				fprintf( stderr, "========================================================================= \n" );
+				fprintf( stderr, "========================================================================= \n" );
+				fprintf( stderr, "========================================================================= \n" );
+				return( (int)(*seq)[i] );
+			}
+		}
+		seq++;
+	}
+	return( 0 );
+}
+	
+void scmx_calc( int icyc, char **aseq, double *effarr, float **scmx )
+{
+	int  i, j, lgth;
+	 
+	lgth = strlen( aseq[0] );
+	for( j=0; j<lgth; j++ )
+	{
+		for( i=0; i<26; i++ )
+		{
+			scmx[i][j] = 0;
+		}
+	}
+	for( i=0; i<icyc+1; i++ )
+	{
+		int id;
+		id = amino_n[(int)aseq[i][0]];
+		scmx[id][0] += (float)effarr[i];
+	}
+	for( j=1; j<lgth-1; j++ )
+	{
+		for( i=0; i<icyc+1; i++ )
+		{
+			int id;
+			id = amino_n[(int)aseq[i][j]];
+			scmx[id][j] += (float)effarr[i];
+		}
+	}
+	for( i=0; i<icyc+1; i++ )
+	{
+		int id;
+		id = amino_n[(int)aseq[i][lgth-1]];
+		scmx[id][lgth-1] += (float)effarr[i];
+	}
+}
+
+void exitall( char arr[] )
+{
+	fprintf( stderr, "%s\n", arr );
+	exit( 1 );
+}
+
+void display( char **seq, int nseq )
+{
+	int i, imax;
+	char b[121];
+
+	if( !disp ) return;
+		if( nseq > DISPSEQF ) imax = DISPSEQF;
+		else                  imax = nseq;
+		fprintf( stderr, "    ....,....+....,....+....,....+....,....+....,....+....,....+....,....+....,....+....,....+....,....+....,....+....,....+\n" );
+		for( i=0; i<+imax; i++ )
+		{
+			strncpy( b, seq[i]+DISPSITEI, 120 );
+			b[120] = 0;
+			fprintf( stderr, "%3d %s\n", i+1, b );
+		}
+}
+#if 0
+double intergroup_score( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len )
+{
+	int i, j, k;
+	double score;
+	double tmpscore;
+	char *mseq1, *mseq2;
+	double efficient;
+	char xxx[100];
+
+//	totaleff1 = 0.0; for( i=0; i<clus1; i++ ) totaleff1 += eff1[i];
+//	totaleff2 = 0.0; for( i=0; i<clus2; i++ ) totaleff2 += eff2[i];
+
+	score = 0.0;
+	for( i=0; i<clus1; i++ ) for( j=0; j<clus2; j++ ) 
+	{
+		efficient = eff1[i] * eff2[j];
+		mseq1 = seq1[i];
+		mseq2 = seq2[j];
+		tmpscore = 0.0;
+		for( k=0; k<len; k++ ) 
+		{
+			if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+			tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+
+			if( mseq1[k] == '-' ) 
+			{
+				tmpscore += penalty;
+				tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+				while( mseq1[++k] == '-' )
+					tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+				k--;
+				if( k >len-2 ) break;
+				continue;
+			}
+			if( mseq2[k] == '-' )
+			{
+				tmpscore += penalty;
+				tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+				while( mseq2[++k] == '-' )
+					tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+				k--;
+				if( k > len-2 ) break;
+				continue;
+			}
+		}
+		score += (double)tmpscore * efficient;
+#if 1
+		sprintf( xxx, "%f", score );
+//		fprintf( stderr, "## score in intergroup_score = %f\n", score );
+#endif
+	}
+#if 0
+		fprintf( stderr, "###score = %f\n", score );
+#endif
+#if 0
+	fprintf( stderr, "## score in intergroup_score = %f\n", score );
+#endif
+	return( score );
+}
+#endif
+
+void intergroup_score_consweight( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value )
+{
+	int i, j, k;
+	int len2 = len - 2;
+	int ms1, ms2;
+	double tmpscore;
+	char *mseq1, *mseq2;
+	double efficient;
+
+//	totaleff1 = 0.0; for( i=0; i<clus1; i++ ) totaleff1 += eff1[i];
+//	totaleff2 = 0.0; for( i=0; i<clus2; i++ ) totaleff2 += eff2[i];
+
+
+
+	*value = 0.0;
+	for( i=0; i<clus1; i++ ) 
+	{
+		for( j=0; j<clus2; j++ ) 
+		{
+			efficient = eff1[i] * eff2[j]; /* $B$J$<$+G[Ns$r;H$o$J$$$H$*$+$7$/$J$k(B, $BB?J,%P%0(B */
+			mseq1 = seq1[i];
+			mseq2 = seq2[j];
+			tmpscore = 0.0;
+			for( k=0; k<len; k++ ) 
+			{
+				ms1 = (int)mseq1[k];
+				ms2 = (int)mseq2[k];
+				if( ms1 == (int)'-' && ms2 == (int)'-' ) continue;
+				tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+	
+				if( ms1 == (int)'-' ) 
+				{
+					tmpscore += (double)penalty;
+					tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					while( (ms1=(int)mseq1[++k]) == (int)'-' )
+						;
+//						tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					k--;
+					if( k >len2 ) break;
+					continue;
+				}
+				if( ms2 == (int)'-' )
+				{
+					tmpscore += (double)penalty;
+					tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					while( (ms2=(int)mseq2[++k]) == (int)'-' )
+						;
+//						tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					k--;
+					if( k > len2 ) break;
+					continue;
+				}
+			}
+			*value += (double)tmpscore * (double)efficient;
+//			fprintf( stderr, "val in _gapnomi = %f\n", *value );
+		}
+	}
+#if 0
+	fprintf( stdout, "###score = %f\n", score );
+#endif
+#if DEBUG
+	fprintf( stderr, "score in intergroup_score = %f\n", score );
+#endif
+//	return( score );
+}
+void intergroup_score_gapnomi( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value )
+{
+	int i, j, k;
+	int len2 = len - 2;
+	int ms1, ms2;
+	double tmpscore;
+	char *mseq1, *mseq2;
+	double efficient;
+
+//	totaleff1 = 0.0; for( i=0; i<clus1; i++ ) totaleff1 += eff1[i];
+//	totaleff2 = 0.0; for( i=0; i<clus2; i++ ) totaleff2 += eff2[i];
+
+
+
+	*value = 0.0;
+	for( i=0; i<clus1; i++ ) 
+	{
+		for( j=0; j<clus2; j++ ) 
+		{
+			efficient = eff1[i] * eff2[j]; /* $B$J$<$+G[Ns$r;H$o$J$$$H$*$+$7$/$J$k(B, $BB?J,%P%0(B */
+			mseq1 = seq1[i];
+			mseq2 = seq2[j];
+			tmpscore = 0.0;
+			for( k=0; k<len; k++ ) 
+			{
+				ms1 = (int)mseq1[k];
+				ms2 = (int)mseq2[k];
+				if( ms1 == (int)'-' && ms2 == (int)'-' ) continue;
+//				tmpscore += (double)amino_dis[ms1][ms2];
+	
+				if( ms1 == (int)'-' ) 
+				{
+					tmpscore += (double)penalty;
+//					tmpscore += (double)amino_dis[ms1][ms2];
+					while( (ms1=(int)mseq1[++k]) == (int)'-' )
+						;
+//						tmpscore += (double)amino_dis[ms1][ms2];
+					k--;
+					if( k >len2 ) break;
+					continue;
+				}
+				if( ms2 == (int)'-' )
+				{
+					tmpscore += (double)penalty;
+//					tmpscore += (double)amino_dis[ms1][ms2];
+					while( (ms2=(int)mseq2[++k]) == (int)'-' )
+						;
+//						tmpscore += (double)amino_dis[ms1][ms2];
+					k--;
+					if( k > len2 ) break;
+					continue;
+				}
+			}
+			*value += (double)tmpscore * (double)efficient;
+//			fprintf( stderr, "val in _gapnomi = %f\n", *value );
+		}
+	}
+#if 0
+	fprintf( stdout, "###score = %f\n", score );
+#endif
+#if DEBUG
+	fprintf( stderr, "score in intergroup_score = %f\n", score );
+#endif
+//	return( score );
+}
+
+void intergroup_score( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value )
+{
+	int i, j, k;
+	int len2 = len - 2;
+	int ms1, ms2;
+	double tmpscore;
+	char *mseq1, *mseq2;
+	double efficient;
+
+	double gaptmpscore;
+	double gapscore = 0.0;
+
+//	fprintf( stderr, "#### in intergroup_score\n" );
+
+//	totaleff1 = 0.0; for( i=0; i<clus1; i++ ) totaleff1 += eff1[i];
+//	totaleff2 = 0.0; for( i=0; i<clus2; i++ ) totaleff2 += eff2[i];
+
+	*value = 0.0;
+	for( i=0; i<clus1; i++ ) 
+	{
+		for( j=0; j<clus2; j++ ) 
+		{
+			efficient = eff1[i] * eff2[j]; /* $B$J$<$+G[Ns$r;H$o$J$$$H$*$+$7$/$J$k(B, $BB?J,%P%0(B */
+			mseq1 = seq1[i];
+			mseq2 = seq2[j];
+			tmpscore = 0.0;
+			gaptmpscore = 0.0;
+			for( k=0; k<len; k++ ) 
+			{
+				ms1 = (int)mseq1[k];
+				ms2 = (int)mseq2[k];
+				if( ms1 == (int)'-' && ms2 == (int)'-' ) continue;
+//				tmpscore += (double)amino_dis[ms1][ms2];
+				tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+	
+				if( ms1 == (int)'-' ) 
+				{
+					tmpscore += (double)penalty;
+					gaptmpscore += (double)penalty;
+//					tmpscore += (double)amino_dis[ms1][ms2];
+					tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					while( (ms1=(int)mseq1[++k]) == (int)'-' )
+//						tmpscore += (double)amino_dis[ms1][ms2];
+						tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					k--;
+					if( k >len2 ) break;
+					continue;
+				}
+				if( ms2 == (int)'-' )
+				{
+					tmpscore += (double)penalty;
+					gaptmpscore += (double)penalty;
+//					tmpscore += (double)amino_dis[ms1][ms2];
+					tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					while( (ms2=(int)mseq2[++k]) == (int)'-' )
+//						tmpscore += (double)amino_dis[ms1][ms2];
+						tmpscore += (double)amino_dis_consweight_multi[ms1][ms2];
+					k--;
+					if( k > len2 ) break;
+					continue;
+				}
+			}
+			*value += (double)tmpscore * (double)efficient;
+			gapscore += (double)gaptmpscore * (double)efficient;
+		}
+	}
+#if 0
+	fprintf( stderr, "###gapscore = %f\n", gapscore );
+#endif
+#if DEBUG
+	fprintf( stderr, "score in intergroup_score = %f\n", score );
+#endif
+//	return( score );
+}
+void intergroup_score_new( char **seq1, char **seq2, double *eff1, double *eff2, int clus1, int clus2, int len, double *value )
+{
+	int i, j, k;
+	int len2 = len - 2;
+	int ms1, ms2;
+	double tmpscore;
+	char *mseq1, *mseq2;
+	static double efficient[1];
+
+//	totaleff1 = 0.0; for( i=0; i<clus1; i++ ) totaleff1 += eff1[i];
+//	totaleff2 = 0.0; for( i=0; i<clus2; i++ ) totaleff2 += eff2[i];
+
+	*value = 0.0;
+	for( i=0; i<clus1; i++ ) 
+	{
+		for( j=0; j<clus2; j++ ) 
+		{
+			*efficient = eff1[i] * eff2[j]; /* $B$J$<$+G[Ns$r;H$o$J$$$H$*$+$7$/$J$k(B, $BB?J,%P%0(B */
+			mseq1 = seq1[i];
+			mseq2 = seq2[j];
+			tmpscore = 0.0;
+			for( k=0; k<len; k++ ) 
+			{
+				ms1 = (int)mseq1[k];
+				ms2 = (int)mseq2[k];
+				if( ms1 == (int)'-' && ms2 == (int)'-' ) continue;
+				tmpscore += (double)amino_dis[ms1][ms2];
+	
+				if( ms1 == (int)'-' ) 
+				{
+					tmpscore += (double)penalty;
+					tmpscore += (double)amino_dis[ms1][ms2];
+					while( (ms1=(int)mseq1[++k]) == (int)'-' )
+						tmpscore += (double)amino_dis[ms1][ms2];
+					k--;
+					if( k >len2 ) break;
+					continue;
+				}
+				if( ms2 == (int)'-' )
+				{
+					tmpscore += (double)penalty;
+					tmpscore += (double)amino_dis[ms1][ms2];
+					while( (ms2=(int)mseq2[++k]) == (int)'-' )
+						tmpscore += (double)amino_dis[ms1][ms2];
+					k--;
+					if( k > len2 ) break;
+					continue;
+				}
+			}
+			*value += (double)tmpscore * (double)*efficient;
+		}
+	}
+#if 0
+	fprintf( stdout, "###score = %f\n", score );
+#endif
+#if DEBUG
+	fprintf( stderr, "score in intergroup_score = %f\n", score );
+#endif
+//	return( score );
+}
+
+
+double score_calc3( char **seq, int s, double **eff, int ex )  /* method 3 */
+{
+    int i, j, k, c;
+    int len = strlen( seq[0] );
+    double score;
+    long tmpscore;
+    static char mseq1[N*2], mseq2[N*2];
+	double totaleff;
+
+	switch( weight )
+	{
+		case 0:
+			totaleff = ( (double)s * ((double)s-1.0) ) / 2.0;
+			break;
+		case 2:
+			totaleff = s / 2; 
+			break;
+		case 3:
+			totaleff = 0.0; for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ ) totaleff += eff[i][j];
+			break;
+		default:
+			fprintf( stderr, "error\n" );
+			exit( 1 );
+	}
+
+    score = 0.0;
+    for( i=0; i<s-1; i++ )
+    {
+        for( j=i+1; j<s; j++ )
+        {
+            strcpy( mseq1, seq[i] );
+            strcpy( mseq2, seq[j] );
+            tmpscore = 0;
+            c = 0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]] + 400 * !scoremtx;
+                c++;
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[0][24];
+                    while( mseq1[++k] == '-' )
+                        ;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[0][24];
+                    while( mseq2[++k] == '-' )
+                        ;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+            /*
+            if( mseq1[0] == '-' || mseq2[0] == '-' )
+            {
+                for( k=0; k<len; k++ )
+                {
+                    if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                    if( !( mseq1[k] != '-' && mseq2[k] != '-' ) )
+                    {
+                        c--;
+                        tmpscore -= SGAPP;
+                        break;
+                    }
+                    else break;
+                }
+            }
+            if( mseq1[len-1] == '-' || mseq2[len-1] == '-' )
+            {
+                for( k=len-1; k>=0; k-- )
+                {
+                    if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                    if( !( mseq1[k] != '-' && mseq2[k] != '-' ) )
+                    {
+                        c--;
+                        tmpscore -= SGAPP;
+                        break;
+                    }
+                    else break;
+                }
+            }
+            */
+            /*
+            if( x == 65 ) printf( "i=%d j=%d tmpscore=%d l=%d\n", i, j, tmpscore, len )
+;
+            */
+            score += (double)tmpscore / (double)c * eff[i][j];
+        }
+    }
+	if( weight == 0 )
+    	score /= totaleff; 
+    return( (double)score );
+}
+double score_calc5( char **seq, int s, double **eff, int ex )  /* method 3 deha nai */
+{
+    int i, j, k;
+    double c;
+    int len = strlen( seq[0] );
+    double score;
+    double tmpscore;
+    char *mseq1, *mseq2;
+    double efficient;
+#if DEBUG
+	FILE *fp;
+#endif
+
+    score = 0.0;
+    c = 0.0;
+
+	for( i=0; i<s; i++ ) 
+	{
+		
+			if( i == ex ) continue;
+            efficient = eff[i][ex];
+            mseq1 = seq[i];
+            mseq2 = seq[ex];
+            tmpscore = 0.0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq1[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq2[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+            score += (double)tmpscore * efficient;
+/*
+			fprintf( stdout, "%d-%d tmpscore = %f, eff = %f, tmpscore*eff = %f\n", i, ex, tmpscore, efficient, tmpscore*efficient );
+*/
+	}
+	/*
+	fprintf( stdout, "total score = %f\n", score );
+	*/
+
+    for( i=0; i<s-1; i++ )
+    {
+        for( j=i+1; j<s; j++ )
+        {
+			if( i == ex || j == ex ) continue;
+
+            efficient = eff[i][j];
+            mseq1 = seq[i];
+            mseq2 = seq[j];
+            tmpscore = 0.0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq1[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq2[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+            score += (double)tmpscore * efficient;
+        }
+    }
+/*
+	fprintf( stderr, "score in score_calc5 = %f\n", score );
+*/
+    return( (double)score );
+/*
+
+fprintf( trap_g, "score by fast = %f\n", (float)score );
+
+tmpscore = score = 0.0;
+	for( i=0; i<s; i++ ) 
+	{
+		if( i == ex ) continue;
+		tmpscore = Cscore_m_1( seq, i, eff );
+		fprintf( stdout, "%d %f\n", i, tmpscore );
+
+		score += tmpscore;
+	}
+	tmpscore = Cscore_m_1( seq, ex, eff );
+	fprintf( stdout, "ex%d %f\n", i, tmpscore );
+	score += tmpscore;
+
+	return( score );
+*/
+}
+
+
+	
+double score_calc4( char **seq, int s, double **eff, int ex )  /* method 3 deha nai */
+{
+    int i, j, k;
+	double c;
+    int len = strlen( seq[0] );
+    double score;
+    long tmpscore;
+	char *mseq1, *mseq2;
+	double efficient;
+
+    score = 0.0;
+	c = 0.0;
+/*
+	printf( "in score_calc4\n" );
+	for( i=0; i<s; i++ )
+	{
+		for( j=0; j<s; j++ ) 
+		{
+			printf( "% 5.3f", eff[i][j] ); 
+		}
+		printf( "\n" );
+		
+	}
+*/
+    for( i=0; i<s-1; i++ )
+    {
+        for( j=i+1; j<s; j++ )
+        {
+			efficient = eff[i][j];
+			if( mix == 1 ) efficient = 1.0;
+			/*
+			printf( "weight for %d v.s. %d = %f\n", i, j, efficient );
+			*/
+            mseq1 = seq[i];
+            mseq2 = seq[j];
+            tmpscore = 0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]] + 400 * !scoremtx ;
+
+				c += efficient;
+
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[24][0];
+                    while( mseq1[++k] == '-' )
+						;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[24][0];
+                    while( mseq2[++k] == '-' )
+						;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+			/*
+			if( x == 65 ) printf( "i=%d j=%d tmpscore=%d l=%d\n", i, j, tmpscore, len );
+			*/
+            score += (double)tmpscore * efficient;
+        }
+    }
+    score /= c;
+    return( (double)score );
+}
+
+
+
+void upg2( int nseq, double **eff, int ***topol, double **len )
+{
+    int i, j, k;
+	double tmplen[M];
+
+    static char **pair = NULL;
+
+	if( !pair )
+	{
+		pair = AllocateCharMtx( njob, njob );
+	}
+
+	for( i=0; i<nseq; i++ ) tmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) pair[i][j] = 0;
+    for( i=0; i<nseq; i++ ) pair[i][i] = 1;
+
+    for( k=0; k<nseq-1; k++ )
+    {
+        float minscore = 9999.0;
+        int im = -1, jm = -1;
+        int count;
+
+        for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+        {
+            if( eff[i][j] < minscore )
+            {
+                minscore = eff[i][j];
+                im = i; jm = j;
+            }
+        }
+        for( i=0, count=0; i<nseq; i++ )
+            if( pair[im][i] > 0 )
+            {
+                topol[k][0][count] = i;
+                count++;
+            }
+        topol[k][0][count] = -1;
+        for( i=0, count=0; i<nseq; i++ )
+            if( pair[jm][i] > 0 )
+            {
+                topol[k][1][count] = i;
+                count++;
+            }
+        topol[k][1][count] = -1;
+
+		len[k][0] = minscore / 2.0 - tmplen[im];
+		len[k][1] = minscore / 2.0 - tmplen[jm];
+
+		tmplen[im] = minscore / 2.0;
+
+        for( i=0; i<nseq; i++ ) pair[im][i] += ( pair[jm][i] > 0 );
+        for( i=0; i<nseq; i++ ) pair[jm][i] = 0;
+
+        for( i=0; i<nseq; i++ )
+        {
+            if( i != im && i != jm )
+            {
+                eff[MIN(i,im)][MAX(i,im)] =
+                ( eff[MIN(i,im)][MAX(i,im)] + eff[MIN(i,jm)][MAX(i,jm)] ) / 2.0;
+                eff[MIN(i,jm)][MAX(i,jm)] = 9999.0;
+            }
+            eff[im][jm] = 9999.0;
+        }
+#if DEBUG
+        printf( "STEP-%03d:\n", k+1 );
+		printf( "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) printf( " %03d", topol[k][0][i] );
+        printf( "\n" );
+		printf( "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) printf( " %03d", topol[k][1][i] );
+        printf( "\n" );
+#endif
+    }
+}
+
+static void setnearest( int nseq, Bchain *acpt, float **eff, float *mindisfrompt, int *nearestpt, int pos )
+{
+	int j;
+	float tmpfloat;
+	float **effptpt;
+	Bchain *acptj;
+
+	*mindisfrompt = 999.9;
+	*nearestpt = -1;
+
+//	if( (acpt+pos)->next ) effpt = eff[pos]+(acpt+pos)->next->pos-pos;
+
+//	for( j=pos+1; j<nseq; j++ )
+	for( acptj=(acpt+pos)->next; acptj!=NULL; acptj=acptj->next )
+	{
+		j = acptj->pos;
+//		if( (tmpfloat=*effpt++) < *mindisfrompt )
+		if( (tmpfloat=eff[pos][j-pos]) < *mindisfrompt )
+		{
+			*mindisfrompt = tmpfloat;
+			*nearestpt = j;
+		}
+	}
+	effptpt = eff;
+//	for( j=0; j<pos; j++ )
+	for( acptj=acpt; (acptj&&acptj->pos!=pos); acptj=acptj->next )
+	{
+		j = acptj->pos;
+//		if( (tmpfloat=(*effptpt++)[pos-j]) < *mindisfrompt )
+		if( (tmpfloat=eff[j][pos-j]) < *mindisfrompt )
+		{
+			*mindisfrompt = tmpfloat;
+			*nearestpt = j;
+		}
+	}
+}
+
+
+
+static void loadtreeoneline( int *ar, float *len, FILE *fp )
+{
+	static char gett[1000];
+
+	fgets( gett, 999, fp );
+
+//	fprintf( stderr, "gett=%s\n", gett );
+
+
+	sscanf( gett, "%d %d %a %a", ar, ar+1, len, len+1 );
+
+	ar[0]--;
+	ar[1]--;
+
+	if( ar[0] >= ar[1] )
+	{
+		fprintf( stderr, "Incorrect guide tree\n" );
+		exit( 1 );
+	}
+
+
+//	fprintf( stderr, "ar[0] = %d, ar[1] = %d\n", ar[0], ar[1] );
+//	fprintf( stderr, "len[0] = %f, len[1] = %f\n", len[0], len[1] );
+}
+
+void loadtree( int nseq, int ***topol, float **len, char **name, int *nlen )
+{
+	int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	static int *hist = NULL;
+	static Bchain *ac = NULL;
+	int im = -1, jm = -1;
+	Bchain *acjmnext, *acjmprev;
+	int prevnode;
+	Bchain *acpti;
+	int *pt1, *pt2, *pt11, *pt22;
+	static int *nmemar;
+	int nmemim, nmemjm;
+	float minscore;
+	int *nearest = NULL; // by D.Mathog, a guess
+	float *mindisfrom = NULL; // by D.Mathog, a guess
+	static char **tree;
+	static char *treetmp;
+	static char *nametmp;
+	FILE *fp;
+	int node[2];
+
+	fp = fopen( "_guidetree", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "cannot open _guidetree\n" );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		hist = AllocateIntVec( njob );
+		ac = (Bchain *)malloc( njob * sizeof( Bchain ) );
+		nmemar = AllocateIntVec( njob );
+		mindisfrom = AllocateFloatVec( njob );
+		nearest = AllocateIntVec( njob );
+		treetmp = AllocateCharVec( njob*50 );
+		nametmp = AllocateCharVec( 30 );
+		tree = AllocateCharMtx( njob, njob*50 );
+	}
+
+	
+    for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<30; j++ ) nametmp[j] = 0;
+		for( j=0; j<30; j++ ) 
+		{
+			if( isalnum( name[i][j] ) )
+				nametmp[j] = name[i][j];
+			else
+				nametmp[j] = '_';
+		}
+		nametmp[30] = 0;
+//		sprintf( tree[i], "%d_l=%d_%.20s", i+1, nlen[i], nametmp+1 );
+		sprintf( tree[i], "%d_%.20s", i+1, nametmp+1 );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = ac+i+1;
+		ac[i].prev = ac+i-1;
+		ac[i].pos = i;
+	}
+	ac[nseq-1].next = NULL;
+
+
+	for( i=0; i<nseq; i++ ) 
+	{
+		hist[i] = -1;
+		nmemar[i] = 1;
+	}
+
+	fprintf( stderr, "\n" );
+	for( k=0; k<nseq-1; k++ )
+	{
+		if( k % 10 == 0 ) fprintf( stderr, "\r% 5d / %d", k, nseq );
+#if 0
+		minscore = 999.9;
+		for( acpti=ac; acpti->next!=NULL; acpti=acpti->next ) 
+		{
+			i = acpti->pos;
+//			fprintf( stderr, "k=%d i=%d\n", k, i );
+			if( mindisfrom[i] < minscore ) // muscle
+			{
+				im = i;
+				minscore = mindisfrom[i];
+			}
+		}
+		jm = nearest[im];
+		if( jm < im ) 
+		{
+			j=jm; jm=im; im=j;
+		}
+#else
+		minscore = 0.0;
+		len[k][0] = len[k][1] = -1.0;
+		loadtreeoneline( node, len[k], fp );
+		im = node[0];
+		jm = node[1];
+
+		if( len[k][0] == -1.0 || len[k][1] == -1.0 )
+		{
+			fprintf( stderr, "\n\nERROR: Branch length is not given.\n" );
+			exit( 1 );
+		}
+
+		if( len[k][0] < 0.0 ) len[k][0] = 0.0;
+		if( len[k][1] < 0.0 ) len[k][1] = 0.0;
+
+#endif
+
+		prevnode = hist[im];
+		nmemim = nmemar[im];
+
+//		fprintf( stderr, "prevnode = %d, nmemim = %d\n", prevnode, nmemim );
+
+		intpt = topol[k][0] = (int *)realloc( topol[k][0], ( nmemim + 1 ) * sizeof( int ) );
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+
+		nmemjm = nmemar[jm];
+		prevnode = hist[jm];
+
+//		fprintf( stderr, "prevnode = %d, nmemjm = %d\n", prevnode, nmemjm );
+
+		intpt = topol[k][1] = (int *)realloc( topol[k][1], ( nmemjm + 1 ) * sizeof( int ) );
+		if( !intpt )
+		{
+			fprintf( stderr, "Cannot reallocate topol\n" );
+			exit( 1 );
+		}
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+//		len[k][0] = ( minscore - tmptmplen[im] );
+//		len[k][1] = ( minscore - tmptmplen[jm] );
+//		len[k][0] = -1;
+//		len[k][1] = -1;
+
+
+		hist[im] = k;
+		nmemar[im] = nmemim + nmemjm;
+
+		mindisfrom[im] = 999.9;
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+        {
+			i = acpti->pos;
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+            }
+        }
+
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+
+//		fprintf( stderr, "im,jm=%d,%d\n", im, jm );
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		acjmprev->next = acjmnext;
+		if( acjmnext != NULL )
+			acjmnext->prev = acjmprev;
+//		free( (void *)eff[jm] ); eff[jm] = NULL;
+
+#if 0 // muscle seems to miss this.
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+		{
+			i = acpti->pos;
+			if( nearest[i] == im ) 
+			{
+//				fprintf( stderr, "calling setnearest\n" );
+//				setnearest( nseq, ac, eff, mindisfrom+i, nearest+i, i );
+			}
+		}
+#endif
+
+
+#if 0
+        fprintf( stdout, "vSTEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i]+1 );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i]+1 );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	fclose( fp );
+	fp = fopen( "infile.tree", "w" );
+		fprintf( fp, "%s\n", treetmp );
+		fprintf( fp, "#by loadtree\n" );
+	fclose( fp );
+
+	FreeCharMtx( tree );
+	free( treetmp );
+	free( nametmp );
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	free( (void *)nmemar ); nmemar = NULL;
+	free( mindisfrom );
+	free( nearest );
+
+
+}
+
+static float sueff1, sueff05;
+static double sueff1_double, sueff05_double;
+
+static float cluster_mix_float( float d1, float d2 )
+{
+	return( MIN( d1, d2 ) * sueff1 + ( d1 + d2 ) * sueff05 ); 
+}
+static float cluster_average_float( float d1, float d2 )
+{
+	return( ( d1 + d2 ) * 0.5 ); 
+}
+static float cluster_minimum_float( float d1, float d2 )
+{
+	return( MIN( d1, d2 ) ); 
+}
+static double cluster_mix_double( double d1, double d2 )
+{
+	return( MIN( d1, d2 ) * sueff1_double + ( d1 + d2 ) * sueff05_double ); 
+}
+static double cluster_average_double( double d1, double d2 )
+{
+	return( ( d1 + d2 ) * 0.5 ); 
+}
+static double cluster_minimum_double( double d1, double d2 )
+{
+	return( MIN( d1, d2 ) ); 
+}
+
+void loadtop( int nseq, float **eff, int ***topol, float **len ) // computes branch length BUG!!
+{
+	int i, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	static Bchain *ac = NULL;
+	float eff1, eff0;
+	static float *tmptmplen = NULL;
+	static int *hist = NULL;
+	int im = -1, jm = -1;
+	Bchain *acjmnext, *acjmprev;
+	int prevnode;
+	Bchain *acpti;
+	int *pt1, *pt2, *pt11, *pt22;
+	static int *nmemar;
+	int nmemim, nmemjm;
+	float minscore;
+	static char **tree;
+	static char *treetmp;
+	FILE *fp;
+	int node[2];
+	float dumfl[2];
+	float (*clusterfuncpt[1])(float,float);
+
+
+	sueff1 = 1 - SUEFF;
+	sueff05 = SUEFF * 0.5;
+	if ( treemethod == 'X' )
+		clusterfuncpt[0] = cluster_mix_float;
+	else if ( treemethod == 'E' )
+		clusterfuncpt[0] = cluster_average_float;
+	else if ( treemethod == 'q' )
+		clusterfuncpt[0] = cluster_minimum_float;
+	else
+	{
+		fprintf( stderr, "Unknown treemethod, %c\n", treemethod );
+		exit( 1 );
+	}
+
+	fp = fopen( "_guidetree", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "cannot open _guidetree\n" );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		treetmp = AllocateCharVec( njob*50 );
+		tree = AllocateCharMtx( njob, njob*50 );
+		hist = AllocateIntVec( njob );
+		tmptmplen = AllocateFloatVec( njob );
+		ac = (Bchain *)malloc( njob * sizeof( Bchain ) );
+		nmemar = AllocateIntVec( njob );
+	}
+	
+    for( i=0; i<nseq; i++ ) sprintf( tree[i], "%d", i+1 );
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = ac+i+1;
+		ac[i].prev = ac+i-1;
+		ac[i].pos = i;
+	}
+	ac[nseq-1].next = NULL;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+	for( i=0; i<nseq; i++ ) 
+	{
+		hist[i] = -1;
+		nmemar[i] = 1;
+	}
+
+	fprintf( stderr, "\n" );
+	for( k=0; k<nseq-1; k++ )
+	{
+		if( k % 10 == 0 ) fprintf( stderr, "\r% 5d / %d", k, nseq );
+
+#if 0
+		minscore = 99999.9;
+		for( acpti=ac; acpti->next!=NULL; acpti=acpti->next ) 
+		{
+			effpt = eff[i=acpti->pos];
+//			i = acpti->pos;
+			for( acptj=acpti->next; acptj!=NULL; acptj=acptj->next )
+	        {
+//				j=acptj->pos;
+//				tmpfloat = eff[i][j-i];
+//				if( tmpfloat < minscore )
+				if( (tmpfloat= effpt[(j=acptj->pos)-i]) < minscore )
+				{
+					minscore = tmpfloat;
+					im = i; jm = j;
+				}
+			}
+		}
+
+//		fprintf( stderr, "im=%d, jm=%d, minscore = %f\n", im, jm, minscore );
+#else
+		dumfl[0] = dumfl[1] = -1.0;
+		loadtreeoneline( node, dumfl, fp );
+		im = node[0];
+		jm = node[1];
+		minscore = eff[im][jm-im];
+
+//		fprintf( stderr, "im=%d, jm=%d, minscore = %f\n", im, jm, minscore );
+
+
+		if( dumfl[0] != -1.0 || dumfl[1] != -1.0 )
+		{
+			fprintf( stderr, "\n\nERROR: Branch length should not be given.\n" );
+			exit( 1 );
+		}
+
+#endif
+
+
+		prevnode = hist[im];
+		nmemim = nmemar[im];
+		intpt = topol[k][0] = (int *)realloc( topol[k][0], ( nmemim + 1 ) * sizeof( int ) );
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		prevnode = hist[jm];
+		nmemjm = nmemar[jm];
+		intpt = topol[k][1] = (int *)realloc( topol[k][1], ( nmemjm + 1 ) * sizeof( int ) );
+		if( !intpt )
+		{
+			fprintf( stderr, "Cannot reallocate topol\n" );
+			exit( 1 );
+		}
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = ( minscore - tmptmplen[im] );
+		len[k][1] = ( minscore - tmptmplen[jm] );
+
+		if( len[k][0] < 0.0 ) len[k][0] = 0.0;
+		if( len[k][1] < 0.0 ) len[k][1] = 0.0;
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+		nmemar[im] = nmemim + nmemjm;
+
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+        {
+			i = acpti->pos;
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim-miniim];
+				eff1 = eff[minijm][maxijm-minijm];
+#if 0
+                eff[miniim][maxiim-miniim] =
+				MIN( eff0, eff1 ) * sueff1 + ( eff0 + eff1 ) * sueff05; 
+#else
+                eff[miniim][maxiim-miniim] =
+				(clusterfuncpt[0])( eff0, eff1 );
+#endif
+            }
+        }
+//		sprintf( treetmp, "(%s,%s)", tree[im], tree[jm] );
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		acjmprev->next = acjmnext;
+		if( acjmnext != NULL )
+			acjmnext->prev = acjmprev;
+		free( (void *)eff[jm] ); eff[jm] = NULL;
+#if 0
+        fprintf( stdout, "vSTEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i]+1 );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i]+1 );
+        fprintf( stdout, "\n" );
+#endif
+    }
+#if 1
+	fclose( fp );
+	fp = fopen( "infile.tree", "w" );
+		fprintf( fp, "%s\n", treetmp );
+		fprintf( fp, "by loadtop\n" );
+	fclose( fp );
+#endif
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	free( (void *)nmemar ); nmemar = NULL;
+
+}
+
+
+void fixed_musclesupg_float_realloc_nobk_halfmtx_treeout( int nseq, float **eff, int ***topol, float **len, char **name, int *nlen )
+{
+	int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	float tmpfloat;
+	float eff1, eff0;
+	static float *tmptmplen = NULL;
+	static int *hist = NULL;
+	static Bchain *ac = NULL;
+	int im = -1, jm = -1;
+	Bchain *acjmnext, *acjmprev;
+	int prevnode;
+	Bchain *acpti;
+	int *pt1, *pt2, *pt11, *pt22;
+	static int *nmemar;
+	int nmemim, nmemjm;
+	float minscore;
+	int *nearest = NULL; // by D.Mathog, a guess
+	float *mindisfrom = NULL; // by D.Mathog, a guess
+	static char **tree;
+	static char *treetmp;
+	static char *nametmp;
+	FILE *fp;
+	float (*clusterfuncpt[1])(float,float);
+
+
+	sueff1 = 1 - SUEFF;
+	sueff05 = SUEFF * 0.5;
+	if ( treemethod == 'X' )
+		clusterfuncpt[0] = cluster_mix_float;
+	else if ( treemethod == 'E' )
+		clusterfuncpt[0] = cluster_average_float;
+	else if ( treemethod == 'q' )
+		clusterfuncpt[0] = cluster_minimum_float;
+	else
+	{
+		fprintf( stderr, "Unknown treemethod, %c\n", treemethod );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		hist = AllocateIntVec( njob );
+		tmptmplen = AllocateFloatVec( njob );
+		ac = (Bchain *)malloc( njob * sizeof( Bchain ) );
+		nmemar = AllocateIntVec( njob );
+		mindisfrom = AllocateFloatVec( njob );
+		nearest = AllocateIntVec( njob );
+		treetmp = AllocateCharVec( njob*50 );
+		nametmp = AllocateCharVec( 30 );
+		tree = AllocateCharMtx( njob, njob*50 );
+	}
+
+	
+    for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<30; j++ ) nametmp[j] = 0;
+		for( j=0; j<30; j++ ) 
+		{
+			if( isalnum( name[i][j] ) )
+				nametmp[j] = name[i][j];
+			else
+				nametmp[j] = '_';
+		}
+		nametmp[30] = 0;
+//		sprintf( tree[i], "%d_l=%d_%.20s", i+1, nlen[i], nametmp+1 );
+		sprintf( tree[i], "%d_%.20s", i+1, nametmp+1 );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = ac+i+1;
+		ac[i].prev = ac+i-1;
+		ac[i].pos = i;
+	}
+	ac[nseq-1].next = NULL;
+
+	for( i=0; i<nseq; i++ ) setnearest( nseq, ac, eff, mindisfrom+i, nearest+i, i ); // muscle
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+	for( i=0; i<nseq; i++ ) 
+	{
+		hist[i] = -1;
+		nmemar[i] = 1;
+	}
+
+	fprintf( stderr, "\n" );
+	for( k=0; k<nseq-1; k++ )
+	{
+		if( k % 10 == 0 ) fprintf( stderr, "\r% 5d / %d", k, nseq );
+
+		minscore = 999.9;
+		for( acpti=ac; acpti->next!=NULL; acpti=acpti->next ) 
+		{
+			i = acpti->pos;
+//			fprintf( stderr, "k=%d i=%d\n", k, i );
+			if( mindisfrom[i] < minscore ) // muscle
+			{
+				im = i;
+				minscore = mindisfrom[i];
+			}
+		}
+		jm = nearest[im];
+		if( jm < im ) 
+		{
+			j=jm; jm=im; im=j;
+		}
+
+
+		prevnode = hist[im];
+		nmemim = nmemar[im];
+		intpt = topol[k][0] = (int *)realloc( topol[k][0], ( nmemim + 1 ) * sizeof( int ) );
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		prevnode = hist[jm];
+		nmemjm = nmemar[jm];
+		intpt = topol[k][1] = (int *)realloc( topol[k][1], ( nmemjm + 1 ) * sizeof( int ) );
+		if( !intpt )
+		{
+			fprintf( stderr, "Cannot reallocate topol\n" );
+			exit( 1 );
+		}
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = ( minscore - tmptmplen[im] );
+		len[k][1] = ( minscore - tmptmplen[jm] );
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+		nmemar[im] = nmemim + nmemjm;
+
+		mindisfrom[im] = 999.9;
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+        {
+			i = acpti->pos;
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim-miniim];
+				eff1 = eff[minijm][maxijm-minijm];
+#if 0
+                		tmpfloat = eff[miniim][maxiim-miniim] =
+				MIN( eff0, eff1 ) * sueff1 + ( eff0 + eff1 ) * sueff05; 
+#else
+                tmpfloat = eff[miniim][maxiim-miniim] =
+				(clusterfuncpt[0])( eff0, eff1 );
+#endif
+				if( tmpfloat < mindisfrom[i]  )
+				{
+					mindisfrom[i] = tmpfloat;
+					nearest[i] = im;
+				}
+				if( tmpfloat < mindisfrom[im]  )
+				{
+					mindisfrom[im] = tmpfloat;
+					nearest[im] = i;
+				}
+				if( nearest[i] == jm )
+				{
+					nearest[i] = im;
+				}
+            }
+        }
+
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+
+//		fprintf( stderr, "im,jm=%d,%d\n", im, jm );
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		acjmprev->next = acjmnext;
+		if( acjmnext != NULL )
+			acjmnext->prev = acjmprev;
+		free( (void *)eff[jm] ); eff[jm] = NULL;
+
+#if 1 // muscle seems to miss this.
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+		{
+			i = acpti->pos;
+			if( nearest[i] == im ) 
+			{
+//				fprintf( stderr, "calling setnearest\n" );
+				setnearest( nseq, ac, eff, mindisfrom+i, nearest+i, i );
+			}
+		}
+#endif
+
+
+#if 0
+        fprintf( stdout, "vSTEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i]+1 );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i]+1 );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	fp = fopen( "infile.tree", "w" );
+		fprintf( fp, "%s\n", treetmp );
+	fclose( fp );
+
+	FreeCharMtx( tree );
+	free( treetmp );
+	free( nametmp );
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	free( (void *)nmemar ); nmemar = NULL;
+	free( mindisfrom );
+	free( nearest );
+
+}
+
+
+void fixed_musclesupg_float_realloc_nobk_halfmtx( int nseq, float **eff, int ***topol, float **len )
+{
+	int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	float tmpfloat;
+	float eff1, eff0;
+	static float *tmptmplen = NULL;
+	static int *hist = NULL;
+	static Bchain *ac = NULL;
+	int im = -1, jm = -1;
+	Bchain *acjmnext, *acjmprev;
+	int prevnode;
+	Bchain *acpti;
+	int *pt1, *pt2, *pt11, *pt22;
+	static int *nmemar;
+	int nmemim, nmemjm;
+	float minscore;
+//	float sueff1 = 1 - SUEFF;
+//	float sueff05 = SUEFF * 0.5;
+	int *nearest = NULL; // by Mathog, a guess
+	float *mindisfrom = NULL; // by Mathog, a guess
+	float (*clusterfuncpt[1])(float,float);
+
+
+	sueff1 = 1 - SUEFF;
+	sueff05 = SUEFF * 0.5;
+	if ( treemethod == 'X' )
+		clusterfuncpt[0] = cluster_mix_float;
+	else if ( treemethod == 'E' )
+		clusterfuncpt[0] = cluster_average_float;
+	else if ( treemethod == 'q' )
+		clusterfuncpt[0] = cluster_minimum_float;
+	else
+	{
+		fprintf( stderr, "Unknown treemethod, %c\n", treemethod );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		hist = AllocateIntVec( njob );
+		tmptmplen = AllocateFloatVec( njob );
+		ac = (Bchain *)malloc( njob * sizeof( Bchain ) );
+		nmemar = AllocateIntVec( njob );
+		mindisfrom = AllocateFloatVec( njob );
+		nearest = AllocateIntVec( njob );
+	}
+
+	
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = ac+i+1;
+		ac[i].prev = ac+i-1;
+		ac[i].pos = i;
+	}
+	ac[nseq-1].next = NULL;
+
+	for( i=0; i<nseq; i++ ) setnearest( nseq, ac, eff, mindisfrom+i, nearest+i, i ); // muscle
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+	for( i=0; i<nseq; i++ ) 
+	{
+		hist[i] = -1;
+		nmemar[i] = 1;
+	}
+
+	fprintf( stderr, "\n" );
+	for( k=0; k<nseq-1; k++ )
+	{
+		if( k % 10 == 0 ) fprintf( stderr, "\r% 5d / %d", k, nseq );
+
+		minscore = 999.9;
+		for( acpti=ac; acpti->next!=NULL; acpti=acpti->next ) 
+		{
+			i = acpti->pos;
+//			fprintf( stderr, "k=%d i=%d\n", k, i );
+			if( mindisfrom[i] < minscore ) // muscle
+			{
+				im = i;
+				minscore = mindisfrom[i];
+			}
+		}
+		jm = nearest[im];
+		if( jm < im ) 
+		{
+			j=jm; jm=im; im=j;
+		}
+
+
+		prevnode = hist[im];
+		nmemim = nmemar[im];
+		intpt = topol[k][0] = (int *)realloc( topol[k][0], ( nmemim + 1 ) * sizeof( int ) );
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		prevnode = hist[jm];
+		nmemjm = nmemar[jm];
+		intpt = topol[k][1] = (int *)realloc( topol[k][1], ( nmemjm + 1 ) * sizeof( int ) );
+		if( !intpt )
+		{
+			fprintf( stderr, "Cannot reallocate topol\n" );
+			exit( 1 );
+		}
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = ( minscore - tmptmplen[im] );
+		len[k][1] = ( minscore - tmptmplen[jm] );
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+		nmemar[im] = nmemim + nmemjm;
+
+		mindisfrom[im] = 999.9;
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+        {
+			i = acpti->pos;
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim-miniim];
+				eff1 = eff[minijm][maxijm-minijm];
+				tmpfloat = eff[miniim][maxiim-miniim] =
+#if 0
+				MIN( eff0, eff1 ) * sueff1 + ( eff0 + eff1 ) * sueff05; 
+#else
+				(clusterfuncpt[0])( eff0, eff1 );
+#endif
+				if( tmpfloat < mindisfrom[i]  )
+				{
+					mindisfrom[i] = tmpfloat;
+					nearest[i] = im;
+				}
+				if( tmpfloat < mindisfrom[im]  )
+				{
+					mindisfrom[im] = tmpfloat;
+					nearest[im] = i;
+				}
+				if( nearest[i] == jm )
+				{
+					nearest[i] = im;
+				}
+            }
+        }
+
+//		fprintf( stderr, "im,jm=%d,%d\n", im, jm );
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		acjmprev->next = acjmnext;
+		if( acjmnext != NULL )
+			acjmnext->prev = acjmprev;
+		free( (void *)eff[jm] ); eff[jm] = NULL;
+
+#if 1 // muscle seems to miss this.
+		for( acpti=ac; acpti!=NULL; acpti=acpti->next )
+		{
+			i = acpti->pos;
+			if( nearest[i] == im ) 
+			{
+//				fprintf( stderr, "calling setnearest\n" );
+				setnearest( nseq, ac, eff, mindisfrom+i, nearest+i, i );
+			}
+		}
+#endif
+
+
+#if 0
+        fprintf( stdout, "vSTEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i]+1 );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i]+1 );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	free( (void *)nmemar ); nmemar = NULL;
+	free( mindisfrom );
+	free( nearest );
+}
+
+
+
+
+
+
+
+
+void veryfastsupg_double_loadtop( int nseq, double **eff, int ***topol, double **len ) // BUG!!!
+{
+    int i, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	double eff1, eff0;
+	static double *tmptmplen = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	double minscore;
+	static char **tree;
+	static char *treetmp;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+	FILE *fp;
+	int node[2];
+	float dumfl[2];
+
+	fp = fopen( "_guidetree", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "cannot open _guidetree\n" );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		treetmp = AllocateCharVec( njob*50 );
+		tree = AllocateCharMtx( njob, njob*50 );
+		hist = AllocateIntVec( njob );
+		tmptmplen = (double *)malloc( njob * sizeof( double ) );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+	}
+	for( i=0; i<nseq; i++ ) sprintf( tree[i], "%d", i+1 );
+	
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+#if 0
+		minscore = 99999.9;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpdouble = eff[i][j];
+				if( tmpdouble < minscore )
+				{
+					minscore = tmpdouble;
+					im = i; jm = j;
+				}
+			}
+		}
+#else
+		dumfl[0] = dumfl[1] = -1.0;
+		loadtreeoneline( node, dumfl, fp );
+		im = node[0];
+		jm = node[1];
+		minscore = eff[im][jm];
+
+//		fprintf( stderr, "im=%d, jm=%d, minscore = %f\n", im, jm, minscore );
+
+
+		if( dumfl[0] != -1.0 || dumfl[1] != -1.0 )
+		{
+			fprintf( stderr, "\n\nBranch length should not given.\n" );
+			exit( 1 );
+		}
+#endif
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = minscore - tmptmplen[im];
+		len[k][1] = minscore - tmptmplen[jm];
+
+		if( len[k][0] < 0.0 ) len[k][0] = 0.0;
+		if( len[k][1] < 0.0 ) len[k][1] = 0.0;
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	fclose( fp );
+
+	fp = fopen( "infile.tree", "w" );
+	fprintf( fp, "%s\n", treetmp );
+//	fprintf( fp, "by veryfastsupg_double_loadtop\n" );
+	fclose( fp );
+
+#if 1
+	fprintf( stderr, "\n" );
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	FreeCharMtx( tree );
+	free( treetmp );
+#endif
+}
+
+void veryfastsupg_double_loadtree( int nseq, double **eff, int ***topol, double **len )
+{
+    int i, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	double eff1, eff0;
+	static double *tmptmplen = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	double minscore;
+	static char **tree;
+	static char *treetmp;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+	FILE *fp;
+	int node[2];
+	float lenfl[2];
+
+	fp = fopen( "_guidetree", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "cannot open _guidetree\n" );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		treetmp = AllocateCharVec( njob*50 );
+		tree = AllocateCharMtx( njob, njob*50 );
+		hist = AllocateIntVec( njob );
+		tmptmplen = (double *)malloc( njob * sizeof( double ) );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+	}
+
+	for( i=0; i<nseq; i++ ) sprintf( tree[i], "%d", i+1 );
+	
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+#if 0
+		minscore = 99999.9;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpdouble = eff[i][j];
+				if( tmpdouble < minscore )
+				{
+					minscore = tmpdouble;
+					im = i; jm = j;
+				}
+			}
+		}
+#else
+		lenfl[0] = lenfl[1] = -1.0;
+		loadtreeoneline( node, lenfl, fp );
+		im = node[0];
+		jm = node[1];
+		minscore = eff[im][jm];
+
+//		fprintf( stderr, "im=%d, jm=%d, minscore = %f\n", im, jm, minscore );
+
+
+		if( lenfl[0] == -1.0 || lenfl[1] == -1.0 )
+		{
+			fprintf( stderr, "\n\nWARNING: Branch length is not given.\n" );
+			exit( 1 );
+		}
+
+		if( lenfl[0] < 0.0 ) lenfl[0] = 0.0;
+		if( lenfl[1] < 0.0 ) lenfl[1] = 0.0;
+#endif
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+#if 0
+		len[k][0] = minscore - tmptmplen[im];
+		len[k][1] = minscore - tmptmplen[jm];
+#else
+		len[k][0] = lenfl[0];
+		len[k][1] = lenfl[1];
+#endif
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	fclose( fp );
+
+
+	fp = fopen( "infile.tree", "w" );
+	fprintf( fp, "%s\n", treetmp );
+//	fprintf( fp, "by veryfastsupg_double_loadtree\n" );
+	fclose( fp );
+
+#if 1
+	fprintf( stderr, "\n" );
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	FreeCharMtx( tree );
+	free( treetmp );
+#endif
+
+
+}
+
+#if 0
+void veryfastsupg_double( int nseq, double **eff, int ***topol, double **len )
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	double tmpdouble;
+	double eff1, eff0;
+	static double *tmptmplen = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	double minscore;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+	if( !hist )
+	{
+		hist = AllocateIntVec( njob );
+		tmptmplen = (double *)malloc( njob * sizeof( double ) );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+	}
+	
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+		minscore = 99999.9;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpdouble = eff[i][j];
+				if( tmpdouble < minscore )
+				{
+					minscore = tmpdouble;
+					im = i; jm = j;
+				}
+			}
+		}
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = minscore - tmptmplen[im];
+		len[k][1] = minscore - tmptmplen[jm];
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+#if 1
+	fprintf( stderr, "\n" );
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+#endif
+}
+#endif
+
+void veryfastsupg_double_outtree( int nseq, double **eff, int ***topol, double **len, char name[M][B] )
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	double tmpdouble;
+	double eff1, eff0;
+	static double *tmptmplen = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	double minscore;
+	static char **tree;
+	static char *treetmp;
+	static char *nametmp;
+	FILE *fpout;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+	double (*clusterfuncpt[1])(double,double);
+
+
+	sueff1_double = 1 - SUEFF;
+	sueff05_double = SUEFF * 0.5;
+	if ( treemethod == 'X' )
+		clusterfuncpt[0] = cluster_mix_double;
+	else if ( treemethod == 'E' )
+		clusterfuncpt[0] = cluster_average_double;
+	else if ( treemethod == 'q' )
+		clusterfuncpt[0] = cluster_minimum_double;
+	else
+	{
+		fprintf( stderr, "Unknown treemethod, %c\n", treemethod );
+		exit( 1 );
+	}
+
+	if( !hist )
+	{
+		treetmp = AllocateCharVec( njob*50 );
+		tree = AllocateCharMtx( njob, njob*50 );
+		hist = AllocateIntVec( njob );
+		tmptmplen = (double *)malloc( njob * sizeof( double ) );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+		nametmp = AllocateCharVec( 30 );
+	}
+
+//	for( i=0; i<nseq; i++ ) sprintf( tree[i], "%d", i+1 );
+    for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<30; j++ ) nametmp[j] = 0;
+		for( j=0; j<30; j++ ) 
+		{
+			if( isalnum( name[i][j] ) )
+				nametmp[j] = name[i][j];
+			else
+				nametmp[j] = '_';
+		}
+		nametmp[30] = 0;
+		sprintf( tree[i], "%d_%.20s", i+1, nametmp+1 );
+	}
+	
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+		minscore = 99999.9;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpdouble = eff[i][j];
+				if( tmpdouble < minscore )
+				{
+					minscore = tmpdouble;
+					im = i; jm = j;
+				}
+			}
+		}
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = minscore - tmptmplen[im];
+		len[k][1] = minscore - tmptmplen[jm];
+
+		tmptmplen[im] = minscore;
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+#if 0
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+#else
+                eff[miniim][maxiim] =
+				(clusterfuncpt[0])( eff0, eff1 );
+#endif
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+
+		sprintf( treetmp, "(%s:%7.5f,%s:%7.5f)", tree[im], len[k][0], tree[jm], len[k][1] );
+		strcpy( tree[im], treetmp );
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	fpout = fopen( "infile.tree", "w" );
+	fprintf( fpout, "%s\n", treetmp );
+//	fprintf( fpout, "by veryfastsupg_double_outtree\n" );
+	fclose( fpout );
+#if 1
+	fprintf( stderr, "\n" );
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+	FreeCharMtx( tree );
+	free( treetmp );
+	free( nametmp );
+#endif
+}
+
+void veryfastsupg( int nseq, double **oeff, int ***topol, double **len )
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	int tmpint;
+	int eff1, eff0;
+	static double *tmptmplen = NULL;
+	static int **eff = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	int minscore;
+	double minscoref;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+	if( !eff )
+	{
+		eff = AllocateIntMtx( njob, njob );
+		hist = AllocateIntVec( njob );
+		tmptmplen = (double *)malloc( njob * sizeof( double ) );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+	}
+	
+	for( i=0; i<nseq; i++ ) 
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			eff[i][j] = (int)( oeff[i][j] * INTMTXSCALE + 0.5 );
+		}
+	}
+
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+		minscore = INTMTXSCALE*4;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpint = eff[i][j];
+				if( tmpint < minscore )
+				{
+					minscore = tmpint;
+					im = i; jm = j;
+				}
+			}
+		}
+		minscoref = (double)minscore * 0.5 / ( INTMTXSCALE );
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+#if 1
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+#else
+		intpt = topol[k][0];
+        for( i=0; i<nseq; i++ )
+            if( pair[im][i] > -2 )
+				*intpt++ = i;
+		*intpt = -1;
+
+		intpt = topol[k][1];
+        for( i=0; i<nseq; i++ )
+            if( pair[jm][i] > -2 )
+				*intpt++ = i;
+		*intpt = -1;
+#endif
+
+		len[k][0] = minscoref - tmptmplen[im];
+		len[k][1] = minscoref - tmptmplen[jm];
+
+		tmptmplen[im] = minscoref;
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+#if 1
+	FreeIntMtx( eff ); eff = NULL;
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+#endif
+}
+void veryfastsupg_int( int nseq, int **oeff, int ***topol, double **len )
+/* len$B$O!"(B oeff$B$, at 0?t!#(Blen$B$b<B$O at 0?t!#(B
+   $BI,MW$K1~$8$F3d$C$F;H$&!#(B */
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+	int *intpt, *intpt2;
+	int tmpint;
+	int eff1, eff0;
+	static int *tmptmplen = NULL;
+	static int **eff = NULL;
+    static int *hist = NULL;
+	static Achain *ac = NULL;
+	int minscore;
+	int im = -1, jm = -1;
+	int prevnode, acjmnext, acjmprev;
+	int *pt1, *pt2, *pt11, *pt22;
+
+
+	if( !eff )
+	{
+		eff = AllocateIntMtx( njob, njob );
+		hist = AllocateIntVec( njob );
+		tmptmplen = AllocateIntVec( njob );
+		ac = (Achain *)malloc( njob * sizeof( Achain ) );
+	}
+	
+	for( i=0; i<nseq; i++ ) 
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			eff[i][j] = ( oeff[i][j] );
+		}
+	}
+
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmptmplen[i] = 0;
+    for( i=0; i<nseq; i++ ) hist[i] = -1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+		minscore = INTMTXSCALE*4;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+	        {
+				tmpint = eff[i][j];
+				if( tmpint < minscore )
+				{
+					minscore = tmpint;
+					im = i; jm = j;
+				}
+			}
+		}
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+		prevnode = hist[im];
+		if( prevnode == -1 )
+		{
+			*intpt++ = im;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		intpt = topol[k][1];
+		prevnode = hist[jm];
+		if( prevnode == -1 )
+		{
+			*intpt++ = jm;
+			*intpt = -1;
+		}
+		else
+		{
+			pt1 = topol[prevnode][0];
+			pt2 = topol[prevnode][1];
+			if( *pt1 > *pt2 )
+			{
+				pt11 = pt2;
+				pt22 = pt1;
+			}
+			else
+			{
+				pt11 = pt1;
+				pt22 = pt2;
+			}
+			for( intpt2=pt11; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			for( intpt2=pt22; *intpt2!=-1; )
+				*intpt++ = *intpt2++;
+			*intpt = -1;
+		}
+
+		minscore *= 0.5;
+
+		len[k][0] = (double)( minscore - tmptmplen[im] );
+		len[k][1] = (double)( minscore - tmptmplen[jm] );
+
+		tmptmplen[im] = minscore;
+
+#if 0
+		free( tmptmplen );
+		tmptmplen = AllocateIntVec( nseq );
+#endif
+
+
+		hist[im] = k;
+
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+				(int) ( (float)MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) + (float)( eff0 + eff1 ) * 0.5 * SUEFF );
+            }
+        }
+		acjmprev = ac[jm].prev; 
+		acjmnext = ac[jm].next; 
+		ac[acjmprev].next = acjmnext;
+		if( acjmnext != -1 )
+			ac[acjmnext].prev = acjmprev;
+#if 0
+        fprintf( stdout, "STEP-%03d:\n", k+1 );
+		fprintf( stdout, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][0][i] );
+        fprintf( stdout, "\n" );
+		fprintf( stdout, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stdout, " %03d", topol[k][1][i] );
+        fprintf( stdout, "\n" );
+#endif
+    }
+	FreeIntMtx( eff ); eff = NULL;
+	free( (void *)tmptmplen ); tmptmplen = NULL;
+	free( hist ); hist = NULL;
+	free( (char *)ac ); ac = NULL;
+}
+void fastsupg( int nseq, double **oeff, int ***topol, double **len )
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+#if 0
+	double eff[nseq][nseq];
+    char pair[njob][njob];
+#else
+	static float *tmplen;
+	int *intpt;
+	float tmpfloat;
+	float eff1, eff0;
+	static float **eff = NULL;
+    static char **pair = NULL;
+	static Achain *ac;
+	float minscore;
+	int im = -1, jm = -1;
+	if( !eff )
+	{
+		eff = AllocateFloatMtx( njob, njob );
+		pair = AllocateCharMtx( njob, njob );
+		tmplen = AllocateFloatVec( njob );
+		ac = (Achain *)calloc( njob, sizeof( Achain ) );
+	}
+#endif
+	
+	for( i=0; i<nseq; i++ ) 
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			eff[i][j] = (float)oeff[i][j];
+		}
+	}
+
+	for( i=0; i<nseq; i++ )
+	{
+		ac[i].next = i+1;
+		ac[i].prev = i-1;
+//		ac[i].curr = i;
+	}
+	ac[nseq-1].next = -1;
+
+	for( i=0; i<nseq; i++ ) tmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) pair[i][j] = 0;
+    for( i=0; i<nseq; i++ ) pair[i][i] = 1;
+
+	fprintf( stderr, "\n" );
+    for( k=0; k<nseq-1; k++ )
+    {
+		if( k % 10 == 0 ) fprintf( stderr, "%d / %d\r", k, nseq );
+
+		minscore = 9999.0;
+		for( i=0; ac[i].next!=-1; i=ac[i].next ) 
+//		for( i=0; i<nseq-1; i++ ) 
+		{
+			for( j=ac[i].next; j!=-1; j=ac[j].next )
+//			for( j=i+1; j<nseq; j++ ) 
+	        {
+				tmpfloat = eff[i][j];
+				if( tmpfloat < minscore )
+				{
+					minscore = tmpfloat;
+					im = i; jm = j;
+				}
+			}
+		}
+
+//		fprintf( stderr, "im=%d, jm=%d\n", im, jm );
+
+		intpt = topol[k][0];
+        for( i=0; i<nseq; i++ )
+            if( pair[im][i] > 0 )
+				*intpt++ = i;
+		*intpt = -1;
+
+		intpt = topol[k][1];
+        for( i=0; i<nseq; i++ )
+            if( pair[jm][i] > 0 )
+				*intpt++ = i;
+		*intpt = -1;
+
+		minscore /= 2.0;
+
+		len[k][0] = (double)minscore - tmplen[im];
+		len[k][1] = (double)minscore - tmplen[jm];
+
+		tmplen[im] = (double)minscore;
+
+        for( i=0; i<nseq; i++ ) pair[im][i] += ( pair[jm][i] > 0 );
+        for( i=0; i<nseq; i++ ) pair[jm][i] = 0;
+
+//		for( i=0; i<nseq; i++ )
+		for( i=0; i!=-1; i=ac[i].next )
+        {
+            if( i != im && i != jm )
+            {
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+//        		eff[minijm][maxijm] = 9999.0;
+            }
+        }
+		ac[ac[jm].prev].next = ac[jm].next;
+		ac[ac[jm].next].prev = ac[jm].prev;
+//		eff[im][jm] = 9999.0;
+#if 0
+        fprintf( stderr, "STEP-%03d:\n", k+1 );
+		fprintf( stderr, "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) fprintf( stderr, " %03d", topol[k][0][i] );
+        fprintf( stderr, "\n" );
+		fprintf( stderr, "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) fprintf( stderr, " %03d", topol[k][1][i] );
+        fprintf( stderr, "\n" );
+#endif
+    }
+	fprintf( stderr, "\n" );
+
+//	FreeFloatMtx( eff );
+//	FreeCharMtx( pair );
+//	FreeFloatVec( tmplen );
+//	free( ac );
+}
+void supg( int nseq, double **oeff, int ***topol, double **len )
+{
+    int i, j, k, miniim, maxiim, minijm, maxijm;
+#if 0
+	double eff[nseq][nseq];
+    char pair[njob][njob];
+#else
+	static float *tmplen;
+	int *intpt;
+	float **floatptpt;
+	float *floatpt;
+	float tmpfloat;
+	float eff1, eff0;
+	static float **eff = NULL;
+    static char **pair = NULL;
+	if( !eff )
+	{
+		eff = AllocateFloatMtx( njob, njob );
+		pair = AllocateCharMtx( njob, njob );
+		tmplen = AllocateFloatVec( njob );
+	}
+#endif
+
+	
+	for( i=0; i<nseq; i++ ) 
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			eff[i][j] = (float)oeff[i][j];
+		}
+	}
+	for( i=0; i<nseq; i++ ) tmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) pair[i][j] = 0;
+    for( i=0; i<nseq; i++ ) pair[i][i] = 1;
+
+    for( k=0; k<nseq-1; k++ )
+    {
+        float minscore = 9999.0;
+        int im = -1, jm = -1;
+
+
+		floatptpt = eff;
+        for( i=0; i<nseq-1; i++ ) 
+		{
+			floatpt = *floatptpt++ + i + 1;
+			for( j=i+1; j<nseq; j++ )
+	        {
+				tmpfloat = *floatpt++;
+				if( tmpfloat < minscore )
+				{
+					minscore = tmpfloat;
+					im = i; jm = j;
+				}
+			}
+		}
+		intpt = topol[k][0];
+        for( i=0; i<nseq; i++ )
+            if( pair[im][i] > 0 )
+				*intpt++ = i;
+		*intpt = -1;
+
+		intpt = topol[k][1];
+        for( i=0; i<nseq; i++ )
+            if( pair[jm][i] > 0 )
+				*intpt++ = i;
+		*intpt = -1;
+
+		len[k][0] = (double)minscore / 2.0 - tmplen[im];
+		len[k][1] = (double)minscore / 2.0 - tmplen[jm];
+
+		tmplen[im] = (double)minscore / 2.0;
+
+        for( i=0; i<nseq; i++ ) pair[im][i] += ( pair[jm][i] > 0 );
+        for( i=0; i<nseq; i++ ) pair[jm][i] = 0;
+
+        for( i=0; i<nseq; i++ )
+        {
+            if( i != im && i != jm )
+            {
+#if 1
+				if( i < im )
+				{
+					 miniim = i;
+					 maxiim = im;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else if( i < jm )
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = i;
+					 maxijm = jm;
+				}
+				else
+				{
+					 miniim = im;
+					 maxiim = i;
+					 minijm = jm;
+					 maxijm = i;
+				}
+#else
+				miniim = MIN( i, im );
+				maxiim = MAX( i, im );
+				minijm = MIN( i, jm );
+				maxijm = MAX( i, jm );
+#endif
+#if 1
+				eff0 = eff[miniim][maxiim];
+				eff1 = eff[minijm][maxijm];
+                eff[miniim][maxiim] =
+                MIN( eff0, eff1 ) * ( 1.0 - SUEFF ) +
+				( eff0 + eff1 ) * 0.5 * SUEFF;
+#else
+                MIN( eff[miniim][maxiim], eff[minijm][maxijm] ) * ( 1.0 - SUEFF ) +
+				( eff[miniim][maxiim] + eff[minijm][maxijm] ) * 0.5 * SUEFF;
+#endif
+                eff[minijm][maxijm] = 9999.0;
+            	eff[im][jm] = 9999.0;
+            }
+        }
+#if DEBUG
+        printf( "STEP-%03d:\n", k+1 );
+		printf( "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) printf( " %03d", topol[k][0][i] );
+        printf( "\n" );
+		printf( "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) printf( " %03d", topol[k][1][i] );
+        printf( "\n" );
+#endif
+    }
+}
+
+void spg( int nseq, double **oeff, int ***topol, double **len )
+{
+    int i, j, k;
+	double tmplen[M];
+#if 0
+	double eff[nseq][nseq];
+    char pair[njob][njob];
+#else
+	double **eff = NULL;
+    char **pair = NULL;
+	if( !eff )
+	{
+		eff = AllocateDoubleMtx( njob, njob );
+		pair = AllocateCharMtx( njob, njob );
+	}
+#endif
+	
+	for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) eff[i][j] = oeff[i][j];
+	for( i=0; i<nseq; i++ ) tmplen[i] = 0.0;
+    for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) pair[i][j] = 0;
+    for( i=0; i<nseq; i++ ) pair[i][i] = 1;
+
+    for( k=0; k<nseq-1; k++ )
+    {
+        float minscore = 9999.0;
+        int im = -1, jm = -1;
+        int count;
+
+        for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+        {
+            if( eff[i][j] < minscore )
+            {
+                minscore = eff[i][j];
+                im = i; jm = j;
+            }
+        }
+        for( i=0, count=0; i<nseq; i++ )
+            if( pair[im][i] > 0 )
+            {
+                topol[k][0][count] = i;
+                count++;
+            }
+        topol[k][0][count] = -1;
+        for( i=0, count=0; i<nseq; i++ )
+            if( pair[jm][i] > 0 )
+            {
+                topol[k][1][count] = i;
+                count++;
+            }
+        topol[k][1][count] = -1;
+
+		len[k][0] = minscore / 2.0 - tmplen[im];
+		len[k][1] = minscore / 2.0 - tmplen[jm];
+
+		tmplen[im] = minscore / 2.0;
+
+        for( i=0; i<nseq; i++ ) pair[im][i] += ( pair[jm][i] > 0 );
+        for( i=0; i<nseq; i++ ) pair[jm][i] = 0;
+
+        for( i=0; i<nseq; i++ )
+        {
+            if( i != im && i != jm )
+            {
+                eff[MIN(i,im)][MAX(i,im)] =
+                MIN( eff[MIN(i,im)][MAX(i,im)], eff[MIN(i,jm)][MAX(i,jm)] );
+                eff[MIN(i,jm)][MAX(i,jm)] = 9999.0;
+            }
+            eff[im][jm] = 9999.0;
+        }
+#if DEBUG
+        printf( "STEP-%03d:\n", k+1 );
+		printf( "len0 = %f\n", len[k][0] );
+        for( i=0; topol[k][0][i]>-1; i++ ) printf( " %03d", topol[k][0][i] );
+        printf( "\n" );
+		printf( "len1 = %f\n", len[k][1] );
+        for( i=0; topol[k][1][i]>-1; i++ ) printf( " %03d", topol[k][1][i] );
+        printf( "\n" );
+#endif
+    }
+}
+
+double ipower( double x, int n )    /* n > 0  */
+{
+    double r;
+
+    r = 1;
+    while( n != 0 )
+    {
+        if( n & 1 ) r *= x;
+        x *= x; n >>= 1;
+    }
+    return( r );
+}
+
+void countnode( int nseq, int ***topol, double **node ) /* node[j][i] != node[i][j] */
+{
+    int i, j, k, s1, s2;
+    static double rootnode[M];
+
+    if( nseq-2 < 0 )
+	{
+		fprintf( stderr, "Too few sequence for countnode: nseq = %d\n", nseq );
+		exit( 1 );
+    }
+
+    for( i=0; i<nseq; i++ ) rootnode[i] = 0;
+    for( i=0; i<nseq-2; i++ )
+    {
+        for( j=0; topol[i][0][j]>-1; j++ )
+            rootnode[topol[i][0][j]]++;
+        for( j=0; topol[i][1][j]>-1; j++ )
+            rootnode[topol[i][1][j]]++;
+        for( j=0; topol[i][0][j]>-1; j++ )
+        {
+            s1 = topol[i][0][j];
+            for( k=0; topol[i][1][k]>-1; k++ )
+            {
+                s2 = topol[i][1][k];
+                node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2] - 1;
+            }
+        }
+    }
+    for( j=0; topol[nseq-2][0][j]>-1; j++ )
+    {
+        s1 = topol[nseq-2][0][j];
+        for( k=0; topol[nseq-2][1][k]>-1; k++ )
+        {
+            s2 = topol[nseq-2][1][k];
+            node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2];
+        }
+    }
+}
+
+void countnode_int( int nseq, int ***topol, int **node )  /* node[i][j] == node[j][i] */
+{
+    int i, j, k, s1, s2;
+    int rootnode[M];
+
+    for( i=0; i<nseq; i++ ) rootnode[i] = 0;
+    for( i=0; i<nseq-2; i++ )
+    {
+        for( j=0; topol[i][0][j]>-1; j++ )
+            rootnode[topol[i][0][j]]++;
+        for( j=0; topol[i][1][j]>-1; j++ )
+            rootnode[topol[i][1][j]]++;
+        for( j=0; topol[i][0][j]>-1; j++ )
+        {
+            s1 = topol[i][0][j];
+            for( k=0; topol[i][1][k]>-1; k++ )
+            {
+                s2 = topol[i][1][k];
+                node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2] - 1;
+            }
+        }
+    }
+    for( j=0; topol[nseq-2][0][j]>-1; j++ )
+    {
+        s1 = topol[nseq-2][0][j];
+        for( k=0; topol[nseq-2][1][k]>-1; k++ )
+        {
+            s2 = topol[nseq-2][1][k];
+            node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2];
+        }
+    }
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ ) 
+		node[j][i] = node[i][j];
+#if DEBUG
+	fprintf( stderr, "node[][] in countnode_int" );
+	for( i=0; i<nseq; i++ ) 
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			fprintf( stderr, "%#3d", node[i][j] );
+		}
+		fprintf( stderr, "\n" );
+	}
+#endif
+}
+
+void counteff_simple_float( int nseq, int ***topol, float **len, double *node )
+{
+    int i, j, s1, s2;
+	double total;
+	static double rootnode[M];
+	static double eff[M];
+
+#if DEBUG
+	for( i=0; i<nseq; i++ ){
+		fprintf( stderr, "len0 = %f\n", len[i][0] );
+		fprintf( stderr, "len1 = %f\n", len[i][1] );
+	}
+#endif
+    for( i=0; i<nseq; i++ )
+	{
+		rootnode[i] = 0.0;
+		eff[i] = 1.0;
+/*
+		rootnode[i] = 1.0;
+*/
+	}
+   	for( i=0; i<nseq-1; i++ )
+   	{
+       	for( j=0; (s1=topol[i][0][j]) > -1; j++ )
+		{
+           	rootnode[s1] += (double)len[i][0] * eff[s1];
+			eff[s1] *= 0.5;
+/*
+           	rootnode[s1] *= 0.5;
+*/
+			
+		}
+       	for( j=0; (s2=topol[i][1][j]) > -1; j++ )
+		{
+           	rootnode[s2] +=  (double)len[i][1] * eff[s2];
+			eff[s2] *= 0.5;
+/*
+           	rootnode[s2] *= 0.5;
+*/
+				
+		}
+	}
+	for( i=0; i<nseq; i++ ) 
+	{
+#if 1 /* 97.9.29 */
+		rootnode[i] += GETA3;
+#endif
+#if 0
+		fprintf( stderr, "### rootnode for %d = %f\n", i, rootnode[i] );
+#endif
+	}
+#if 1
+	total = 0.0;
+	for( i=0; i<nseq; i++ ) 
+	{
+		total += rootnode[i];
+	}
+#else
+	total = 1.0;
+#endif
+		
+	for( i=0; i<nseq; i++ ) 
+	{
+		node[i] = rootnode[i] / total;
+	}
+
+#if 0
+	fprintf( stderr, "weight array in counteff_simple\n" );
+	for( i=0; i<nseq; i++ )
+		fprintf( stderr, "%f\n", node[i] );
+	printf( "\n" );
+	exit( 1 );
+#endif
+}
+
+void counteff_simple( int nseq, int ***topol, double **len, double *node )
+{
+    int i, j, s1, s2;
+	double total;
+	static double rootnode[M];
+	static double eff[M];
+
+#if DEBUG
+	for( i=0; i<nseq; i++ ){
+		fprintf( stderr, "len0 = %f\n", len[i][0] );
+		fprintf( stderr, "len1 = %f\n", len[i][1] );
+	}
+#endif
+    for( i=0; i<nseq; i++ )
+	{
+		rootnode[i] = 0.0;
+		eff[i] = 1.0;
+/*
+		rootnode[i] = 1.0;
+*/
+	}
+   	for( i=0; i<nseq-1; i++ )
+   	{
+       	for( j=0; (s1=topol[i][0][j]) > -1; j++ )
+		{
+           	rootnode[s1] += len[i][0] * eff[s1];
+			eff[s1] *= 0.5;
+/*
+           	rootnode[s1] *= 0.5;
+*/
+			
+		}
+       	for( j=0; (s2=topol[i][1][j]) > -1; j++ )
+		{
+           	rootnode[s2] +=  len[i][1] * eff[s2];
+			eff[s2] *= 0.5;
+/*
+           	rootnode[s2] *= 0.5;
+*/
+				
+		}
+	}
+	for( i=0; i<nseq; i++ ) 
+	{
+#if 1 /* 97.9.29 */
+		rootnode[i] += GETA3;
+#endif
+#if 0
+		fprintf( stderr, "### rootnode for %d = %f\n", i, rootnode[i] );
+#endif
+	}
+#if 1
+	total = 0.0;
+	for( i=0; i<nseq; i++ ) 
+	{
+		total += rootnode[i];
+	}
+#else
+	total = 1.0;
+#endif
+		
+	for( i=0; i<nseq; i++ ) 
+	{
+		node[i] = rootnode[i] / total;
+	}
+
+#if 0
+	fprintf( stderr, "weight array in counteff_simple\n" );
+	for( i=0; i<nseq; i++ )
+		fprintf( stderr, "%f\n", node[i] );
+	printf( "\n" );
+	exit( 1 );
+#endif
+}
+
+
+void counteff( int nseq, int ***topol, double **len, double **node )
+{
+    int i, j, k, s1, s2;
+	double rootnode[M];
+	double eff[M];
+
+	if( mix ) 
+	{
+		switch( weight )
+		{
+			case( 2 ): 
+				weight = 3;
+				break;
+			case( 3 ): 
+				weight = 2;
+				break;
+			default: 
+				ErrorExit( "mix error" );
+				break;
+		}
+	}
+
+	if( weight == 2 )
+	{
+	    for( i=0; i<nseq; i++ ) rootnode[i] = 0;
+    	for( i=0; i<nseq-2; i++ )
+    	{
+        	for( j=0; topol[i][0][j]>-1; j++ )
+            	rootnode[topol[i][0][j]]++;
+        	for( j=0; topol[i][1][j]>-1; j++ )
+            	rootnode[topol[i][1][j]]++;
+        	for( j=0; topol[i][0][j]>-1; j++ )
+        	{
+            	s1 = topol[i][0][j];
+            	for( k=0; topol[i][1][k]>-1; k++ )
+            	{
+                	s2 = topol[i][1][k];
+                	node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2] - 1;
+            	}
+        	}
+    	}
+    	for( j=0; topol[nseq-2][0][j]>-1; j++ )
+    	{
+        	s1 = topol[nseq-2][0][j];
+        	for( k=0; topol[nseq-2][1][k]>-1; k++ )
+        	{
+            	s2 = topol[nseq-2][1][k];
+            	node[MIN(s1,s2)][MAX(s1,s2)] = rootnode[s1] + rootnode[s2];
+        	}
+    	}
+   		for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+   	   		node[i][j] = ipower( 0.5, (int)node[i][j] ) + geta2;
+		for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ ) 
+			node[j][i] = node[i][j];
+	}
+
+	if( weight == 3 )
+	{
+#if DEBUG
+		for( i=0; i<nseq; i++ ){
+			fprintf( stderr, "len0 = %f\n", len[i][0] );
+			fprintf( stderr, "len1 = %f\n", len[i][1] );
+		}
+#endif
+	    for( i=0; i<nseq; i++ )
+		{
+			rootnode[i] = 0.0;
+			eff[i] = 1.0;
+/*
+			rootnode[i] = 1.0;
+*/
+		}
+    	for( i=0; i<nseq-1; i++ )
+    	{
+        	for( j=0; (s1=topol[i][0][j]) > -1; j++ )
+			{
+   	        	rootnode[s1] += len[i][0] * eff[s1];
+				eff[s1] *= 0.5;
+/*
+   	        	rootnode[s1] *= 0.5;
+*/
+				
+			}
+   	    	for( j=0; (s2=topol[i][1][j]) > -1; j++ )
+			{
+   	        	rootnode[s2] +=  len[i][1] * eff[s2];
+				eff[s2] *= 0.5;
+/*
+   	        	rootnode[s2] *= 0.5;
+*/
+				
+			}
+		}
+		for( i=0; i<nseq; i++ ) 
+		{
+#if 1 /* 97.9.29 */
+			rootnode[i] += GETA3;
+#endif
+#if DEBUG
+			fprintf( stderr, "rootnode for %d = %f\n", i, rootnode[i] );
+#endif
+		}
+		for( i=0; i<nseq; i++ ) 
+		{
+			for( j=0; j<nseq; j++ ) 
+				if( j != i )
+					node[i][j] = (double)rootnode[i] * rootnode[j];
+				else node[i][i] = rootnode[i];
+		}
+	}
+
+#if 0
+	printf( "weight matrix in counteff\n" );
+	for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<nseq; j++ ) 
+		{
+			printf( "%f ", node[i][j] );
+		}
+		printf( "\n" );
+	}
+#endif
+}
+
+float score_calcp( char *seq1, char *seq2, int len )
+{
+	int k;
+	int ms1, ms2;
+	float tmpscore;
+	int len2 = len - 2;
+
+	tmpscore = 0.0;
+	for( k=0; k<len; k++ )
+	{
+		ms1 = (int)seq1[k];
+		ms2 = (int)seq2[k];
+		if( ms1 == (int)'-' && ms2 == (int)'-' ) continue;
+		tmpscore += (float)amino_dis[ms1][ms2];
+	
+		if( ms1 == (int)'-' ) 
+		{
+			tmpscore += (float)penalty;
+			tmpscore += (float)amino_dis[ms1][ms2];
+			while( (ms1=(int)seq1[++k]) == (int)'-' )
+				tmpscore += (float)amino_dis[ms1][ms2];
+			k--;
+			if( k >len2 ) break;
+			continue;
+		}
+		if( ms2 == (int)'-' )
+		{
+			tmpscore += (float)penalty;
+			tmpscore += (float)amino_dis[ms1][ms2];
+			while( (ms2=(int)seq2[++k]) == (int)'-' )
+				tmpscore += (float)amino_dis[ms1][ms2];
+			k--;
+			if( k > len2 ) break;
+			continue;
+		}
+	}
+	return( tmpscore );
+}
+
+float score_calc1( char *seq1, char *seq2 )   /* method 1 */
+{
+	int k;
+	float score = 0.0;
+	int count = 0;
+	int len = strlen( seq1 );
+
+	for( k=0; k<len; k++ )
+	{	
+		if( seq1[k] != '-' && seq2[k] != '-' )
+		{
+			score += (float)amino_dis[(int)seq1[k]][(int)seq2[k]];
+			count++;
+		}
+	}
+	if( count ) score /= (float)count;
+	else score = 1.0;
+	return( score );
+}
+
+float substitution_nid( char *seq1, char *seq2 )
+{
+	int k;
+	float s12;
+	int len = strlen( seq1 );
+	
+	s12 = 0.0;
+	for( k=0; k<len; k++ )
+		if( seq1[k] != '-' && seq2[k] != '-' )
+			s12 += ( seq1[k] == seq2[k] );
+
+//	fprintf( stdout, "s12 = %f\n", s12 );
+	return( s12 );
+}
+
+float substitution_score( char *seq1, char *seq2 )
+{
+	int k;
+	float s12;
+	int len = strlen( seq1 );
+	
+	s12 = 0.0;
+	for( k=0; k<len; k++ )
+		if( seq1[k] != '-' && seq2[k] != '-' )
+			s12 += amino_dis[(int)seq1[k]][(int)seq2[k]];
+
+//	fprintf( stdout, "s12 = %f\n", s12 );
+	return( s12 );
+}
+
+float substitution_hosei( char *seq1, char *seq2 )   /* method 1 */
+#if 0
+{
+	int k;
+	float score = 0.0;
+	int count = 0;
+	int len = strlen( seq1 );
+
+	for( k=0; k<len; k++ )
+	{	
+		if( seq1[k] != '-' && seq2[k] != '-' )
+		{
+			score += (float)( seq1[k] != seq2[k] );
+			count++;
+		}
+	}
+	if( count ) score /= (float)count;
+	else score = 1.0;
+	if( score < 0.95 ) score = - log( 1.0 - score );
+	else score = 3.0;
+	return( score );
+}
+#else
+{
+	int count = 0;
+	float score;
+	int iscore = 0;
+	char s1, s2;
+
+	while( (s1=*seq1++) )
+	{
+		s2 = *seq2++;
+		if( s1 == '-' ) continue;
+		if( s2 == '-' ) continue;
+		iscore += ( s1 != s2 );
+		count++;
+	}
+	if( count ) score = (float)iscore / count;
+	else score = 1.0;
+	if( score < 0.95 ) score = - log( 1.0 - score );
+	else score = 3.0;
+	return( score );
+}
+#endif
+
+float substitution( char *seq1, char *seq2 )   /* method 1 */
+{
+	int k;
+	float score = 0.0;
+	int count = 0;
+	int len = strlen( seq1 );
+
+	for( k=0; k<len; k++ )
+	{	
+		if( seq1[k] != '-' && seq2[k] != '-' )
+		{
+			score += (float)( seq1[k] != seq2[k] );
+			count++;
+		}
+	}
+	if( count ) score /= (float)count;
+	else score = 1.0;
+	return( score );
+}
+
+
+void treeconstruction( char **seq, int nseq, int ***topol, double **len, double **eff )
+{
+    int i, j;
+
+	if( weight > 1 )
+	{
+		if( utree == 0 )
+		{
+	    	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+   		 	{
+/*
+		       	 eff[i][j] = (double)score_calc1( seq[i], seq[j] );
+*/
+		       	 eff[i][j] = (double)substitution_hosei( seq[i], seq[j] );
+ /*
+				 fprintf( stderr, "%f\n", eff[i][j] );
+ */
+   		 	}
+/*
+			fprintf( stderr, "distance matrix\n" );
+			for( i=0; i<nseq; i++ )
+			{
+				for( j=0; j<nseq; j++ ) 
+				{
+					fprintf( stderr, "%f ", eff[i][j] );
+				}
+				fprintf( stderr, "\n" );
+			}
+*/
+/*
+   			upg( nseq, eff, topol, len );
+   			upg2( nseq, eff, topol, len );
+*/
+   			spg( nseq, eff, topol, len );
+   			counteff( nseq, topol, len, eff );
+		}
+	}
+	else
+	{
+		for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ ) 
+			eff[i][j] = 1.0;
+	}
+/*
+fprintf( stderr, "weight matrix\n" );
+for( i=0; i<nseq; i++ )
+{
+	for( j=0; j<nseq; j++ ) 
+	{
+		fprintf( stderr, "%f ", eff[i][j] );
+	}
+	fprintf( stderr, "\n" );
+}
+*/
+}
+
+float bscore_calc( char **seq, int s, double **eff )  /* algorithm B */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    long score;
+
+	score = 0;
+	nglen = 0;
+	for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ )
+	{
+		double efficient = eff[i][j];
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 + !gb1  * !gc1 
+                 * !gb2  *  gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+				 + gb1   * !gc1
+				 * gb2   *  gc2      *BEFF
+
+				 + gb1   *  gc1
+				 * gb2   * !gc2      *BEFF
+                 ;
+			score += (long)cob * penalty * efficient;
+			score += (long)amino_dis[(int)seq[i][k]][(int)seq[j][k]] * efficient;
+			nglen += ( !gc1 * !gc2 );
+		}
+	}
+	return( (float)score / nglen + 400.0 * !scoremtx );
+}
+
+void AllocateTmpSeqs( char ***mseq2pt, char **mseq1pt, int locnlenmax )
+{
+	*mseq2pt = AllocateCharMtx( njob, locnlenmax+1 );
+	*mseq1pt = AllocateCharVec( locnlenmax+1 );
+}
+
+void FreeTmpSeqs( char **mseq2, char *mseq1 )
+{
+	FreeCharMtx( mseq2 );
+	free( (char *)mseq1 );
+}
+
+void gappick0( char *aseq, char *seq )
+{
+	for( ; *seq != 0; seq++ )
+	{
+		if( *seq != '-' )
+			*aseq++ = *seq;
+	}
+	*aseq = 0;
+
+}
+
+void gappick( int nseq, int s, char **aseq, char **mseq2, 
+			  double **eff, double *effarr )
+{
+	int i, j, count, countjob, len, allgap;
+	len = strlen( aseq[0] );
+	for( i=0, count=0; i<len; i++ ) 
+	{
+		allgap = 1;
+		for( j=0; j<nseq; j++ ) if( j != s ) allgap *= ( aseq[j][i] == '-' );
+        if( allgap == 0 )
+		{
+			for( j=0, countjob=0; j<nseq; j++ ) 
+			{
+				if( j != s )
+				{
+					mseq2[countjob][count] = aseq[j][i];
+					countjob++;
+				}
+			}
+			count++;
+		}
+	}
+	for( i=0; i<nseq-1; i++ ) mseq2[i][count] = 0;
+
+	for( i=0, countjob=0; i<nseq; i++ ) 
+	{
+		if( i != s )
+		{
+			effarr[countjob] = eff[s][i];
+			countjob++;
+		}
+	}
+/*
+fprintf( stdout, "effarr in gappick s = %d\n", s+1 );
+for( i=0; i<countjob; i++ ) 
+	fprintf( stdout, " %f", effarr[i] );
+printf( "\n" );
+*/
+}
+
+void commongappick_record( int nseq, char **seq, int *map )
+{
+	int i, j, count;
+	int len = strlen( seq[0] );
+
+
+	for( i=0, count=0; i<=len; i++ ) 
+	{
+	/*
+		allgap = 1;
+		for( j=0; j<nseq; j++ ) 
+			allgap *= ( seq[j][i] == '-' );
+		if( !allgap )
+	*/
+		for( j=0; j<nseq; j++ )
+			if( seq[j][i] != '-' ) break;
+		if( j != nseq )
+		{
+			for( j=0; j<nseq; j++ )
+			{
+				seq[j][count] = seq[j][i];
+			}
+			map[count] = i;
+			count++;
+	 	}
+	}
+}
+
+void commongappick( int nseq, char **seq )
+{
+	int i, j, count;
+	int len = strlen( seq[0] );
+
+	for( i=0, count=0; i<=len; i++ ) 
+	{
+	/*
+		allgap = 1;
+		for( j=0; j<nseq; j++ ) 
+			allgap *= ( seq[j][i] == '-' );
+		if( !allgap )
+	*/
+		for( j=0; j<nseq; j++ )
+			if( seq[j][i] != '-' ) break;
+		if( j != nseq )
+		{
+			for( j=0; j<nseq; j++ )
+			{
+				seq[j][count] = seq[j][i];
+			}
+			count++;
+	 	}
+	}
+}
+		
+double score_calc0( char **seq, int s, double **eff, int ex )
+{
+	double tmp;
+
+	if( scmtd == 3 ) tmp = score_calc3( seq, s, eff, ex );
+	if( scmtd == 4 ) tmp = score_calc4( seq, s, eff, ex );
+	if( scmtd == 5 ) tmp = score_calc5( seq, s, eff, ex );
+	else             tmp = score_calc5( seq, s, eff, ex );
+
+	return( tmp );
+
+}
+
+/*
+float score_m_1( char **seq, int ex, double **eff )
+{
+	int i, j, k;
+	int len = strlen( seq[0] );
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+	double score;
+
+	score = 0.0;
+	nglen = 0;
+	for( i=0; i<njob; i++ ) 
+	{
+		double efficient = eff[MIN(i,ex)][MAX(i,ex)];
+		if( i == ex ) continue;
+
+		gc1 = 0; 
+		gc2 = 0;
+		for( k=0; k<len; k++ ) 
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[ex][k] == '-' );
+      
+            cob = 
+                   !gb1  *  gc1
+                 * !gb2  * !gc2
+
+                 + !gb1  * !gc1
+                 * !gb2  *  gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+                 +  gb1  * !gc1
+                 *  gb2  *  gc2      *BEFF
+
+                 +  gb1  *  gc1
+                 *  gb2  * !gc2      *BEFF
+                 ;
+			score += (double)cob * penalty * efficient;
+			score += (double)amino_dis[seq[i][k]][seq[ex][k]] * efficient;
+			*
+			nglen += ( !gc1 * !gc2 );
+			*
+			if( !gc1 && !gc2 ) fprintf( stdout, "%f\n", score );
+		}
+	}
+	return( (float)score / nglen + 400.0 * !scoremtx );
+}
+*/
+
+#if 0
+void sitescore( char **seq, double **eff, char sco1[], char sco2[], char sco3[] )
+{
+	int i, j, k;
+	int len = strlen( seq[0] );
+	double tmp;
+	double count;
+	int ch;
+	double sco[N];
+
+	for( i=0; i<len; i++ ) 
+	{
+		tmp = 0.0; count = 0;
+		for( j=0; j<njob-1; j++ ) for( k=j+1; k<njob; k++ ) 
+		{
+		/*
+			if( seq[j][i] != '-' && seq[k][i] != '-' )
+		*/
+			{
+				tmp += amino_dis[seq[j][i]][seq[k][i]] + 400 * !scoremtx;
+				count++; 
+			}
+		}
+		if( count > 0.0 ) tmp /= count;
+		else( tmp = 0.0 );
+		ch = (int)( tmp/100.0 - 0.000001 );
+		sprintf( sco1+i, "%c", ch+0x61 );
+	}
+	sco1[len] = 0;
+
+    for( i=0; i<len; i++ ) 
+    {
+        tmp = 0.0; count = 0;
+        for( j=0; j<njob-1; j++ ) for( k=j+1; k<njob; k++ ) 
+        {
+		/*
+            if( seq[j][i] != '-' && seq[k][i] != '-' )
+		*/
+            {
+                tmp += eff[j][k] * ( amino_dis[seq[j][i]][seq[k][i]] + 400 * !scoremtx );
+                count += eff[j][k]; 
+            }
+        }
+		if( count > 0.0 ) tmp /= count;
+		else( tmp = 0.0 );
+		tmp = ( tmp - 400 * !scoremtx ) * 2;
+		if( tmp < 0 ) tmp = 0;
+        ch = (int)( tmp/100.0 - 0.000001 );
+        sprintf( sco2+i, "%c", ch+0x61 );
+		sco[i] = tmp;
+    }
+    sco2[len] = 0;
+
+	for( i=WIN; i<len-WIN; i++ )
+	{
+		tmp = 0.0;
+		for( j=i-WIN; j<=i+WIN; j++ )
+		{
+			tmp += sco[j];
+		}
+		for( j=0; j<njob; j++ ) 
+		{
+			if( seq[j][i] == '-' )
+			{
+				tmp = 0.0;
+				break;
+			}
+		}
+		tmp /= WIN * 2 + 1;
+		ch = (int)( tmp/100.0 - 0.0000001 );
+		sprintf( sco3+i, "%c", ch+0x61 );
+	}
+	for( i=0; i<WIN; i++ ) sco3[i] = '-';
+	for( i=len-WIN; i<len; i++ ) sco3[i] = '-';
+	sco3[len] = 0;
+}
+#endif
+
+void strins( char *str1, char *str2 )
+{
+	char *bk;
+	int len1 = strlen( str1 );
+	int len2 = strlen( str2 );
+
+	bk = str2;
+	str2 += len1+len2;
+	str1 += len1-1;
+
+	while( str2 >= bk+len1 ) { *str2 = *(str2-len1); str2--;} // by D.Mathog
+	while( str2 >= bk ) { *str2-- = *str1--; }
+}
+
+int isaligned( int nseq, char **seq )
+{
+	int i;
+	int len = strlen( seq[0] );
+	for( i=1; i<nseq; i++ ) 
+	{
+		if( strlen( seq[i] ) != len ) return( 0 );
+	}
+	return( 1 );
+}
+
+double score_calc_for_score( int nseq, char **seq )
+{
+    int i, j, k, c;
+    int len = strlen( seq[0] );
+    double score;
+    double tmpscore;
+    char *mseq1, *mseq2;
+
+    score = 0.0;
+    for( i=0; i<nseq-1; i++ )
+    {
+        for( j=i+1; j<nseq; j++ )
+        {
+            mseq1 = seq[i];
+            mseq2 = seq[j];
+            tmpscore = 0.0;
+            c = 0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                c++;
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[0][24];
+                    while( mseq1[++k] == '-' )
+                        ;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty - n_dis[0][24];
+                    while( mseq2[++k] == '-' )
+                        ;
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+            score += (double)tmpscore / (double)c;
+#if DEBUG
+			printf( "tmpscore in mltaln9.c = %f\n", tmpscore );
+			printf( "tmpscore / c          = %f\n", tmpscore/(double)c );
+#endif
+        }
+    }
+	fprintf( stderr, "raw score = %f\n", score );
+	score /= (double)nseq * ( nseq-1.0 ) / 2.0;
+	score += 400.0;
+#if DEBUG
+	printf( "score in mltaln9.c = %f\n", score );
+#endif
+    return( (double)score );
+}
+
+void floatncpy( float *vec1, float *vec2, int len )
+{
+	while( len-- )
+		*vec1++ = *vec2++;
+}
+
+float score_calc_a( char **seq, int s, double **eff )  /* algorithm A+ */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    float score;
+
+	score = 0;
+	nglen = 0;
+	for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ )
+	{
+		double efficient = eff[i][j];
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 +  gb1  * !gc1 
+                 * !gb2  * !gc2
+
+	             + !gb1  * !gc1
+ 		         * !gb2  *  gc2
+
+                 + !gb1  * !gc1 
+                 *  gb2  * !gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+				 +  gb1  * !gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 *  gb2  * !gc2
+      
+				 + !gb1  *  gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 * !gb2  *  gc2
+                 ;
+			score += 0.5 * (float)cob * penalty * efficient;
+			score += (float)amino_dis[(int)seq[i][k]][(int)seq[j][k]] * (float)efficient;
+			nglen += ( !gc1 * !gc2 );
+		}
+	}
+	return( (float)score / nglen + 400.0 * !scoremtx );
+}
+
+
+float score_calc_s( char **seq, int s, double **eff )  /* algorithm S, not used */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    float score;
+
+	score = 0;
+	nglen = 0;
+	for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ )
+	{
+		double efficient = eff[i][j];
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 +  gb1  * !gc1 
+                 * !gb2  * !gc2
+
+	             + !gb1  * !gc1
+ 		         * !gb2  *  gc2
+
+                 + !gb1  * !gc1 
+                 *  gb2  * !gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+#if 0
+				 +  gb1  * !gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 *  gb2  * !gc2
+      
+				 + !gb1  *  gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 * !gb2  *  gc2
+#endif
+                 ;
+			score += 0.5 * (float)cob * penalty * efficient;
+			score += (float)amino_dis[(int)seq[i][k]][(int)seq[j][k]] * (float)efficient;
+			nglen += ( !gc1 * !gc2 );
+		}
+	}
+	return( (float)score / nglen + 400.0 );
+}
+
+double score_calc_for_score_s( int s, char **seq )  /* algorithm S */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    float score;
+
+	score = 0;
+	nglen = 0;
+	for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ )
+	{
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 +  gb1  * !gc1 
+                 * !gb2  * !gc2
+
+	             + !gb1  * !gc1
+ 		         * !gb2  *  gc2
+
+                 + !gb1  * !gc1 
+                 *  gb2  * !gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+#if 0
+				 +  gb1  * !gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 *  gb2  * !gc2
+      
+				 + !gb1  *  gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 * !gb2  *  gc2
+#endif
+                 ;
+			score += 0.5 * (float)cob * penalty;
+			score += (float)amino_dis[(int)seq[i][k]][(int)seq[j][k]];
+			nglen += ( !gc1 * !gc2 );
+		}
+#if 0
+		fprintf( stderr, "i = %d, j=%d\n", i+1, j+1 );
+		fprintf( stderr, "score = %f\n", score );
+#endif
+	}
+	return( (double)score / nglen + 400.0 );
+}
+
+double SSPscore___( int s, char **seq, int ex )  /* algorithm S */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    float score;
+
+	score = 0;
+	nglen = 0;
+	i=ex; for( j=0; j<s; j++ )
+	{
+
+		if( j == ex ) continue;
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 +  gb1  * !gc1 
+                 * !gb2  * !gc2
+
+	             + !gb1  * !gc1
+ 		         * !gb2  *  gc2
+
+                 + !gb1  * !gc1 
+                 *  gb2  * !gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2 * 2.0 
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2 * 2.0 
+      
+#if 0
+				 +  gb1  * !gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 *  gb2  * !gc2
+      
+				 + !gb1  *  gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 * !gb2  *  gc2
+#endif
+                 ;
+			score += 0.5 * (float)cob * penalty;
+			score += (float)amino_dis[(int)seq[i][k]][(int)seq[j][k]];
+			nglen += ( !gc1 * !gc2 ); /* tsukawanai */
+		}
+#if 0
+		fprintf( stderr, "i = %d, j=%d\n", i+1, j+1 );
+		fprintf( stderr, "score = %f\n", score );
+#endif
+	}
+	return( (double)score );
+}
+
+double SSPscore( int s, char **seq )  /* algorithm S */
+{
+	int i, j, k;
+	int gb1, gb2, gc1, gc2;
+	int cob;
+	int nglen;
+    int len = strlen( seq[0] );
+    float score;
+
+	score = 0;
+	nglen = 0;
+	for( i=0; i<s-1; i++ ) for( j=i+1; j<s; j++ )
+	{
+
+		gc1 = 0;
+		gc2 = 0;
+		for( k=0; k<len; k++ )
+		{
+			gb1 = gc1;
+			gb2 = gc2;
+
+			gc1 = ( seq[i][k] == '-' );
+			gc2 = ( seq[j][k] == '-' );
+			
+            cob = 
+	               !gb1  *  gc1
+ 		         * !gb2  * !gc2
+
+                 +  gb1  * !gc1 
+                 * !gb2  * !gc2
+
+	             + !gb1  * !gc1
+ 		         * !gb2  *  gc2
+
+                 + !gb1  * !gc1 
+                 *  gb2  * !gc2
+
+                 + !gb1  *  gc1
+                 *  gb2  * !gc2
+
+                 +  gb1  * !gc1
+                 * !gb2  *  gc2
+      
+#if 0
+				 +  gb1  * !gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 *  gb2  * !gc2
+      
+				 + !gb1  *  gc1
+				 *  gb2  *  gc2
+
+				 +  gb1  *  gc1
+				 * !gb2  *  gc2
+#endif
+                 ;
+			score += 0.5 * (float)cob * penalty;
+			score += (float)amino_dis[(int)seq[i][k]][(int)seq[j][k]];
+			nglen += ( !gc1 * !gc2 ); /* tsukawanai */
+		}
+#if 0
+		fprintf( stderr, "i = %d, j=%d\n", i+1, j+1 );
+		fprintf( stderr, "score = %f\n", score );
+#endif
+	}
+	return( (double)score );
+}
+
+
+
+double DSPscore( int s, char **seq )  /* method 3 deha nai */
+{
+    int i, j, k;
+    double c;
+    int len = strlen( seq[0] );
+    double score;
+    double tmpscore;
+    char *mseq1, *mseq2;
+#if DEBUG
+	FILE *fp;
+#endif
+
+    score = 0.0;
+    c = 0.0;
+
+    for( i=0; i<s-1; i++ )
+    {
+        for( j=i+1; j<s; j++ )
+        {
+            mseq1 = seq[i];
+            mseq2 = seq[j];
+            tmpscore = 0.0;
+            for( k=0; k<len; k++ )
+            {
+                if( mseq1[k] == '-' && mseq2[k] == '-' ) continue;
+                tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+
+                if( mseq1[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq1[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+                if( mseq2[k] == '-' )
+                {
+                    tmpscore += penalty;
+                    while( mseq2[++k] == '-' )
+                        tmpscore += amino_dis[(int)mseq1[k]][(int)mseq2[k]];
+                    k--;
+                    if( k > len-2 ) break;
+                    continue;
+                }
+            }
+            score += (double)tmpscore;
+        }
+    }
+
+	return( score );
+}
+
+
+#define SEGMENTSIZE 150
+
+int searchAnchors( int nseq, char **seq, Segment *seg )
+{
+	int i, j, k;
+	int status;
+	double score;
+	int value = 0;
+	int len;
+	int length;
+	static double *stra = NULL;
+	static int alloclen = 0;
+	double cumscore;
+	static double threshold;
+
+	len = strlen( seq[0] );
+	if( alloclen < len )
+	{
+		if( alloclen )
+		{
+			FreeDoubleVec( stra );
+		}
+		else
+		{
+			threshold = (int)divThreshold / 100.0 * 600.0 * divWinSize;
+		}
+		stra = AllocateDoubleVec( len );
+		alloclen = len;
+	}
+
+	for( i=0; i<len; i++ )
+	{
+#if 0
+		/* make prf */
+		for( j=0; j<26; j++ )
+		{
+			prf[j] = 0.0;
+		}
+		for( j=0; j<nseq; j++ ) prf[amino_n[seq[j][i]]] += 1.0;
+
+		/* make hat */
+		pre = 26;
+		for( j=25; j>=0; j-- )
+		{
+			if( prf[j] )
+			{
+				hat[pre] = j;
+				pre = j;
+			}
+		}
+		hat[pre] = -1;
+
+		/* make site score */
+		stra[i] = 0.0;
+		for( k=hat[26]; k!=-1; k=hat[k] ) 
+			for( j=hat[26]; j!=-1; j=hat[j] ) 
+				stra[i] += n_dis[k][j] * prf[k] * prf[j];
+#else
+		stra[i] = 0.0;
+		for( k=0; k<nseq-1; k++ ) for( j=k+1; j<nseq; j++ )
+			stra[i] += n_dis[(int)amino_n[(int)seq[k][i]]][(int)amino_n[(int)seq[j][i]]];
+		stra[i] /= (double)nseq * ( nseq-1 ) / 2;
+#endif
+	}
+
+	(seg+0)->skipForeward = 0;
+	(seg+1)->skipBackward = 0;
+	status = 0;
+	cumscore = 0.0;
+	score = 0.0;
+	length = 0; /* modified at 01/09/11 */
+	for( j=0; j<divWinSize; j++ ) score += stra[j];
+	for( i=1; i<len-divWinSize; i++ )
+	{
+		score = score - stra[i-1] + stra[i+divWinSize-1];
+#if DEBUG
+		fprintf( stderr, "%d %f   ? %f", i, score, threshold );
+		if( score > threshold ) fprintf( stderr, "YES\n" );
+		else                    fprintf( stderr, "NO\n" );
+#endif
+
+		if( score > threshold )
+		{
+			if( !status )
+			{
+				status = 1;
+				seg->start = i;
+				length = 0;
+				cumscore = 0.0;
+			}
+			length++;
+			cumscore += score;
+		}
+		if( score <= threshold || length > SEGMENTSIZE )
+		{
+			if( status )
+			{
+				seg->end = i;
+				seg->center = ( seg->start + seg->end + divWinSize ) / 2 ;
+				seg->score = cumscore;
+#if DEBUG
+				fprintf( stderr, "%d-%d length = %d\n", seg->start, seg->end, length );
+#endif
+				if( length > SEGMENTSIZE )
+				{
+					(seg+0)->skipForeward = 1;
+					(seg+1)->skipBackward = 1;
+				}
+				else
+				{
+					(seg+0)->skipForeward = 0;
+					(seg+1)->skipBackward = 0;
+				}
+				length = 0;
+				cumscore = 0.0;
+				status = 0;
+				value++;
+				seg++;
+				if( value > MAXSEG - 3 ) ErrorExit( "TOO MANY SEGMENTS!");
+			}
+		}
+	}
+	if( status )
+	{
+		seg->end = i;
+		seg->center = ( seg->start + seg->end + divWinSize ) / 2 ;
+		seg->score = cumscore;
+#if DEBUG
+fprintf( stderr, "%d-%d length = %d\n", seg->start, seg->end, length );
+#endif
+		value++;
+	}
+	return( value );
+}
+
+void dontcalcimportance( int nseq, double *eff, char **seq, LocalHom **localhom )
+{
+	int i, j;
+	LocalHom *ptr;
+	static int *nogaplen = NULL;
+
+	if( nogaplen == NULL )
+	{
+		nogaplen = AllocateIntVec( nseq );
+	}
+
+	for( i=0; i<nseq; i++ )
+	{
+		nogaplen[i] = seqlen( seq[i] );
+//		fprintf( stderr, "nogaplen[%d] = %d\n", i, nogaplen[i] );
+	}
+
+	for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<nseq; j++ )
+		{
+			for( ptr=localhom[i]+j; ptr; ptr=ptr->next )
+			{
+//				fprintf( stderr, "i,j=%d,%d,ptr=%p\n", i, j, ptr );
+#if 1
+				ptr->importance = ptr->opt / ptr->overlapaa;
+				ptr->fimportance = (float)ptr->importance;
+#else
+				ptr->importance = ptr->opt / MIN( nogaplen[i], nogaplen[j] );
+#endif
+			}
+		}
+	}
+}
+
+void calcimportance( int nseq, double *eff, char **seq, LocalHom **localhom )
+{
+	int i, j, pos, len;
+	static double *importance;
+	double tmpdouble;
+	static int *nogaplen = NULL;
+	LocalHom *tmpptr;
+
+	if( importance == NULL )
+	{
+		importance = AllocateDoubleVec( nlenmax );
+		nogaplen = AllocateIntVec( nseq );
+	}
+
+
+	for( i=0; i<nseq; i++ )
+	{
+		nogaplen[i] = seqlen( seq[i] );
+//		fprintf( stderr, "nogaplen[] = %d\n", nogaplen[i] );
+	}
+
+#if 0
+	for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ )
+	{
+		tmpptr = localhom[i]+j;
+		fprintf( stderr, "%d-%d\n", i, j );
+		do
+		{
+			fprintf( stderr, "reg1=%d-%d, reg2=%d-%d, opt=%f\n", tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->opt );
+		} while( tmpptr=tmpptr->next );
+	}
+#endif
+
+
+	for( i=0; i<nseq; i++ )
+	{
+//		fprintf( stderr, "i = %d\n", i );
+		for( pos=0; pos<nlenmax; pos++ )
+			importance[pos] = 0.0;
+		for( j=0; j<nseq; j++ )
+		{
+			if( i == j ) continue;
+			tmpptr = localhom[i]+j;
+			for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+			{
+				if( tmpptr->opt == -1 ) continue;
+				for( pos=tmpptr->start1; pos<=tmpptr->end1; pos++ )
+#if 1
+					importance[pos] += eff[j];
+#else
+					importance[pos] += eff[j] * tmpptr->opt / MIN( nogaplen[i], nogaplen[j] );
+					importance[pos] += eff[j] * tmpptr->opt / tmpptr->overlapaa;
+#endif
+			}
+		}
+#if 0
+		fprintf( stderr, "position specific importance of seq %d:\n", i );
+		for( pos=0; pos<nlenmax; pos++ )
+			fprintf( stderr, "%d: %f\n", pos, importance[pos] );
+		fprintf( stderr, "\n" );
+#endif
+		for( j=0; j<nseq; j++ )
+		{
+//			fprintf( stderr, "i=%d, j=%d\n", i, j );
+			if( i == j ) continue;
+			if( localhom[i][j].opt == -1.0 ) continue;
+#if 1
+			for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+			{
+				if( tmpptr->opt == -1.0 ) continue;
+				tmpdouble = 0.0;
+				len = 0;
+				for( pos=tmpptr->start1; pos<=tmpptr->end1; pos++ )
+				{
+					tmpdouble += importance[pos];
+					len++;
+				}
+				tmpdouble /= (double)len;
+
+				tmpptr->importance = tmpdouble * tmpptr->opt;
+				tmpptr->fimportance = (float)tmpptr->importance;
+			}
+#else
+			tmpdouble = 0.0;
+			len = 0;
+			for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+			{
+				if( tmpptr->opt == -1.0 ) continue;
+				for( pos=tmpptr->start1; pos<=tmpptr->end1; pos++ )
+				{
+					tmpdouble += importance[pos];
+					len++;
+				}
+			}
+
+			tmpdouble /= (double)len;
+
+			for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+			{
+				if( tmpptr->opt == -1.0 ) continue;
+				tmpptr->importance = tmpdouble * tmpptr->opt;
+//				tmpptr->importance = tmpptr->opt / tmpptr->overlapaa; //$B$J$+$C$?$3$H$K$9$k(B
+			}
+#endif
+
+//			fprintf( stderr, "importance of match between %d - %d = %f\n", i, j, tmpdouble );
+		}
+	}
+
+#if 0
+	fprintf( stderr, "before averaging:\n" );
+
+	for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ )
+	{
+		fprintf( stderr, "%d-%d\n", i, j );
+		for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+		{
+			fprintf( stderr, "reg1=%d-%d, reg2=%d-%d, imp=%f -> %f opt=%f\n", tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->opt / tmpptr->overlapaa, eff[i] * tmpptr->importance, tmpptr->opt );
+		}
+	}
+#endif
+
+#if 1
+//	fprintf( stderr, "average?\n" );
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+	{
+		double imp;
+		LocalHom *tmpptr1, *tmpptr2;
+
+//		fprintf( stderr, "i=%d, j=%d\n", i, j );
+
+		tmpptr1 = localhom[i]+j; tmpptr2 = localhom[j]+i;
+		for( ; tmpptr1 && tmpptr2; tmpptr1 = tmpptr1->next, tmpptr2 = tmpptr2->next)
+		{
+			if( tmpptr1->opt == -1.0 || tmpptr2->opt == -1.0 ) 
+			{
+//				fprintf( stderr, "WARNING: i=%d, j=%d, tmpptr1->opt=%f, tmpptr2->opt=%f\n", i, j, tmpptr1->opt, tmpptr2->opt );
+				continue;
+			}
+//			fprintf( stderr, "## importances = %f, %f\n", tmpptr1->importance, tmpptr2->importance );
+			imp = 0.5 * ( tmpptr1->importance + tmpptr2->importance );
+			tmpptr1->importance = tmpptr2->importance = imp;
+			tmpptr1->fimportance = tmpptr2->fimportance = (float)imp;
+
+//			fprintf( stderr, "## importance = %f\n", tmpptr1->importance );
+
+		}
+
+#if 1
+		if( ( tmpptr1 && !tmpptr2 ) || ( !tmpptr1 && tmpptr2 ) )
+		{
+			fprintf( stderr, "ERROR: i=%d, j=%d\n", i, j );
+			exit( 1 );
+		}
+#endif
+	}
+#endif
+#if 0
+	fprintf( stderr, "after averaging:\n" );
+
+	for( i=0; i<nseq; i++ ) for( j=0; j<nseq; j++ )
+	{
+		fprintf( stderr, "%d-%d\n", i, j );
+		for( tmpptr = localhom[i]+j; tmpptr; tmpptr=tmpptr->next )
+		{
+			fprintf( stderr, "reg1=%d-%d, reg2=%d-%d, imp=%f -> %f opt=%f\n", tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->opt / tmpptr->overlapaa, tmpptr->importance, tmpptr->opt );
+		}
+	}
+#endif
+}
+
+
+#if 0
+void weightimportance( int nseq, double **eff, LocalHom **localhom )
+{
+	int i, j, pos, len;
+	static double *importance;
+	double tmpdouble;
+	LocalHom *tmpptr, *tmpptr1, *tmpptr2;
+	if( importance == NULL )
+		importance = AllocateDoubleVec( nlenmax );
+
+
+	fprintf( stderr, "effmtx = :\n" );
+	for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<nseq; j++ )
+		{
+			fprintf( stderr, "%6.3f ", eff[i][j] );
+		}
+		fprintf( stderr, "\n" );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		for( pos=0; pos<nlenmax; pos++ )
+			importance[pos] = 0.0;
+		for( j=0; j<nseq; j++ )
+		{
+
+			if( i == j ) continue;
+			tmpptr = localhom[i]+j;
+			while( 1 )
+			{
+				fprintf( stderr, "i=%d, j=%d\n", i, j );
+				for( pos=tmpptr->start1; pos<=tmpptr->end1; pos++ )
+//					importance[pos] += eff[i][j] * tmpptr->importance;
+					importance[pos] += eff[i][j] / (double)nseq * tmpptr->importance / 1.0;
+				fprintf( stderr, "eff[][] = %f, localhom[i][j].importance = %f \n", eff[i][j], tmpptr->importance );
+				tmpptr = tmpptr->next;
+				if( tmpptr == NULL ) break;
+			} 
+
+		}
+#if 0
+		fprintf( stderr, "position specific importance of seq %d:\n", i );
+		for( pos=0; pos<nlenmax; pos++ )
+			fprintf( stderr, "%d: %f\n", pos, importance[pos] );
+		fprintf( stderr, "\n" );
+#endif
+		for( j=0; j<nseq; j++ )
+		{
+			fprintf( stderr, "i=%d, j=%d\n", i, j );
+			if( i == j ) continue;
+			tmpptr = localhom[i]+j;
+			do
+			{
+				tmpdouble = 0.0;
+				len = 0;
+				for( pos=tmpptr->start1; pos<=tmpptr->end1; pos++ )
+				{
+					tmpdouble += importance[pos];
+					len++;
+				}
+				tmpdouble /= (double)len;
+				tmpptr->importance = tmpdouble;
+				fprintf( stderr, "importance of match between %d - %d = %f\n", i, j, tmpdouble );
+				tmpptr = tmpptr->next;
+			} while( tmpptr );
+		}
+	}
+#if 1
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+	{
+		fprintf( stderr, "i = %d, j=%d\n", i, j );
+		tmpptr1 = localhom[i]+j;
+		tmpptr2 = localhom[j]+i;
+		while( tmpptr1 && tmpptr2 )
+		{
+			tmpptr1->importance += tmpptr2->importance;
+			tmpptr1->importance *= 0.5;
+			tmpptr2->importance *= tmpptr1->importance;
+			fprintf( stderr, "%d-%d: s1=%d, e1=%d, s2=%d, e2=%d, importance=%f\n", i, j, tmpptr1->start1, tmpptr1->end1, tmpptr1->start2, tmpptr1->end2, tmpptr1->importance );
+			tmpptr1 = tmpptr1->next;
+			tmpptr2 = tmpptr2->next;
+			fprintf( stderr, "tmpptr1 = %p, tmpptr2 = %p\n", tmpptr1, tmpptr2 );
+		}
+	}
+#endif
+}
+
+void weightimportance2( int nseq, double *eff, LocalHom **localhom )
+{
+	int i, j, pos, len;
+	static double *wimportance;
+	double tmpdouble;
+	if( wimportance == NULL )
+		wimportance = AllocateDoubleVec( nlenmax );
+
+
+	fprintf( stderr, "effmtx = :\n" );
+	for( i=0; i<nseq; i++ )
+	{
+		for( j=0; j<nseq; j++ )
+		{
+			fprintf( stderr, "%6.3f ", eff[i] * eff[j] );
+		}
+		fprintf( stderr, "\n" );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		fprintf( stderr, "i = %d\n", i );
+		for( pos=0; pos<nlenmax; pos++ )
+			wimportance[pos] = 0.0;
+		for( j=0; j<nseq; j++ )
+		{
+			if( i == j ) continue;
+			for( pos=localhom[i][j].start1; pos<=localhom[i][j].end1; pos++ )
+//				wimportance[pos] += eff[i][j];
+				wimportance[pos] += eff[i] * eff[j] / (double)nseq * localhom[i][j].importance / 1.0;
+		}
+#if 0
+		fprintf( stderr, "position specific wimportance of seq %d:\n", i );
+		for( pos=0; pos<nlenmax; pos++ )
+			fprintf( stderr, "%d: %f\n", pos, wimportance[pos] );
+		fprintf( stderr, "\n" );
+#endif
+		for( j=0; j<nseq; j++ )
+		{
+			if( i == j ) continue;
+			tmpdouble = 0.0;
+			len = 0;
+			for( pos=localhom[i][j].start1; pos<=localhom[i][j].end1; pos++ )
+			{
+				tmpdouble += wimportance[pos];
+				len++;
+			}
+			tmpdouble /= (double)len;
+			localhom[i][j].wimportance = tmpdouble;
+			fprintf( stderr, "wimportance of match between %d - %d = %f\n", i, j, tmpdouble );
+		}
+	}
+#if 1
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+	{
+		localhom[i][j].wimportance += localhom[j][i].wimportance;
+		localhom[i][j].wimportance = 0.5 * ( localhom[i][j].wimportance );
+	}
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+	{
+		localhom[j][i].wimportance = localhom[i][j].wimportance;
+	}
+#endif
+}
+
+void weightimportance4( int clus1, int clus2, double *eff1, double *eff2, LocalHom ***localhom )
+{
+	int i, j, pos, len;
+	static double *wimportance;
+	LocalHom *tmpptr, *tmpptr1, *tmpptr2;
+	if( wimportance == NULL )
+		wimportance = AllocateDoubleVec( nlenmax );
+
+
+#if 0
+	fprintf( stderr, "effarr1 = :\n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "%6.3f\n", eff1[i] );
+	fprintf( stderr, "effarr2 = :\n" );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "%6.3f\n", eff2[i] );
+#endif
+
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+//			fprintf( stderr, "i=%d, j=%d\n", i, j );
+			tmpptr = localhom[i][j];
+			do
+			{
+				tmpptr->wimportance = tmpptr->importance * eff1[i] * eff2[j];
+				tmpptr = tmpptr->next;
+			} while( tmpptr );
+		}
+	}
+}
+
+static void	addlocalhom_e( LocalHom *localhom, int start1, int start2, int end1, int end2, double opt )
+{
+	LocalHom *tmpptr;
+	tmpptr = localhom;
+
+	fprintf( stderr, "adding localhom\n" );
+	while( tmpptr->next )
+		tmpptr = tmpptr->next;
+	fprintf( stderr, "allocating localhom\n" );
+	tmpptr->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+	fprintf( stderr, "done\n" );
+	tmpptr = tmpptr->next;
+
+	tmpptr->start1 = start1;
+	tmpptr->start2 = start2;
+	tmpptr->end1 = end1;
+	tmpptr->end2 = end2;
+	tmpptr->opt = opt;
+
+	fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+}
+
+#if 0
+#endif
+
+
+
+void extendlocalhom( int nseq, LocalHom **localhom )
+{
+	int i, j, k, pos0, pos1, pos2, st;
+	int start1, start2, end1, end2;
+	static int *tmpint1 = NULL;
+	static int *tmpint2 = NULL;
+	static int *tmpdouble1 = NULL;
+	static int *tmpdouble2 = NULL;
+	double opt;
+	LocalHom *tmpptr;
+	if( tmpint1 == NULL )
+	{
+		tmpint1 = AllocateIntVec( nlenmax );
+		tmpint2 = AllocateIntVec( nlenmax );
+		tmpdouble1 = AllocateIntVec( nlenmax );
+		tmpdouble2 = AllocateIntVec( nlenmax );
+	}
+
+
+	for( k=0; k<nseq; k++ )
+	{
+		for( i=0; i<nseq-1; i++ ) 
+		{
+			if( i == k ) continue;
+			for( pos0=0; pos0<nlenmax; pos0++ ) 
+				tmpint1[pos0] = -1;
+
+			tmpptr=localhom[k]+i;
+			do
+			{
+				pos0 = tmpptr->start1;
+				pos1 = tmpptr->start2;
+				while( pos0<=tmpptr->end1 )
+				{
+					tmpint1[pos0] = pos1++;
+					tmpdouble1[pos0] = tmpptr->opt;
+					pos0++;
+				}
+			} while( tmpptr = tmpptr->next );
+
+
+			for( j=i+1; j<nseq; j++ )
+			{
+				if( j == k ) continue;
+				for( pos1=0; pos1<nlenmax; pos1++ ) tmpint2[pos1] = -1;
+				tmpptr=localhom[k]+j;
+				do
+				{
+					pos0 = tmpptr->start1;
+					pos2 = tmpptr->start2;
+					while( pos0<=tmpptr->end1 )
+					{
+						tmpint2[pos0] = pos2++;
+						tmpdouble2[pos0++] = tmpptr->opt;
+					}
+				} while( tmpptr = tmpptr->next );
+
+#if 0
+
+				fprintf( stderr, "i,j=%d,%d\n", i, j );
+
+				for( pos0=0; pos0<nlenmax; pos0++ )
+					fprintf( stderr, "%d ", tmpint1[pos0] );
+				fprintf( stderr, "\n" );
+
+				for( pos0=0; pos0<nlenmax; pos0++ )
+					fprintf( stderr, "%d ", tmpint2[pos0] );
+				fprintf( stderr, "\n" );
+#endif
+
+
+				st = 0;
+				for( pos0=0; pos0<nlenmax; pos0++ )
+				{
+//					fprintf( stderr, "pos0 = %d/%d, st = %d, tmpint1[pos0] = %d, tmpint2[pos0] = %d\n", pos0, nlenmax, st, tmpint1[pos0], tmpint2[pos0] );
+					if( tmpint1[pos0] >= 0 && tmpint2[pos0] >= 0 )
+					{
+						if( st == 0 )
+						{
+							st = 1;
+							start1 = tmpint1[pos0];
+							start2 = tmpint2[pos0];
+							opt = MIN( tmpdouble1[pos0], tmpdouble2[pos0] );
+						}
+						else if( tmpint1[pos0-1] != tmpint1[pos0]-1 || tmpint2[pos0-1] != tmpint2[pos0]-1 )
+						{
+							addlocalhom_e( localhom[i]+j, start1, start2, tmpint1[pos0-1], tmpint2[pos0-1], opt );
+							addlocalhom_e( localhom[j]+i, start2, start1, tmpint2[pos0-1], tmpint1[pos0-1], opt );
+							start1 = tmpint1[pos0];
+							start2 = tmpint2[pos0];
+							opt = MIN( tmpdouble1[pos0], tmpdouble2[pos0] );
+						}
+					}
+					if( tmpint1[pos0] == -1 || tmpint2[pos0] == -1 )
+					{
+						if( st == 1 )
+						{
+							st = 0;
+							addlocalhom_e( localhom[i]+j, start1, start2, tmpint1[pos0-1], tmpint2[pos0-1], opt );
+							addlocalhom_e( localhom[j]+i, start2, start1, tmpint2[pos0-1], tmpint1[pos0-1], opt );
+						}
+					}
+				}
+			}
+		}
+	}
+}
+#endif
+
+static void addlocalhom2_e( LocalHom *pt, LocalHom *lh, int sti, int stj, int eni, int enj, double opt, int overlp, int interm )
+{
+// dokka machigatteru
+	if( pt != lh ) // susumeru
+	{
+		pt->next = (LocalHom *)calloc( 1, sizeof( LocalHom ) );
+		pt = pt->next;
+		pt->next = NULL;
+		lh->last = pt;
+	}
+	else // sonomamatsukau
+	{
+		lh->last = pt;
+	}
+	lh->nokori++;
+//	fprintf( stderr, "in addlocalhom2_e, pt = %p, pt->next = %p, interm=%d, sti-eni-stj-enj=%d %d %d %d\n", pt, pt->next, interm, sti, eni, stj, enj );
+
+	pt->start1 = sti;
+	pt->start2 = stj;
+	pt->end1 = eni;
+	pt->end2 = enj;
+	pt->opt = opt;
+	pt->extended = interm;
+	pt->overlapaa = overlp;
+#if 0
+	fprintf( stderr, "i: %d-%d\n", sti, eni );
+	fprintf( stderr, "j: %d-%d\n", stj, enj );
+	fprintf( stderr, "opt=%f\n", opt );
+	fprintf( stderr, "overlp=%d\n", overlp );
+#endif
+}
+
+void extendlocalhom2( int nseq, LocalHom **localhom, double **dist )
+{
+	int overlp, plim;
+	int i, j, k;
+	int pi, pj, pk, len;
+	int status, sti, stj;
+	int *ipt;
+	int co;
+	static int *ini = NULL;
+	static int *inj = NULL;
+	LocalHom *pt;
+
+	sti = 0; // by D.Mathog, a guess
+	stj = 0; // by D.Mathog, a guess
+
+	if( ini == NULL )
+	{
+		ini = AllocateIntVec( nlenmax+1 );
+		inj = AllocateIntVec( nlenmax+1 );
+	}
+
+
+	for( i=0; i<nseq-1; i++ )
+	{
+		for( j=i+1; j<nseq; j++ )
+		{
+#if 0
+			for( k=0; k<nseq; k++ ) sai[k] = 0;
+			numint = ncons;
+			while( 1 )
+			{
+				k = (int)( rnd() * nseq );
+				if( k == i || k == j ) continue; // mou yatta nomo habuita hoga ii 
+				if( numint-- == 0 ) break;
+				if( sai[k] ) continue;
+				sai[k] = 1;
+#else
+			for( k=0; k<nseq; k++ )
+			{
+#endif
+//				fprintf( stderr, "i=%d, j=%d, k=%d, dists = %f,%f,%f thrinter=%f\n", i, j, k, dist[i][j], dist[MIN(i,k)][MAX(i,k)], dist[MIN(j,k)][MAX(j,k)], thrinter );
+				if( k == i || k == j ) continue; // mou yatta nomo habuita hoga ii 
+				if( dist[MIN(i,k)][MAX(i,k)] > dist[i][j] * thrinter || dist[MIN(j,k)][MAX(j,k)] > dist[i][j] * thrinter ) continue;
+				ipt = ini; co = nlenmax+1;
+				while( co-- ) *ipt++ = -1;
+				ipt = inj; co = nlenmax+1;
+				while( co-- ) *ipt++ = -1;
+				overlp = 0;
+
+				{
+					for( pt=localhom[i]+k; pt; pt=pt->next )
+		        	{
+//						fprintf( stderr, "i=%d,k=%d,st1:st2=%d:%d,pt=%p,extended=%p\n", i, k, pt->start1, pt->start2, pt, pt->extended );
+						if( pt->opt == -1 )
+						{
+							fprintf( stderr, "opt kainaide tbfast.c = %f\n", pt->opt );
+						}
+						if( pt->extended > -1 ) break;
+						pi = pt->start1;
+						pk = pt->start2;
+						len = pt->end1 - pt->start1 + 1;
+						ipt = ini + pk;
+						while( len-- ) *ipt++ = pi++;
+					}
+				}
+
+				{
+					for( pt=localhom[j]+k; pt; pt=pt->next )
+		        	{
+						if( pt->opt == -1 )
+						{
+							fprintf( stderr, "opt kainaide tbfast.c = %f\n", pt->opt );
+						}
+						if( pt->extended > -1 ) break;
+						pj = pt->start1;
+						pk = pt->start2;
+						len = pt->end1 - pt->start1 + 1;
+						ipt = inj + pk;
+						while( len-- ) *ipt++ = pj++;
+					}
+				}
+#if 0
+				fprintf( stderr, "i=%d,j=%d,k=%d\n", i, j, k );
+				overlp = 0;
+				for( pk = 0; pk < nlenmax; pk++ )
+				{
+					if( ini[pk] != -1 && inj[pk] != -1 ) overlp++;
+					fprintf( stderr, " %d", inj[pk] );
+				}
+				fprintf( stderr, "\n" );
+
+				fprintf( stderr, "i=%d,j=%d,k=%d\n", i, j, k );
+				overlp = 0;
+				for( pk = 0; pk < nlenmax; pk++ )
+				{
+					if( ini[pk] != -1 && inj[pk] != -1 ) overlp++;
+					fprintf( stderr, " %d", ini[pk] );
+				}
+				fprintf( stderr, "\n" );
+#endif
+				overlp = 0;
+				plim = nlenmax+1;
+				for( pk = 0; pk < plim; pk++ )
+					if( ini[pk] != -1 && inj[pk] != -1 ) overlp++;
+
+
+				status = 0;
+				plim = nlenmax+1;
+				for( pk=0; pk<plim; pk++ )
+				{
+//					fprintf( stderr, "%d %d: %d-%d\n", i, j, ini[pk], inj[pk] );
+					if( status )
+					{
+						if( ini[pk] == -1 || inj[pk] == -1 || ini[pk-1] != ini[pk] - 1 || inj[pk-1] != inj[pk] - 1 ) // saigonoshori
+						{
+							status = 0;
+//							fprintf( stderr, "end here!\n" );
+
+							pt = localhom[i][j].last;
+//							fprintf( stderr, "in ex (ba), pt = %p, nokori=%d, i,j,k=%d,%d,%d\n", pt, localhom[i][j].nokori, i, j, k );
+							addlocalhom2_e( pt, localhom[i]+j, sti, stj, ini[pk-1], inj[pk-1], MIN( localhom[i][k].opt, localhom[j][k].opt ) * 1.0, overlp, k );
+//							fprintf( stderr, "in ex, pt = %p, pt->next = %p, pt->next->next = %p\n", pt, pt->next, pt->next->next );
+
+							pt = localhom[j][i].last;
+//							fprintf( stderr, "in ex (ba), pt = %p, pt->next = %p\n", pt, pt->next );
+//							fprintf( stderr, "in ex (ba), pt = %p, pt->next = %p, k=%d\n", pt, pt->next, k );
+							addlocalhom2_e( pt, localhom[j]+i, stj, sti, inj[pk-1], ini[pk-1], MIN( localhom[i][k].opt, localhom[j][k].opt ) * 1.0, overlp, k );
+//							fprintf( stderr, "in ex, pt = %p, pt->next = %p, pt->next->next = %p\n", pt, pt->next, pt->next->next );
+						}
+					}
+					if( !status ) // else deha arimasenn.
+					{
+						if( ini[pk] == -1 || inj[pk] == -1 ) continue;
+						sti = ini[pk];
+						stj = inj[pk];
+//						fprintf( stderr, "start here!\n" );
+						status = 1;
+					}
+				}
+//				if( status ) fprintf( stderr, "end here\n" );
+
+//				exit( 1 );
+//					fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->next ); 
+			}
+#if 0
+			for( pt=localhomtable[i]+j; pt; pt=pt->next )
+        	{
+	            if( tmpptr->opt == -1.0 ) continue;
+				fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, tmpptr->next ); 
+        	}
+#endif
+		}
+	}
+}
+
+int makelocal( char *s1, char *s2, int thr )
+{
+	int start, maxstart, maxend;
+	char *pt1, *pt2;
+	double score;
+	double maxscore;
+
+	pt1 = s1;
+	pt2 = s2;
+
+	maxend = 0; // by D.Mathog, a guess
+
+//	fprintf( stderr, "thr = %d, \ns1 = %s\ns2 = %s\n", thr, s1, s2 );
+	maxscore = 0.0;
+	score = 0.0;
+	start = 0;
+	maxstart = 0;
+	while( *pt1 )
+	{
+//		fprintf( stderr, "*pt1 = %c*pt2 = %c\n", *pt1, *pt2 );
+		if( *pt1 == '-' || *pt2 == '-' )
+		{
+//			fprintf( stderr, "penalty = %d\n", penalty );
+			score += penalty;
+			while( *pt1 == '-' || *pt2 == '-' )
+			{
+				pt1++; pt2++;
+			}
+			continue;
+		}
+
+		score += ( amino_dis[(int)*pt1++][(int)*pt2++] - thr );
+//		score += ( amino_dis[(int)*pt1++][(int)*pt2++] );
+		if( score > maxscore ) 
+		{
+//			fprintf( stderr, "score = %f\n", score );
+			maxscore = score;
+			maxstart = start;
+//			fprintf( stderr, "## max! maxstart = %d, start = %d\n", maxstart, start );
+		}
+		if( score < 0.0 )
+		{
+//			fprintf( stderr, "## resetting, start = %d, maxstart = %d\n", start, maxstart );
+			if( start == maxstart )
+			{
+				maxend = pt1 - s1;
+//				fprintf( stderr, "maxend = %d\n", maxend );
+			}
+			score = 0.0;
+			start = pt1 - s1;
+		}
+	}
+	if( start == maxstart )
+		maxend = pt1 - s1 - 1;
+
+//	fprintf( stderr, "maxstart = %d, maxend = %d, maxscore = %f\n", maxstart, maxend, maxscore );
+	s1[maxend+1] = 0;
+	s2[maxend+1] = 0;
+	return( maxstart );
+}
+
+void resetlocalhom( int nseq, LocalHom **lh )
+{
+	int i, j;
+	LocalHom *pt;
+
+	for( i=0; i<nseq-1; i++ ) for( j=i+1; j<nseq; j++ )
+	{
+		for( pt=lh[i]+j; pt; pt=pt->next )
+			pt->opt = 1.0;
+	}
+
+}
+
+void gapireru( char *res, char *ori, char *gt )
+{
+	char g;
+	while( (g = *gt++) )
+	{
+		if( g == '-' )
+		{
+			*res++ = '-';
+		}
+		else
+		{
+			*res++ = *ori++;
+		}
+	}
+	*res = 0;
+}
+
+void getkyokaigap( char *g, char **s, int pos, int n )
+{
+//	char *bk = g;
+//	while( n-- ) *g++ = '-';
+	while( n-- ) *g++ = (*s++)[pos];
+
+//	fprintf( stderr, "bk = %s\n", bk );
+}
+
+void new_OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len, char *sgappat )
+#if 0
+{
+	int i, j, gc, gb; 
+	float feff;
+
+	
+	for( i=0; i<len+1; i++ ) ogcp[i] = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		gc = ( sgappat[j] == '-' );
+		for( i=0; i<len; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			if( !gb *  gc ) ogcp[i] += feff;
+		}
+	}
+}
+#else
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = ogcp;
+	i = len;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		spt = seq[j];
+		fpt = ogcp;
+		gc = ( sgappat[j] == '-' );
+		i = len;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *spt++ == '-' );
+			{
+				if( !gb *  gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+	}
+}
+#endif
+void new_OpeningGapCount_zure( float *ogcp, int clus, char **seq, double *eff, int len, char *sgappat, char *egappat )
+#if 0
+{
+	int i, j, gc, gb; 
+	float feff;
+
+	
+	for( i=0; i<len+1; i++ ) ogcp[i] = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		gc = ( sgappat[j] == '-' );
+		for( i=0; i<len; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			if( !gb *  gc ) ogcp[i] += feff;
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			if( !gb *  gc ) ogcp[i] += feff;
+		}
+	}
+}
+#else
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = ogcp;
+	i = len+2;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		spt = seq[j];
+		fpt = ogcp;
+		gc = ( sgappat[j] == '-' );
+		i = len;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *spt++ == '-' );
+			{
+				if( !gb *  gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			if( !gb *  gc ) *fpt += feff;
+		}
+	}
+}
+#endif
+
+void new_FinalGapCount_zure( float *fgcp, int clus, char **seq, double *eff, int len, char *sgappat, char *egappat )
+#if 0
+{
+	int i, j, gc, gb; 
+	float feff;
+	
+	for( i=0; i<len+1; i++ ) fgcp[i] = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		gc = ( sgappat[j] == '-' );
+		for( i=0; i<len; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			{
+				if( gb * !gc ) fgcp[i] += feff;
+			}
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			{
+				if( gb * !gc ) fgcp[len] += feff;
+			}
+		}
+	}
+}
+#else
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = fgcp;
+	i = len+2;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		fpt = fgcp;
+		spt = seq[j];
+		gc = ( sgappat[j] == '-' );
+		i = len;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *spt++ == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+			}
+		}
+	}
+}
+#endif
+void new_FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len, char *egappat )
+#if 0
+{
+	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] == '-' );
+		for( i=1; i<len; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			{
+				if( gb * !gc ) fgcp[i-1] += feff;
+			}
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			{
+				if( gb * !gc ) fgcp[len-1] += feff;
+			}
+		}
+	}
+}
+#else
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = fgcp;
+	i = len;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		fpt = fgcp;
+		spt = seq[j];
+		gc = ( *spt == '-' );
+		i = len;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *++spt == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+			}
+		}
+	}
+}
+#endif
+
+void st_OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len )
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = ogcp;
+	i = len;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		spt = seq[j];
+		fpt = ogcp;
+		gc = 0;
+//		gc = 1;
+		i = len;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *spt++ == '-' );
+			{
+				if( !gb *  gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+	}
+	ogcp[len] = 0.0;
+}
+
+void st_FinalGapCount_zure( float *fgcp, int clus, char **seq, double *eff, int len )
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = fgcp;
+	i = len+1;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		fpt = fgcp+1;
+		spt = seq[j];
+		gc = ( *spt == '-' );
+		i = len;
+//		for( i=1; i<len; i++ ) 
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *++spt == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+		{
+			gb = gc;
+			gc = 0;
+//			gc = 1;
+			{
+				if( gb * !gc ) *fpt += feff;
+			}
+		}
+	}
+}
+
+void st_FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len )
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = fgcp;
+	i = len;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		fpt = fgcp;
+		spt = seq[j];
+		gc = ( *spt == '-' );
+		i = len;
+//		for( i=1; i<len; i++ ) 
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *++spt == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+		{
+			gb = gc;
+			gc = 0;
+//			gc = 1;
+			{
+				if( gb * !gc ) *fpt += feff;
+			}
+		}
+	}
+}
+
+void getGapPattern( float *fgcp, int clus, char **seq, double *eff, int len, char *xxx )
+{
+	int i, j, gc, gb; 
+	float feff;
+	float *fpt;
+	char *spt;
+	
+	fpt = fgcp;
+	i = len+1;
+	while( i-- ) *fpt++ = 0.0;
+	for( j=0; j<clus; j++ ) 
+	{
+		feff = (float)eff[j];
+		fpt = fgcp;
+		spt = seq[j];
+		gc = ( *spt == '-' );
+		i = len+1;
+		while( i-- )
+		{
+			gb = gc;
+			gc = ( *++spt == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+				fpt++;
+			}
+		}
+#if 0
+		{
+			gb = gc;
+			gc = ( egappat[j] == '-' );
+			{
+				if( gb * !gc ) *fpt += feff;
+			}
+		}
+#endif
+	}
+	for( j=0; j<len; j++ )
+	{
+		fprintf( stderr, "%d, %f\n", j, fgcp[j] );
+	}
+}
+
+void getdigapfreq_st( float *freq, int clus, char **seq, double *eff, int len )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+1; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		if( 0 && seq[i][0] == '-' ) // machigai kamo
+			freq[0] += feff;
+		for( j=1; j<len; j++ ) 
+		{
+			if( seq[i][j] == '-' && seq[i][j-1] == '-' )
+				freq[j] += feff;
+		}
+		if( 0 && seq[i][len-1] == '-' )
+			freq[len] += feff;
+	}
+//	fprintf( stderr, "\ndigapf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getdiaminofreq_x( float *freq, int clus, char **seq, double *eff, int len )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+2; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		if( seq[i][0] != '-' ) // tadashii
+			freq[0] += feff;
+		for( j=1; j<len; j++ ) 
+		{
+			if( seq[i][j] != '-' && seq[i][j-1] != '-' )
+				freq[j] += feff;
+		}
+		if( 1 && seq[i][len-1] != '-' ) // xxx wo tsukawanaitoki [len-1] nomi
+			freq[len] += feff;
+	}
+//	fprintf( stderr, "\ndiaaf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getdiaminofreq_st( float *freq, int clus, char **seq, double *eff, int len )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+1; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		if( seq[i][0] != '-' )
+			freq[0] += feff;
+		for( j=1; j<len; j++ ) 
+		{
+			if( seq[i][j] != '-' && seq[i][j-1] != '-' )
+				freq[j] += feff;
+		}
+//		if( 1 && seq[i][len-1] != '-' ) // xxx wo tsukawanaitoki [len-1] nomi
+			freq[len] += feff;
+	}
+//	fprintf( stderr, "\ndiaaf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getdigapfreq_part( float *freq, int clus, char **seq, double *eff, int len, char *sgappat, char *egappat )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+2; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+//		if( seq[i][0] == '-' )
+		if( seq[i][0] == '-' && sgappat[i] == '-' )
+			freq[0] += feff;
+		for( j=1; j<len; j++ ) 
+		{
+			if( seq[i][j] == '-' && seq[i][j-1] == '-' )
+				freq[j] += feff;
+		}
+//		if( seq[i][len] == '-' && seq[i][len-1] == '-' ) // xxx wo tsukawanaitoki arienai
+		if( egappat[i] == '-' && seq[i][len-1] == '-' )
+			freq[len] += feff;
+	}
+//	fprintf( stderr, "\ndigapf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getdiaminofreq_part( float *freq, int clus, char **seq, double *eff, int len, char *sgappat, char *egappat )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+2; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		if( seq[i][0] != '-' && sgappat[i] != '-' )
+			freq[0] += feff;
+		for( j=1; j<len; j++ ) 
+		{
+			if( seq[i][j] != '-' && seq[i][j-1] != '-' )
+				freq[j] += feff;
+		}
+//		if( 1 && seq[i][len-1] != '-' ) // xxx wo tsukawanaitoki [len-1] nomi
+		if( egappat[i] != '-'  && seq[i][len-1] != '-' ) // xxx wo tsukawanaitoki [len-1] nomi
+			freq[len] += feff;
+	}
+//	fprintf( stderr, "\ndiaaf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getgapfreq_zure_part( float *freq, int clus, char **seq, double *eff, int len, char *sgap )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+2; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		if( sgap[i] == '-' )
+			freq[0] += feff;
+		for( j=0; j<len; j++ ) 
+		{
+			if( seq[i][j] == '-' )
+				freq[j+1] += feff;
+		}
+//		if( egap[i] == '-' )
+//			freq[len+1] += feff;
+	}
+//	fprintf( stderr, "\ngapf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getgapfreq_zure( float *freq, int clus, char **seq, double *eff, int len )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+1; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		for( j=0; j<len; j++ ) 
+		{
+			if( seq[i][j] == '-' )
+				freq[j+1] += feff;
+		}
+	}
+	freq[len+1] = 0.0;
+//	fprintf( stderr, "\ngapf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void getgapfreq( float *freq, int clus, char **seq, double *eff, int len )
+{
+	int i, j;
+	float feff;
+	for( i=0; i<len+1; i++ ) freq[i] = 0.0;
+	for( i=0; i<clus; i++ )
+	{
+		feff = eff[i];
+		for( j=0; j<len; j++ ) 
+		{
+			if( seq[i][j] == '-' )
+				freq[j] += feff;
+		}
+	}
+	freq[len] = 0.0;
+//	fprintf( stderr, "\ngapf = \n" );
+//	for( i=0; i<len+1; i++ ) fprintf( stderr, "%5.3f ", freq[i] );
+}
+
+void st_getGapPattern( Gappat **pat, int clus, char **seq, double *eff, int len )
+{
+	int i, j, k, gb, gc; 
+	int known;
+	float feff;
+	Gappat **fpt;
+	char *spt;
+	int gaplen;
+
+	fpt = pat;
+	i = len+1;
+	while( i-- ) 
+	{
+		if( *fpt ) free( *fpt );
+		*fpt++ = NULL;
+	}
+
+	for( j=0; j<clus; j++ ) 
+	{
+//		fprintf( stderr, "seq[%d] = %s\n", j, seq[j] );
+		feff = (float)eff[j];
+
+		fpt = pat;
+		*fpt = NULL; // Falign.c kara yobareru tokiha chigau.
+		spt = seq[j];
+		gc = 0;
+		gaplen = 0;
+
+		for( i=0; i<len+1; i++ ) 
+//		while( i-- )
+		{
+//			fprintf( stderr, "i=%d, gaplen = %d\n", i, gaplen );
+			gb = gc;
+			gc = ( i != len && *spt++ == '-' );
+			if( gc ) 
+				gaplen++;
+			else
+			{
+				if( gb && gaplen )
+				{
+					k = 1;
+					known = 0;
+					if( *fpt ) for( ; (*fpt)[k].len != -1; k++ )
+					{
+						if( (*fpt)[k].len == gaplen ) 
+						{
+//							fprintf( stderr, "known\n" );
+							known = 1;
+							break;
+						}
+					}
+
+					if( known == 0 )
+					{
+						*fpt = (Gappat *)realloc( *fpt, (k+3) *  sizeof( Gappat ) );  // mae1 (total), ato2 (len0), term
+						if( !*fpt )
+						{
+							fprintf( stderr, "Cannot allocate gappattern!'n" );
+							fprintf( stderr, "Use an approximate method, with the --mafft5 option.\n" );
+							exit( 1 );
+						}
+						(*fpt)[k].freq = 0.0;
+						(*fpt)[k].len = gaplen;
+						(*fpt)[k+1].len = -1;
+						(*fpt)[k+1].freq = 0.0; // iranai
+//						fprintf( stderr, "gaplen=%d, Unknown, %f\n", gaplen, (*fpt)[k].freq );
+					}
+
+//					fprintf( stderr, "adding pos %d, len=%d, k=%d, freq=%f->", i, gaplen, k, (*fpt)[k].freq );
+					(*fpt)[k].freq += feff;
+//					fprintf( stderr, "%f\n", (*fpt)[k].freq );
+					gaplen = 0;
+				}
+			}
+			fpt++;
+		}
+	}
+#if 1
+	for( j=0; j<len+1; j++ )
+	{
+		if( pat[j] )
+		{
+//			fprintf( stderr, "j=%d\n", j );
+//			for( i=1; pat[j][i].len!=-1; i++ )
+//				fprintf( stderr, "pos=%d, i=%d, len=%d, freq=%f\n", j, i, pat[j][i].len, pat[j][i].freq );
+
+			pat[j][0].len = 0; // iminashi
+			pat[j][0].freq = 0.0;
+			for( i=1; pat[j][i].len!=-1;i++ )
+			{
+				pat[j][0].freq += pat[j][i].freq;
+//				fprintf( stderr, "totaling, i=%d, result = %f\n", i, pat[j][0].freq );
+			}
+//			fprintf( stderr, "totaled, result = %f\n", pat[j][0].freq );
+
+			pat[j][i].freq = 1.0 - pat[j][0].freq;
+			pat[j][i].len = 0; // imiari
+			pat[j][i+1].len = -1; 
+		}
+		else
+		{
+			pat[j] = (Gappat *)calloc( 3, sizeof( Gappat ) );
+			pat[j][0].freq = 0.0;
+			pat[j][0].len = 0; // iminashi
+
+			pat[j][1].freq = 1.0 - pat[j][0].freq;
+			pat[j][1].len = 0; // imiari
+			pat[j][2].len = -1; 
+		}
+	}
+#endif
+}
+
+static void commongappickpair( char *r1, char *r2, char *i1, char *i2 )
+{
+//	strcpy( r1, i1 );
+//	strcpy( r2, i2 );
+//	return; // not SP
+	while( *i1 )
+	{
+		if( *i1 == '-' && *i2 == '-' ) 
+		{
+			i1++;
+			i2++;
+		}
+		else
+		{
+			*r1++ = *i1++;
+			*r2++ = *i2++;
+		}
+	}
+	*r1 = 0;
+	*r2 = 0;
+}
+
+float naiveRpairscore( int n1, int n2, char **seq1, char **seq2, double *eff1, double *eff2, int penal )
+{
+//	return( 0 );
+	int i, j;
+	float val;
+	float  valf;
+	int  pv;
+	double deff;
+	char *p1, *p2, *p1p, *p2p;
+	val = 0.0;
+	for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
+	{
+		deff = eff1[i] * eff2[j];
+//		fprintf( stderr, "feff %d-%d = %f\n", i, j, feff );
+//		fprintf( stderr, "i1 = %s\n", seq1[i] );
+//		fprintf( stderr, "i2 = %s\n", seq2[j] );
+//		fprintf( stderr, "s1 = %s\n", s1 );
+//		fprintf( stderr, "s2 = %s\n", s2 );
+//		fprintf( stderr, "penal = %d\n", penal );
+
+		valf = 0;
+		p1 = seq1[i]; p2 = seq2[j];
+		pv = 0;
+		if( *p1 == '-' && *p2 != '-' )
+			pv = penal;
+		if( *p1 != '-' && *p2 == '-' )
+			pv = penal;
+//		if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, p1-seq1[i], p2-seq2[j] );
+		p1p = p1; p2p = p2;
+		valf += (float)amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+		while( *p1p )
+		{
+			pv = 0;
+			if( *p1p != '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p == '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal;
+//					;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal;
+//					;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p != '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal * 2; // ??
+//					;
+				if( *p1 != '-' && *p2 == '-' )
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+//					;
+				if( *p1 == '-' && *p2 == '-' )
+					pv = penal;
+//					;
+			}
+			if( *p1p == '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal * 2; // ??
+//					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+//					;
+				if( *p1 == '-' && *p2 == '-' )
+					pv = penal;
+//					;
+			}
+//			fprintf( stderr, "adding %c-%c, %d\n", *p1, *p2, amino_dis[*p1][*p2] );
+//			if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, p1-seq1[i], p2-seq2[j] );
+			valf += amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+			p1p++; p2p++;
+		}
+//		fprintf( stderr, "valf = %d\n", valf );
+		val += deff * ( valf );
+	}
+	fprintf( stderr, "val = %f\n", val );
+	return( val );
+//	exit( 1 );
+}
+float naiveQpairscore( int n1, int n2, char **seq1, char **seq2, double *eff1, double *eff2, int penal )
+{
+	int i, j;
+	float val;
+	float  valf;
+	int  pv;
+	double deff;
+	char *p1, *p2, *p1p, *p2p;
+	return( 0 );
+	val = 0.0;
+	for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
+	{
+		deff = eff1[i] * eff2[j];
+//		fprintf( stderr, "feff %d-%d = %f\n", i, j, feff );
+//		fprintf( stderr, "i1 = %s\n", seq1[i] );
+//		fprintf( stderr, "i2 = %s\n", seq2[j] );
+//		fprintf( stderr, "s1 = %s\n", s1 );
+//		fprintf( stderr, "s2 = %s\n", s2 );
+//		fprintf( stderr, "penal = %d\n", penal );
+
+		valf = 0;
+		p1 = seq1[i]; p2 = seq2[j];
+		pv = 0;
+		if( *p1 == '-' && *p2 != '-' )
+			pv = penal;
+		if( *p1 != '-' && *p2 == '-' )
+			pv = penal;
+//		if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, p1-seq1[i], p2-seq2[j] );
+		p1p = p1; p2p = p2;
+		valf += (float)amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+		while( *p1p )
+		{
+			pv = 0;
+			if( *p1p != '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p == '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 == '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p != '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal * 2; // ??
+//					;
+				if( *p1 != '-' && *p2 == '-' )
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+//					;
+				if( *p1 == '-' && *p2 == '-' )
+//					pv = penal;
+					;
+			}
+			if( *p1p == '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal * 2; // ??
+//					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+//					;
+				if( *p1 == '-' && *p2 == '-' )
+//					pv = penal;
+					;
+			}
+//			fprintf( stderr, "adding %c-%c, %d\n", *p1, *p2, amino_dis[*p1][*p2] );
+//			if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, p1-seq1[i], p2-seq2[j] );
+			valf += amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+			p1p++; p2p++;
+		}
+//		fprintf( stderr, "valf = %d\n", valf );
+		val += deff * ( valf );
+	}
+	fprintf( stderr, "val = %f\n", val );
+	return( val );
+//	exit( 1 );
+}
+float naiveHpairscore( int n1, int n2, char **seq1, char **seq2, double *eff1, double *eff2, int penal )
+{
+	int i, j;
+	float val;
+	float  valf;
+	int  pv;
+//	float feff = 0.0; // by D.Mathog, a guess
+	double deff;
+	char *p1, *p2, *p1p, *p2p;
+	val = 0.0;
+	for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
+	{
+		deff = eff1[i] * eff2[j];
+//		fprintf( stderr, "i1 = %s\n", seq1[i] );
+//		fprintf( stderr, "i2 = %s\n", seq2[j] );
+//		fprintf( stderr, "s1 = %s\n", s1 );
+//		fprintf( stderr, "s2 = %s\n", s2 );
+//		fprintf( stderr, "penal = %d\n", penal );
+
+		valf = 0;
+		p1 = seq1[i]; p2 = seq2[j];
+		pv = 0;
+		if( *p1 == '-' && *p2 != '-' )
+			pv = penal;
+		if( *p1 != '-' && *p2 == '-' )
+			pv = penal;
+		if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, (int)(p1-seq1[i]), (int)(p2-seq2[j]) );
+		p1p = p1; p2p = p2;
+		valf += (float)amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+		while( *p1p )
+		{
+			pv = 0;
+			if( *p1p != '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 == '-' )
+					pv = penal;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p == '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 == '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					;
+				if( *p1 == '-' && *p2 == '-' )
+					;
+			}
+			if( *p1p != '-' && *p2p == '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 == '-' )
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+				if( *p1 == '-' && *p2 == '-' )
+//					pv = penal;
+					;
+			}
+			if( *p1p == '-' && *p2p != '-' )
+			{
+				if( *p1 == '-' && *p2 != '-' )
+					;
+				if( *p1 != '-' && *p2 == '-' )
+//					pv = penal;
+					;
+				if( *p1 != '-' && *p2 != '-' )
+					pv = penal;
+				if( *p1 == '-' && *p2 == '-' )
+//					pv = penal;
+					;
+			}
+//			fprintf( stderr, "adding %c-%c, %d\n", *p1, *p2, amino_dis[*p1][*p2] );
+//			if( pv ) fprintf( stderr, "Penal!, %f, %d-%d, pos1,pos2=%d,%d\n", pv * deff * 0.5,  i, j, p1-seq1[i], p2-seq2[j] );
+			valf += amino_dis[(int)*p1++][(int)*p2++] + 0.5 * pv;
+			p1p++; p2p++;
+		}
+//		fprintf( stderr, "valf = %d\n", valf );
+		val += deff * ( valf );
+	}
+	fprintf( stderr, "val = %f\n", val );
+	return( val );
+//	exit( 1 );
+}
+
+int naivepairscore11( char *seq1, char *seq2, int penal )
+{
+	int  vali;
+	int len = strlen( seq1 );
+	char *s1, *s2, *p1, *p2;
+	s1 = calloc( len+1, sizeof( char ) );
+	s2 = calloc( len+1, sizeof( char ) );
+	{
+		vali = 0;
+		commongappickpair( s1, s2, seq1, seq2 );
+//		fprintf( stderr, "i1 = %s\n", seq1[i] );
+//		fprintf( stderr, "i2 = %s\n", seq2[j] );
+//		fprintf( stderr, "s1 = %s\n", s1 );
+//		fprintf( stderr, "s2 = %s\n", s2 );
+//		fprintf( stderr, "penal = %d\n", penal );
+
+		p1 = s1; p2 = s2;
+		while( *p1 )
+		{
+			if( *p1 == '-' )
+			{
+//				fprintf( stderr, "Penal! %c-%c in %d-%d, %f\n", *(p1-1), *(p2-1), i, j, feff );
+				vali += penal;
+//				while( *p1 == '-' || *p2 == '-' ) 
+				while( *p1 == '-' )  // SP
+				{
+					p1++;
+					p2++;
+				}
+				continue;
+			}
+			if( *p2 == '-' )
+			{
+//				fprintf( stderr, "Penal! %c-%c in %d-%d, %f\n", *(p1-1), *(p2-1), i, j, feff );
+				vali +=  penal;
+//				while( *p2 == '-' || *p1 == '-' ) 
+				while( *p2 == '-' )  // SP
+				{
+					p1++;
+					p2++;
+				}
+				continue;
+			}
+//			fprintf( stderr, "adding %c-%c, %d\n", *p1, *p2, amino_dis[*p1][*p2] );
+			vali += amino_dis[(int)*p1++][(int)*p2++];
+		}
+	}
+	free( s1 );
+	free( s2 );
+//	fprintf( stderr, "vali = %d\n", vali );
+	return( vali );
+//	exit( 1 );
+}
+float naivepairscore( int n1, int n2, char **seq1, char **seq2, double *eff1, double *eff2, int penal )
+{
+//	return( 0.0 );
+	int i, j;
+	float val;
+	int  vali;
+	float feff;
+	int len = strlen( seq1[0] );
+	char *s1, *s2, *p1, *p2;
+	s1 = calloc( len+1, sizeof( char ) );
+	s2 = calloc( len+1, sizeof( char ) );
+	val = 0.0;
+	for( i=0; i<n1; i++ ) for( j=0; j<n2; j++ )
+	{
+		vali = 0;
+		feff = eff1[i] * eff2[j];
+//		fprintf( stderr, "feff %d-%d = %f\n", i, j, feff );
+		commongappickpair( s1, s2, seq1[i], seq2[j] );
+//		fprintf( stderr, "i1 = %s\n", seq1[i] );
+//		fprintf( stderr, "i2 = %s\n", seq2[j] );
+//		fprintf( stderr, "s1 = %s\n", s1 );
+//		fprintf( stderr, "s2 = %s\n", s2 );
+//		fprintf( stderr, "penal = %d\n", penal );
+
+		p1 = s1; p2 = s2;
+		while( *p1 )
+		{
+			if( *p1 == '-' )
+			{
+//				fprintf( stderr, "Penal! %c-%c in %d-%d, %f\n", *(p1-1), *(p2-1), i, j, feff );
+				vali += penal;
+//				while( *p1 == '-' || *p2 == '-' ) 
+				while( *p1 == '-' )  // SP
+				{
+					p1++;
+					p2++;
+				}
+				continue;
+			}
+			if( *p2 == '-' )
+			{
+//				fprintf( stderr, "Penal! %c-%c in %d-%d, %f\n", *(p1-1), *(p2-1), i, j, feff );
+				vali +=  penal;
+//				while( *p2 == '-' || *p1 == '-' ) 
+				while( *p2 == '-' )  // SP
+				{
+					p1++;
+					p2++;
+				}
+				continue;
+			}
+//			fprintf( stderr, "adding %c-%c, %d\n", *p1, *p2, amino_dis[*p1][*p2] );
+			vali += amino_dis[(int)*p1++][(int)*p2++];
+		}
+//		fprintf( stderr, "vali = %d\n", vali );
+		val += feff * vali;
+	}
+	free( s1 );
+	free( s2 );
+	fprintf( stderr, "val = %f\n", val );
+	return( val );
+//	exit( 1 );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,562 @@
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mtxutl.h"
+
+void MtxuntDouble( double **mtx, int n )
+{
+    int i, j;
+    for( i=0; i<n; i++ ) for( j=0; j<n; j++ ) mtx[i][j] = 0.0;
+    for( i=0; i<n; i++ ) mtx[i][i] = 1.0;
+}
+
+void MtxmltDouble( double **mtx1, double **mtx2, int n )
+{
+    int i, j, k;
+    double s, *tmp;
+
+	tmp = (double *)calloc( n, sizeof( double ) );
+    for( i=0; i<n; i++ ) 
+    {
+        for( k=0; k<n; k++ ) tmp[k] = mtx1[i][k];
+        for( j=0; j<n; j++ ) 
+        {
+            s = 0.0;
+            for( k=0; k<n; k++ ) s += tmp[k] * mtx2[k][j];
+            mtx1[i][j] = s;
+        }
+    }
+	free( tmp );
+}
+
+char *AllocateCharVec( int l1 )
+{
+	char *cvec;
+	
+	cvec = (char *)calloc( l1, sizeof( char ) );
+	if( cvec == NULL )
+	{
+		fprintf( stderr, "Cannot allocate %d character vector.\n", l1 );
+		exit( 1 );
+	}
+	return( cvec );
+}
+	
+#if 0
+void ReallocateCharMtx( char **mtx, int l1, int l2 )
+{
+	int i;
+	char *bk = (char *)malloc( l2+1 ); // hontou ha iranai
+	if( bk == NULL )
+	{
+		fprintf( stderr, "Cannot allocate bk in ReallocateCharMtx\n" );
+		exit( 1 );
+	}
+	for( i=0; i<l1; i++ ) 
+	{
+#if 1
+		strcpy( bk, mtx[i] );
+		mtx[i] = (char *)realloc( mtx[i], (l2+1) * sizeof( char ) );
+		if( mtx[i] == NULL )
+		{
+			fprintf( stderr, "Cannot reallocate %d x %d character matrix.\n", l1, l2 );
+		}
+		if( strcmp( bk, mtx[i] ) ) // hontou ha iranai
+		{
+			fprintf( stderr, "changed!! \n%s\n \nto\n%s\n in realloc..\n", bk, mtx[i] );
+			strcpy( mtx[i], bk );
+		}
+#else
+		strcpy( bk, mtx[i] );
+		free( mtx[i] );
+		mtx[i] = (char *)calloc( (l2+1), sizeof( char ) );
+		strcpy( mtx[i], bk );
+#endif
+	}
+	free( bk ); // hontou ha iranai
+} 
+#else
+void ReallocateCharMtx( char **mtx, int l1, int l2 )
+{
+	int i;
+	for( i=0; i<l1; i++ ) 
+	{
+		mtx[i] = (char *)realloc( mtx[i], (l2+1) * sizeof( char ) );
+		if( mtx[i] == NULL )
+		{
+			fprintf( stderr, "Cannot reallocate %d x %d character matrix.\n", l1, l2 );
+		}
+	}
+} 
+#endif
+
+char **AllocateCharMtx( int l1, int l2 )
+{
+	int i;
+	char **cmtx;
+	
+	cmtx = (char **)calloc( l1+1, sizeof( char * ) );
+	if( cmtx == NULL )
+	{
+		fprintf( stderr, "Cannot allocate %d x %d character matrix.\n", l1, l2 );
+		exit( 1 );
+	}   
+	if( l2 )
+	{
+		for( i=0; i<l1; i++ ) 
+		{
+			cmtx[i] = AllocateCharVec( l2 );
+		}
+	}
+	cmtx[l1] = NULL;
+	return( cmtx );
+} 
+
+void FreeCharMtx( char **mtx )
+{
+/*
+	char **x;
+	x = mtx;
+	while( *x != NULL ) free( *x++ );
+	free( mtx );
+*/
+	int i;
+	for( i=0; mtx[i]; i++ ) 
+	{
+		free( mtx[i] );
+	}
+	free( mtx );
+}
+
+float *AllocateFloatVec( int l1 )
+{
+	float *vec;
+
+	vec = (float *)calloc( (unsigned int)l1, sizeof( float ) );
+	if( vec == NULL )
+	{
+		fprintf( stderr, "Allocation error ( %d fload vec )\n", l1 );
+		exit( 1 );
+	}
+	return( vec );
+}
+
+void FreeFloatVec( float *vec )
+{
+	free( (char *)vec );
+}
+
+float **AllocateFloatHalfMtx( int ll1 )
+{
+	float **mtx;
+	int i;
+
+	mtx = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+	if( mtx == NULL )
+	{
+		fprintf( stderr, "Allocation error ( %d fload halfmtx )\n", ll1 );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ )
+	{
+		mtx[i] = (float *)calloc( ll1-i, sizeof( float ) );
+		if( !mtx[i] )
+		{
+			fprintf( stderr, "Allocation error( %d floathalfmtx )\n", ll1 );
+			exit( 1 );
+		}
+	}
+	mtx[ll1] = NULL;
+	return( mtx );
+}
+
+float **AllocateFloatMtx( int ll1, int ll2 )
+{
+	float **mtx;
+	int i;
+
+	mtx = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+	if( mtx == NULL )
+	{
+		fprintf( stderr, "Allocation error ( %d x %d fload mtx )\n", ll1, ll2 );
+		exit( 1 );
+	}
+	if( ll2 )
+	{
+		for( i=0; i<ll1; i++ )
+		{
+			mtx[i] = (float *)calloc( ll2, sizeof( float ) );
+			if( !mtx[i] )
+			{
+				fprintf( stderr, "Allocation error( %d x %d floatmtx )\n", ll1, ll2 );
+				exit( 1 );
+			}
+		}
+	}
+	mtx[ll1] = NULL;
+	return( mtx );
+}
+
+void FreeFloatHalfMtx( float **mtx, int n )
+{
+	int i;
+
+	for( i=0; i<n; i++ ) 
+	{
+		if( mtx[i] ) FreeFloatVec( mtx[i] );
+	}
+	free( mtx );
+}
+void FreeFloatMtx( float **mtx )
+{
+	int i;
+
+	for( i=0; mtx[i]; i++ ) 
+	{
+		FreeFloatVec( mtx[i] );
+	}
+	free( mtx );
+}
+
+int *AllocateIntVec( int ll1 )
+{
+	int *vec;
+
+	vec = (int *)calloc( ll1, sizeof( int ) );
+	if( vec == NULL )
+	{	
+		fprintf( stderr, "Allocation error( %d int vec )\n", ll1 );
+		exit( 1 );
+	}
+	return( vec );
+}	
+
+void FreeIntVec( int *vec )
+{
+	free( (char *)vec );
+}
+
+float **AllocateFloatTri( int ll1 )
+{
+	float **tri;
+	int i;
+
+	tri = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+	if( !tri )
+	{
+		fprintf( stderr, "Allocation error ( float tri )\n" );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ ) 
+	{
+		tri[i] = AllocateFloatVec( i+3 );
+	}
+	tri[ll1] = NULL;
+		
+	return( tri );
+}
+
+void FreeFloatTri( float **tri )
+{
+/*
+	float **x;
+	x = tri;
+	while( *tri != NULL ) free( *tri++ );
+	free( x );
+*/
+	int i;
+	for( i=0; tri[i]; i++ ) 
+		free( tri[i] );
+	free( tri );
+}
+		
+int **AllocateIntMtx( int ll1, int ll2 )
+{
+	int i;
+	int **mtx;
+
+	mtx = (int **)calloc( ll1+1, sizeof( int * ) );
+	if( !mtx )
+	{
+		fprintf( stderr, "Allocation error( %d x %d int mtx )\n", ll1, ll2 );
+		exit( 1 );
+	}
+	if( ll2 )
+	{
+		for( i=0; i<ll1; i++ ) 
+		{
+			mtx[i] = AllocateIntVec( ll2 );
+		}
+	}
+	mtx[ll1] = NULL;
+	return( mtx );
+}
+
+/*
+void FreeIntMtx( int **mtx )
+{
+*
+	int **x;
+	x = mtx;
+	while( !*mtx ) free( *mtx++ );
+	free( x );
+*
+	int i;
+	for( i=0; mtx[i] != NULL; i++ ) 
+		free( (char *)mtx[i] );
+	free( (char *)mtx );
+}
+*/
+
+char ***AllocateCharCub( int ll1, int ll2, int  ll3 )
+{
+	int i;
+	char ***cub;
+
+	cub = (char ***)calloc( ll1+1, sizeof( char ** ) );
+	if( !cub ) 
+	{
+		fprintf( stderr, "Allocation error( %d x %d x %d char cube\n", ll1, ll2, ll3 );
+		exit( 1 );
+	}
+	if( ll2 )
+	{
+		for( i=0; i<ll1; i++ ) 
+		{
+			cub[i] = AllocateCharMtx( ll2, ll3 );
+		}
+	}
+	cub[ll1] = NULL;
+	return( cub );
+}
+
+void FreeCharCub( char ***cub )
+{
+	int i;
+
+	for( i=0; cub[i]; i++ ) 
+	{
+		FreeCharMtx( cub[i] );
+	}
+	free( cub );
+}
+
+void freeintmtx( int **mtx, int ll1, int ll2 )
+{
+    int i;
+
+    for( i=0; i<ll1; i++ ) 
+        free( (char *)mtx[i] );
+    free( (char *)mtx );
+}
+      
+void FreeIntMtx( int **mtx )
+{
+	int i;
+
+	for( i=0; mtx[i]; i++ ) 
+		free( (char *)mtx[i] );
+	free( (char *)mtx );
+}
+
+char ****AllocateCharHcu( int ll1, int ll2, int ll3, int ll4 )
+{
+	int i;
+	char ****hcu;
+
+	hcu = (char ****)calloc( ll1+1, sizeof( char *** ) );
+	if( hcu == NULL ) exit( 1 );
+	for( i=0; i<ll1; i++ ) 
+		hcu[i] = AllocateCharCub( ll2, ll3, ll4 );
+	hcu[ll1] = NULL;
+	return( hcu );
+}
+
+void FreeCharHcu( char ****hcu )
+{
+	int i;
+	for( i=0; hcu[i]; i++ )
+	{
+		FreeCharCub( hcu[i] );
+	}
+	free ( (char *)hcu );
+}
+
+double *AllocateDoubleVec( int ll1 )
+{
+	double *vec;
+
+	vec = (double *)calloc( ll1, sizeof( double ) );
+	return( vec );
+}
+
+void FreeDoubleVec( double *vec )
+{
+	free( vec );
+}
+
+int ***AllocateIntCub( int ll1, int ll2, int ll3 )
+{
+	int i;
+	int ***cub;
+
+	cub = (int ***)calloc( ll1+1, sizeof( int ** ) );
+	if( cub == NULL )
+	{
+		fprintf( stderr, "cannot allocate IntCub\n" );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ ) 
+		cub[i] = AllocateIntMtx( ll2, ll3 );
+	cub[ll1] = NULL;
+
+	return cub;
+}
+
+void FreeIntCub( int ***cub )
+{
+	int i;
+	for( i=0; cub[i]; i++ ) 
+	{
+		FreeIntMtx( cub[i] );
+	}
+	free( cub );
+}
+
+double **AllocateDoubleMtx( int ll1, int ll2 )
+{
+	int i;
+	double **mtx;
+	mtx = (double **)calloc( ll1+1, sizeof( double * ) );
+	if( !mtx )
+	{
+		fprintf( stderr, "cannot allocate DoubleMtx\n" );
+		exit( 1 );
+	}
+	if( ll2 )
+	{
+		for( i=0; i<ll1; i++ ) 
+			mtx[i] = AllocateDoubleVec( ll2 );
+	}
+	mtx[ll1] = NULL;
+
+	return mtx;
+}
+
+void FreeDoubleMtx( double **mtx )
+{
+	int i;
+	for( i=0; mtx[i]; i++ )
+		FreeDoubleVec( mtx[i] );
+	free( mtx );
+}
+
+float ***AllocateFloatCub( int ll1, int ll2, int  ll3 )
+{
+	int i;
+	float ***cub;
+
+	cub = (float ***)calloc( ll1+1, sizeof( float ** ) );
+	if( !cub ) 
+	{
+		fprintf( stderr, "cannot allocate float cube.\n" );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ ) 
+	{
+		cub[i] = AllocateFloatMtx( ll2, ll3 );
+	}
+	cub[ll1] = NULL;
+	return( cub );
+}
+
+void FreeFloatCub( float ***cub )
+{
+	int i;
+
+	for( i=0; cub[i]; i++ ) 
+	{
+		FreeFloatMtx( cub[i] );
+	}
+	free( cub );
+}
+
+double ***AllocateDoubleCub( int ll1, int ll2, int  ll3 )
+{
+	int i;
+	double ***cub;
+
+	cub = (double ***)calloc( ll1+1, sizeof( double ** ) );
+	if( !cub ) 
+	{
+		fprintf( stderr, "cannot allocate double cube.\n" );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ ) 
+	{
+		cub[i] = AllocateDoubleMtx( ll2, ll3 );
+	}
+	cub[ll1] = NULL;
+	return( cub );
+}
+
+void FreeDoubleCub( double ***cub )
+{
+	int i;
+
+	for( i=0; cub[i]; i++ ) 
+	{
+		FreeDoubleMtx( cub[i] );
+	}
+	free( cub );
+}
+
+
+short *AllocateShortVec( int ll1 )
+{
+	short *vec;
+
+	vec = (short *)calloc( ll1, sizeof( short ) );
+	if( vec == NULL )
+	{	
+		fprintf( stderr, "Allocation error( %d short vec )\n", ll1 );
+		exit( 1 );
+	}
+	return( vec );
+}	
+
+void FreeShortVec( short *vec )
+{
+	free( (char *)vec );
+}
+
+short **AllocateShortMtx( int ll1, int ll2 )
+{
+	int i;
+	short **mtx;
+
+
+	mtx = (short **)calloc( ll1+1, sizeof( short * ) );
+	if( !mtx )
+	{
+		fprintf( stderr, "Allocation error( %d x %d short mtx ) \n", ll1, ll2 );
+		exit( 1 );
+	}
+	for( i=0; i<ll1; i++ ) 
+	{
+		mtx[i] = AllocateShortVec( ll2 );
+	}
+	mtx[ll1] = NULL;
+	return( mtx );
+}
+
+void FreeShortMtx( short **mtx )
+{
+	int i;
+
+	for( i=0; mtx[i]; i++ ) 
+		free( (char *)mtx[i] );
+	free( (char *)mtx );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.h?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/mtxutl.h Thu Feb 19 06:37:59 2009
@@ -0,0 +1,50 @@
+void MtxuntDouble( double **, int );
+void MtxmltDouble( double **, double **, int );
+
+char *AllocateCharVec( int );
+void FreeCharVec( char * );
+
+char **AllocateCharMtx( int, int);
+void ReallocateCharMtx( char **, int, int);
+void FreeCharMtx( char ** );
+
+float *AllocateFloatVec( int );
+void FreeFloatVec( float * );
+
+float **AllocateFloatHalfMtx( int );
+float **AllocateFloatMtx( int, int );
+void FreeFloatHalfMtx( float **, int );
+void FreeFloatMtx( float ** );
+
+float **AlocateFloatTri( int );
+void FreeFloatTri( float ** );
+
+int *AllocateIntVec( int );
+void FreeIntVec( int * );
+
+int **AllocateIntMtx( int, int );
+void FreeIntMtx( int ** );
+
+char ***AllocateCharCub( int, int, int );
+void FreeCharCub( char *** );
+
+int ***AllocateIntCub( int, int, int );
+void FreeIntCub( int *** );
+
+double *AllocateDoubleVec( int );
+void FreeDoubleVec( double * );
+
+double **AllocateDoubleMtx( int, int );
+void FreeDoubleMtx( double ** );
+
+double ***AllocateDoubleCub( int, int, int );
+void FreeDoubleCub( double *** );
+
+float ***AllocateFloatCub( int, int, int );
+void FreeFloatCub( float *** );
+
+short *AllocateShortVec( int );
+void FreeShortVec( short * );
+
+short **AllocateShortMtx( int, int );
+void FreeShortMtx( short ** );

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/pairlocalalign.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/pairlocalalign.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/pairlocalalign.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/pairlocalalign.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1228 @@
+#include "mltaln.h"
+
+#define DEBUG 0
+#define IODEBUG 0
+#define SCOREOUT 0
+
+#define NODIST -9999
+
+static char *whereispairalign;
+static char *laraparams;
+static char foldalignopt[1000];
+static int out_align_instead_of_hat3;
+
+static void t2u( char *seq )
+{
+	while( *seq )
+	{
+		if     ( *seq == 'A' ) *seq = 'a';
+		else if( *seq == 'a' ) *seq = 'a';
+		else if( *seq == 'T' ) *seq = 'u';
+		else if( *seq == 't' ) *seq = 'u';
+		else if( *seq == 'U' ) *seq = 'u';
+		else if( *seq == 'u' ) *seq = 'u';
+		else if( *seq == 'G' ) *seq = 'g';
+		else if( *seq == 'g' ) *seq = 'g';
+		else if( *seq == 'C' ) *seq = 'c';
+		else if( *seq == 'c' ) *seq = 'c';
+		else *seq = 'n';
+		seq++;
+	}
+}
+
+static float recallpairfoldalign( char **mseq1, char **mseq2, int m1, int m2, int *of1pt, int *of2pt, int alloclen )
+{
+	static FILE *fp = NULL;
+	float value;
+	char *aln1;
+	char *aln2;
+	int of1tmp, of2tmp;
+
+	if( fp == NULL )
+	{
+		fp = fopen( "_foldalignout", "r" );
+		if( fp == NULL )
+		{
+			fprintf( stderr, "Cannot open _foldalignout\n" );
+			exit( 1 );
+		}
+	}
+
+	aln1 = calloc( alloclen, sizeof( char ) );
+	aln2 = calloc( alloclen, sizeof( char ) );
+
+	readpairfoldalign( fp, *mseq1, *mseq2, aln1, aln2, m1, m2, &of1tmp, &of2tmp, alloclen );
+
+	if( strstr( foldalignopt, "-global") )
+	{
+		fprintf( stderr, "Calling G__align11\n" );
+		value = G__align11( mseq1, mseq2, alloclen );
+		*of1pt = 0;
+		*of2pt = 0;
+	}
+	else
+	{
+		fprintf( stderr, "Calling L__align11\n" );
+		value = L__align11( mseq1, mseq2, alloclen, of1pt, of2pt );
+	}
+
+//	value = (float)naivepairscore11( *mseq1, *mseq2, penalty ); // nennnotame
+
+	if( aln1[0] == 0 )
+	{
+		fprintf( stderr, "FOLDALIGN returned no alignment between %d and %d.  Sequence alignment is used instead.\n", m1+1, m2+1 );
+	}
+	else
+	{
+		strcpy( *mseq1, aln1 );
+		strcpy( *mseq2, aln2 );
+		*of1pt = of1tmp;
+		*of2pt = of2tmp;
+	}
+
+//	value = naivepairscore11( *mseq1, *mseq2, penalty ); // v6.511 ha kore wo tsukau, global nomi dakara.
+
+//	fclose( fp ); // saigo dake yatta houga yoi.
+
+//	fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
+//	fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
+
+
+	free( aln1 );
+	free( aln2 );
+
+	return( value );
+}
+
+static void callfoldalign( int nseq, char **mseq )
+{
+	FILE *fp;
+	int i;
+	int res;
+	static char com[10000];
+
+	for( i=0; i<nseq; i++ )
+		t2u( mseq[i] );
+
+	fp = fopen( "_foldalignin", "w" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _foldalignin\n" );
+		exit( 1 );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		fprintf( fp, ">%d\n", i+1 );
+		fprintf( fp, "%s\n", mseq[i] );
+	}
+	fclose( fp );
+
+	sprintf( com, "env PATH=%s  foldalign210 %s _foldalignin > _foldalignout ", whereispairalign, foldalignopt );
+	res = system( com );
+	if( res )
+	{
+		fprintf( stderr, "Error in foldalign\n" );
+		exit( 1 );
+	}
+
+}
+
+static void calllara( int nseq, char **mseq, char *laraarg )
+{
+	FILE *fp;
+	int i;
+	int res;
+	static char com[10000];
+
+	for( i=0; i<nseq; i++ )
+
+	fp = fopen( "_larain", "w" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _larain\n" );
+		exit( 1 );
+	}
+	for( i=0; i<nseq; i++ )
+	{
+		fprintf( fp, ">%d\n", i+1 );
+		fprintf( fp, "%s\n", mseq[i] );
+	}
+	fclose( fp );
+
+
+//	fprintf( stderr, "calling LaRA\n" );
+	sprintf( com, "env PATH=%s:/bin:/usr/bin mafft_lara -i _larain -w _laraout -o _lara.params %s", whereispairalign, laraarg );
+	res = system( com );
+	if( res )
+	{
+		fprintf( stderr, "Error in lara\n" );
+		exit( 1 );
+	}
+}
+
+static float recalllara( char **mseq1, char **mseq2, int alloclen )
+{
+	static FILE *fp = NULL;
+	static char *ungap1;
+	static char *ungap2;
+	static char *ori1;
+	static char *ori2;
+//	int res;
+	static char com[10000];
+	float value;
+
+
+	if( fp == NULL )
+	{
+		fp = fopen( "_laraout", "r" );
+		if( fp == NULL )
+		{
+			fprintf( stderr, "Cannot open _laraout\n" );
+			exit( 1 );
+		}
+		ungap1 = AllocateCharVec( alloclen );
+		ungap2 = AllocateCharVec( alloclen );
+		ori1 = AllocateCharVec( alloclen );
+		ori2 = AllocateCharVec( alloclen );
+	}
+
+
+	strcpy( ori1, *mseq1 );
+	strcpy( ori2, *mseq2 );
+
+	fgets( com, 999, fp );
+	myfgets( com, 9999, fp );
+	strcpy( *mseq1, com );
+	myfgets( com, 9999, fp );
+	strcpy( *mseq2, com );
+
+	gappick0( ungap1, *mseq1 );
+	gappick0( ungap2, *mseq2 );
+	t2u( ungap1 );
+	t2u( ungap2 );
+	t2u( ori1 );
+	t2u( ori2 );
+
+	if( strcmp( ungap1, ori1 ) || strcmp( ungap2, ori2 ) )
+	{
+		fprintf( stderr, "SEQUENCE CHANGED!!\n" );
+		fprintf( stderr, "*mseq1  = %s\n", *mseq1 );
+		fprintf( stderr, "ungap1  = %s\n", ungap1 );
+		fprintf( stderr, "ori1    = %s\n", ori1 );
+		fprintf( stderr, "*mseq2  = %s\n", *mseq2 );
+		fprintf( stderr, "ungap2  = %s\n", ungap2 );
+		fprintf( stderr, "ori2    = %s\n", ori2 );
+		exit( 1 );
+	}
+
+	value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
+
+//	fclose( fp ); // saigo dake yatta houga yoi.
+
+	return( value );
+}
+
+static float recallmxscarna( char **mseq1, char **mseq2, int m1, int m2, int alloclen )
+{
+	FILE *fp = NULL;
+	static char *ungap1 = NULL;
+	static char *ungap2 = NULL;
+	static char *ori1 = NULL;
+	static char *ori2 = NULL;
+//	int res;
+	static char com[10000];
+	float value;
+
+
+	if( ungap1 == NULL )
+	{
+		ungap1 = AllocateCharVec( alloclen );
+		ungap2 = AllocateCharVec( alloclen );
+		ori1 = AllocateCharVec( alloclen );
+		ori2 = AllocateCharVec( alloclen );
+	}
+
+	sprintf( com, "_%d-_%d.fasta", m1, m2 );
+	fp = fopen( com, "r" );
+	if( fp == NULL )
+	{
+		fprintf( stderr, "Cannot open %s.\n", com );
+		exit( 1 );
+	}
+
+	strcpy( ori1, *mseq1 );
+	strcpy( ori2, *mseq2 );
+
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq1 );
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq2 );
+
+	gappick0( ungap1, *mseq1 );
+	gappick0( ungap2, *mseq2 );
+	t2u( ungap1 );
+	t2u( ungap2 );
+	t2u( ori1 );
+	t2u( ori2 );
+
+	if( strcmp( ungap1, ori1 ) || strcmp( ungap2, ori2 ) )
+	{
+		fprintf( stderr, "SEQUENCE CHANGED!!\n" );
+		fprintf( stderr, "*mseq1  = %s\n", *mseq1 );
+		fprintf( stderr, "ungap1  = %s\n", ungap1 );
+		fprintf( stderr, "ori1    = %s\n", ori1 );
+		fprintf( stderr, "*mseq2  = %s\n", *mseq2 );
+		fprintf( stderr, "ungap2  = %s\n", ungap2 );
+		fprintf( stderr, "ori2    = %s\n", ori2 );
+		exit( 1 );
+	}
+
+	value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
+
+	fclose( fp );
+
+	return( value );
+}
+
+static float callmxscarna_giving_bpp( char **mseq1, char **mseq2, char **bpp1, char **bpp2, int alloclen )
+{
+	FILE *fp;
+	int res;
+	static char com[10000];
+	float value;
+
+	fp = fopen( "_bpporg", "w" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot write to _bpporg\n" );
+		exit( 1 );
+	}
+	fprintf( fp, ">a\n" );
+	while( *bpp1 )
+		fprintf( fp, *bpp1++ );
+
+	fprintf( fp, ">b\n" );
+	while( *bpp2 )
+		fprintf( fp, *bpp2++ );
+	fclose( fp );
+
+	system( "tr -d '\\r' < _bpporg > _bpp" ); // for cygwin, wakaran
+
+	t2u( *mseq1 );
+	t2u( *mseq2 );
+	fp = fopen( "_mxscarnainorg", "w" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _mxscarnainorg\n" );
+		exit( 1 );
+	}
+	fprintf( fp, ">1\n" );
+//	fprintf( fp, "%s\n", *mseq1 );
+	write1seq( fp, *mseq1 );
+	fprintf( fp, ">2\n" );
+//	fprintf( fp, "%s\n", *mseq2 );
+	write1seq( fp, *mseq2 );
+	fclose( fp );
+
+	system( "tr -d '\\r' < _mxscarnainorg > _mxscarnain" ); // for cygwin, wakaran
+
+	sprintf( com, "env PATH=%s mxscarnamod -readbpp _mxscarnain > _mxscarnaout 2>_dum", whereispairalign );
+	res = system( com );
+	if( res )
+	{
+		fprintf( stderr, "Error in mxscarna\n" );
+		exit( 1 );
+	}
+
+	fp = fopen( "_mxscarnaout", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _mxscarnaout\n" );
+		exit( 1 );
+	}
+
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq1 );
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq2 );
+
+	fclose( fp );
+
+//	fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
+//	fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
+
+	value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
+
+	return( value );
+}
+
+static float callmxscarna_slow( char **mseq1, char **mseq2, int alloclen )
+{
+	FILE *fp;
+	int res;
+	static char com[10000];
+	float value;
+
+
+	t2u( *mseq1 );
+	t2u( *mseq2 );
+	fp = fopen( "_mxscarnain", "w" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _mxscarnain\n" );
+		exit( 1 );
+	}
+	fprintf( fp, ">1\n" );
+	fprintf( fp, "%s\n", *mseq1 );
+	fprintf( fp, ">2\n" );
+	fprintf( fp, "%s\n", *mseq2 );
+	fclose( fp );
+
+	sprintf( com, "env PATH=%s mxscarnamod _mxscarnain > _mxscarnaout 2>_dum", whereispairalign );
+	res = system( com );
+	if( res )
+	{
+		fprintf( stderr, "Error in mxscarna\n" );
+		exit( 1 );
+	}
+
+	fp = fopen( "_mxscarnaout", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open _mxscarnaout\n" );
+		exit( 1 );
+	}
+
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq1 );
+	fgets( com, 999, fp );
+	load1SeqWithoutName_new( fp, *mseq2 );
+
+	fclose( fp );
+
+//	fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
+//	fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
+
+	value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
+
+	return( value );
+}
+
+static void readhat4( FILE *fp, char ***bpp )
+{
+	char oneline[1000];
+	int bppsize;
+	int onechar;
+//	double prob;
+//	int posi, posj;
+
+	bppsize = 0;
+//	fprintf( stderr, "reading hat4\n" );
+	onechar = getc(fp);
+//	fprintf( stderr, "onechar = %c\n", onechar );
+	if( onechar != '>' )
+	{
+		fprintf( stderr, "Format error\n" );
+		exit( 1 );
+	}
+	ungetc( onechar, fp );
+	fgets( oneline, 999, fp );
+	while( 1 )
+	{
+		onechar = getc(fp);
+		ungetc( onechar, fp );
+		if( onechar == '>' || onechar == EOF )
+		{
+//			fprintf( stderr, "Next\n" );
+			*bpp = realloc( *bpp, (bppsize+2) * sizeof( char * ) );
+			(*bpp)[bppsize] = NULL;
+			break;
+		}
+		fgets( oneline, 999, fp );
+//		fprintf( stderr, "oneline=%s\n", oneline );
+//		sscanf( oneline, "%d %d %f", &posi, &posj, &prob );
+//		fprintf( stderr, "%d %d -> %f\n", posi, posj, prob );
+		*bpp = realloc( *bpp, (bppsize+2) * sizeof( char * ) );
+		(*bpp)[bppsize] = calloc( 100, sizeof( char ) );
+		strcpy( (*bpp)[bppsize], oneline );
+		bppsize++;
+	}
+}
+
+static void preparebpp( int nseq, char ***bpp )
+{
+	FILE *fp;
+	int i;
+
+	fp = fopen( "hat4", "r" );
+	if( !fp )
+	{
+		fprintf( stderr, "Cannot open hat4\n" );
+		exit( 1 );
+	}
+	for( i=0; i<nseq; i++ )
+		readhat4( fp, bpp+i );
+	fclose( fp );
+}
+
+void arguments( int argc, char *argv[] )
+{
+    int c;
+
+	foldalignopt[0] = 0;
+	laraparams = NULL;
+	inputfile = NULL;
+	fftkeika = 0;
+	pslocal = -1000.0;
+	constraint = 0;
+	nblosum = 62;
+	fmodel = 0;
+	calledByXced = 0;
+	devide = 0;
+	use_fft = 0;
+	fftscore = 1;
+	fftRepeatStop = 0;
+	fftNoAnchStop = 0;
+    weight = 3;
+    utree = 1;
+	tbutree = 1;
+    refine = 0;
+    check = 1;
+    cut = 0.0;
+    disp = 0;
+    outgap = 1;
+    alg = 'A';
+    mix = 0;
+	tbitr = 0;
+	scmtd = 5;
+	tbweight = 0;
+	tbrweight = 3;
+	checkC = 0;
+	treemethod = 'x';
+	contin = 0;
+	scoremtx = 1;
+	kobetsubunkatsu = 0;
+	divpairscore = 0;
+	out_align_instead_of_hat3 = 0;
+	dorp = NOTSPECIFIED;
+	ppenalty = NOTSPECIFIED;
+	ppenalty_OP = NOTSPECIFIED;
+	ppenalty_ex = NOTSPECIFIED;
+	ppenalty_EX = NOTSPECIFIED;
+	poffset = NOTSPECIFIED;
+	kimuraR = NOTSPECIFIED;
+	pamN = NOTSPECIFIED;
+	geta2 = GETA2;
+	fftWinSize = NOTSPECIFIED;
+	fftThreshold = NOTSPECIFIED;
+	RNAppenalty = NOTSPECIFIED;
+	RNApthr = NOTSPECIFIED;
+
+    while( --argc > 0 && (*++argv)[0] == '-' )
+	{
+        while ( ( c = *++argv[0] ) )
+		{
+            switch( c )
+            {
+				case 'i':
+					inputfile = *++argv;
+					fprintf( stderr, "inputfile = %s\n", inputfile );
+					--argc;
+					goto nextoption;
+				case 'f':
+					ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
+					--argc;
+					goto nextoption;
+				case 'g':
+					ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
+					--argc;
+					goto nextoption;
+				case 'O':
+					ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
+					--argc;
+					goto nextoption;
+				case 'E':
+					ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
+					--argc;
+					goto nextoption;
+				case 'h':
+					poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
+					--argc;
+					goto nextoption;
+				case 'k':
+					kimuraR = atoi( *++argv );
+//					fprintf( stderr, "kimuraR = %d\n", kimuraR );
+					--argc;
+					goto nextoption;
+				case 'b':
+					nblosum = atoi( *++argv );
+					scoremtx = 1;
+//					fprintf( stderr, "blosum %d\n", nblosum );
+					--argc;
+					goto nextoption;
+				case 'j':
+					pamN = atoi( *++argv );
+					scoremtx = 0;
+					TMorJTT = JTT;
+					fprintf( stderr, "jtt %d\n", pamN );
+					--argc;
+					goto nextoption;
+				case 'm':
+					pamN = atoi( *++argv );
+					scoremtx = 0;
+					TMorJTT = TM;
+					fprintf( stderr, "TM %d\n", pamN );
+					--argc;
+					goto nextoption;
+				case 'l':
+					ppslocal = (int)( atof( *++argv ) * 1000 + 0.5 );
+					pslocal = (int)( 600.0 / 1000.0 * ppslocal + 0.5);
+//					fprintf( stderr, "ppslocal = %d\n", ppslocal );
+//					fprintf( stderr, "pslocal = %d\n", pslocal );
+					--argc;
+					goto nextoption;
+				case 'd':
+					whereispairalign = *++argv;
+					fprintf( stderr, "whereispairalign = %s\n", whereispairalign );
+					--argc; 
+					goto nextoption;
+				case 'p':
+					laraparams = *++argv;
+					fprintf( stderr, "laraparams = %s\n", laraparams );
+					--argc; 
+					goto nextoption;
+				case 'n':
+					out_align_instead_of_hat3 = 1;
+					break;
+#if 1
+				case 'a':
+					fmodel = 1;
+					break;
+#endif
+				case 'r':
+					fmodel = -1;
+					break;
+				case 'D':
+					dorp = 'd';
+					break;
+				case 'P':
+					dorp = 'p';
+					break;
+				case 'e':
+					fftscore = 0;
+					break;
+#if 0
+				case 'O':
+					fftNoAnchStop = 1;
+					break;
+#endif
+				case 'Q':
+					calledByXced = 1;
+					break;
+				case 'x':
+					disp = 1;
+					break;
+#if 0
+				case 'a':
+					alg = 'a';
+					break;
+#endif
+				case 'S':
+					alg = 'S';
+					break;
+				case 't':
+					alg = 't';
+					break;
+				case 'L':
+					alg = 'L';
+					break;
+				case 's':
+					alg = 's';
+					break;
+				case 'B':
+					alg = 'B';
+					break;
+				case 'T':
+					alg = 'T';
+					break;
+				case 'H':
+					alg = 'H';
+					break;
+				case 'M':
+					alg = 'M';
+					break;
+				case 'R':
+					alg = 'R';
+					break;
+				case 'N':
+					alg = 'N';
+					break;
+				case 'K':
+					alg = 'K';
+					break;
+				case 'A':
+					alg = 'A';
+					break;
+				case 'V':
+					alg = 'V';
+					break;
+				case 'C':
+					alg = 'C';
+					break;
+				case 'F':
+					use_fft = 1;
+					break;
+				case 'v':
+					tbrweight = 3;
+					break;
+				case 'y':
+					divpairscore = 1;
+					break;
+/* Modified 01/08/27, default: user tree */
+				case 'J':
+					tbutree = 0;
+					break;
+/* modification end. */
+				case 'o':
+//					foldalignopt = *++argv;
+					strcat( foldalignopt, " " );
+					strcat( foldalignopt, *++argv );
+					fprintf( stderr, "foldalignopt = %s\n", foldalignopt );
+					--argc; 
+					goto nextoption;
+				case 'z':
+					fftThreshold = atoi( *++argv );
+					--argc; 
+					goto nextoption;
+				case 'w':
+					fftWinSize = atoi( *++argv );
+					--argc;
+					goto nextoption;
+				case 'Z':
+					checkC = 1;
+					break;
+                default:
+                    fprintf( stderr, "illegal option %c\n", c );
+                    argc = 0;
+                    break;
+            }
+		}
+		nextoption:
+			;
+	}
+    if( argc == 1 )
+    {
+        cut = atof( (*argv) );
+        argc--;
+    }
+    if( argc != 0 ) 
+    {
+        fprintf( stderr, "options: Check source file !\n" );
+        exit( 1 );
+    }
+	if( tbitr == 1 && outgap == 0 )
+	{
+		fprintf( stderr, "conflicting options : o, m or u\n" );
+		exit( 1 );
+	}
+	if( alg == 'C' && outgap == 0 )
+	{
+		fprintf( stderr, "conflicting options : C, o\n" );
+		exit( 1 );
+	}
+}
+
+int countamino( char *s, int end )
+{
+	int val = 0;
+	while( end-- )
+		if( *s++ != '-' ) val++;
+	return( val );
+}
+
+static void pairalign( char name[M][B], int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double *effarr, int alloclen )
+{
+	int i, j, ilim;
+	int clus1, clus2;
+	int off1, off2;
+	float pscore = 0.0; // by D.Mathog
+	static char *indication1, *indication2;
+	FILE *hat2p, *hat3p;
+	static double **distancemtx;
+	static double *effarr1 = NULL;
+	static double *effarr2 = NULL;
+	char *pt;
+	char *hat2file = "hat2";
+	LocalHom **localhomtable, *tmpptr;
+	static char **pair;
+	int intdum;
+	double bunbo;
+	char ***bpp; // mxscarna no toki dake
+
+	localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
+	for( i=0; i<njob; i++)
+	{
+		localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
+		for( j=0; j<njob; j++)
+		{
+			localhomtable[i][j].start1 = -1;
+			localhomtable[i][j].end1 = -1;
+			localhomtable[i][j].start2 = -1; 
+			localhomtable[i][j].end2 = -1; 
+			localhomtable[i][j].opt = -1.0;
+			localhomtable[i][j].next = NULL;
+			localhomtable[i][j].nokori = 0;
+		}
+	}
+
+	if( effarr1 == NULL ) 
+	{
+		distancemtx = AllocateDoubleMtx( njob, njob );
+		effarr1 = AllocateDoubleVec( njob );
+		effarr2 = AllocateDoubleVec( njob );
+		indication1 = AllocateCharVec( 150 );
+		indication2 = AllocateCharVec( 150 );
+#if 0
+#else
+		pair = AllocateCharMtx( njob, njob );
+#endif
+	}
+
+#if 0
+	fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold );
+#endif
+
+#if 0
+	for( i=0; i<njob; i++ )
+		fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] );
+#endif
+
+
+//	writePre( njob, name, nlen, aseq, 0 );
+
+	for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0;
+	for( i=0; i<njob; i++ ) pair[i][i] = 1;
+
+	if( alg == 'H' )
+	{
+		fprintf( stderr, "Calling FOLDALIGN with option '%s'\n", foldalignopt );
+		callfoldalign( njob, seq );
+		fprintf( stderr, "done.\n" );
+	}
+	if( alg == 'B' )
+	{
+		fprintf( stderr, "Running LARA (Bauer et al. http://www.planet-lisa.net/)\n" );
+		calllara( njob, seq, "" );
+		fprintf( stderr, "done.\n" );
+	}
+	if( alg == 'T' )
+	{
+		fprintf( stderr, "Running SLARA (Bauer et al. http://www.planet-lisa.net/)\n" );
+		calllara( njob, seq, "-s" );
+		fprintf( stderr, "done.\n" );
+	}
+	if( alg == 's' )
+	{
+		fprintf( stderr, "Preparing bpp\n" );
+//		bpp = AllocateCharCub( njob, nlenmax, 0 );
+		bpp = calloc( njob, sizeof( char ** ) );
+		preparebpp( njob, bpp );
+		fprintf( stderr, "done.\n" );
+		fprintf( stderr, "Running MXSCARNA (Tabei et al. http://www.ncrna.org/software/mxscarna)\n" );
+	}
+
+	ilim = njob - 1;
+	for( i=0; i<ilim; i++ ) 
+	{
+		fprintf( stderr, "% 5d / %d\r", i, njob );
+		for( j=i+1; j<njob; j++ )
+		{
+
+			if( strlen( seq[i] ) == 0 || strlen( seq[j] ) == 0 )
+			{
+				distancemtx[i][j] = NODIST;
+				continue;
+			}
+
+			strcpy( aseq[i], seq[i] );
+			strcpy( aseq[j], seq[j] );
+			clus1 = conjuctionfortbfast( pair, i, aseq, mseq1, effarr1, effarr, indication1 );
+			clus2 = conjuctionfortbfast( pair, j, aseq, mseq2, effarr2, effarr, indication2 );
+	//		fprintf( stderr, "mseq1 = %s\n", mseq1[0] );
+	//		fprintf( stderr, "mseq2 = %s\n", mseq2[0] );
+	
+#if 0
+			fprintf( stderr, "group1 = %.66s", indication1 );
+			fprintf( stderr, "\n" );
+			fprintf( stderr, "group2 = %.66s", indication2 );
+			fprintf( stderr, "\n" );
+#endif
+	//		for( l=0; l<clus1; l++ ) fprintf( stderr, "## STEP-eff for mseq1-%d %f\n", l, effarr1[l] );
+	
+#if 1
+			if( use_fft )
+			{
+				pscore = Falign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, &intdum );
+//				fprintf( stderr, "pscore (fft) = %f\n", pscore );
+				off1 = off2 = 0;
+			}
+			else
+#endif
+			{
+				switch( alg )
+				{
+					case( 'a' ):
+						pscore = Aalign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen );
+						off1 = off2 = 0;
+						break;
+					case( 't' ):
+						pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
+						off1 = off2 = 0;
+						break;
+					case( 'A' ):
+						pscore = G__align11( mseq1, mseq2, alloclen );
+						off1 = off2 = 0;
+						break;
+#if 0
+					case( 'V' ):
+						pscore = VAalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j );
+						fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore );
+						break;
+					case( 'S' ):
+						fprintf( stderr, "aligning %d-%d\n", i, j );
+						pscore = suboptalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j );
+						fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore );
+						break;
+#endif
+					case( 'N' ):
+						pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
+						genL__align11( mseq1, mseq2, alloclen, &off1, &off2 );
+//						fprintf( stderr, "pscore = %f\n", pscore );
+						break;
+					case( 'K' ):
+						pscore = genG__align11( mseq1, mseq2, alloclen );
+						off1 = off2 = 0;
+						break;
+					case( 'L' ):
+						pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
+						L__align11( mseq1, mseq2, alloclen, &off1, &off2 );
+//						fprintf( stderr, "pscore (1) = %f\n", pscore );
+//						pscore = (float)naivepairscore11( *mseq1, *mseq2, penalty ); // nennnotame
+//						fprintf( stderr, "pscore (2) = %f\n\n", pscore );
+						break;
+					case( 'H' ):
+						pscore = recallpairfoldalign( mseq1, mseq2, i, j, &off1, &off2, alloclen );
+						break;
+					case( 'B' ):
+					case( 'T' ):
+						pscore = recalllara( mseq1, mseq2, alloclen );
+						off1 = off2 = 0;
+//						fprintf( stderr, "lara, pscore = %f\n", pscore );
+						break;
+					case( 's' ):
+						pscore = callmxscarna_giving_bpp( mseq1, mseq2, bpp[i], bpp[j], alloclen );
+//						pscore = G__align11_noalign( amino_disLN, -1200, -60, mseq1, mseq2, alloclen );
+						off1 = off2 = 0;
+//						fprintf( stderr, "scarna, pscore = %f\n", pscore );
+						break;
+					case( 'M' ):
+//						pscore = MSalign11( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL );
+						pscore = MSalign11( mseq1, mseq2, alloclen );
+//						fprintf( stderr, "pscore (M)= %f\n", pscore );
+						break;
+						ErrorExit( "ERROR IN SOURCE FILE" );
+				}
+			}
+			if( alg == 't' || ( mseq1[0][0] != 0 && mseq2[0][0] != 0  ) ) // 't' no jouken ha iranai to omou. if( ( mseq1[0][0] != 0 && mseq2[0][0] != 0  ) )
+			{
+				distancemtx[i][j] = pscore;
+#if SCOREOUT
+				fprintf( stderr, "score = %10.2f (%d,%d)\n", pscore, i, j );
+#endif
+//				fprintf( stderr, "pslocal = %d\n", pslocal );
+//				offset = makelocal( *mseq1, *mseq2, pslocal );
+#if 0
+				fprintf( stderr, "off1 = %d, off2 = %d\n", off1, off2 );
+#endif
+
+				if( alg == 't' || out_align_instead_of_hat3 == 1 )
+					;
+				else if( alg == 'H' )
+					putlocalhom_ext( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) );
+				else if( alg != 'S' && alg != 'V' )
+					putlocalhom2( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) );
+			}
+			else
+			{
+				distancemtx[i][j] = NODIST;
+			}
+
+			if( out_align_instead_of_hat3 && alg != 't' )
+			{
+				fprintf( stdout, "sequence %d - sequence %d, pairwise score = %.0f\n", i+1, j+1, pscore );
+				fprintf( stdout, ">%s\n", name[i] );
+				write1seq( stdout, mseq1[0] );
+				fprintf( stdout, ">%s\n", name[j] );
+				write1seq( stdout, mseq2[0] );
+				fprintf( stdout, "\n" );
+			}
+		}
+	}
+	for( i=0; i<njob; i++ )
+	{
+		pscore = 0.0;
+		for( pt=seq[i]; *pt; pt++ )
+			pscore += amino_dis[(int)*pt][(int)*pt];
+		distancemtx[i][i] = pscore;
+
+	}
+
+	ilim = njob-1;	
+	for( i=0; i<ilim; i++ )
+	{
+		for( j=i+1; j<njob; j++ )
+		{
+
+#if 0
+			fprintf( stdout, "distancemtx[i][j] = %f\n", distancemtx[i][j] );
+			fprintf( stdout, "distancemtx[i][i] = %f\n", distancemtx[i][i] );
+			fprintf( stdout, "distancemtx[j][j] = %f\n", distancemtx[j][j] );
+			fprintf( stdout, "bunbo = %f\n", MIN( distancemtx[i][i], distancemtx[j][j] ) );
+#endif
+			if( distancemtx[i][j] == NODIST || (bunbo=MIN( distancemtx[i][i], distancemtx[j][j] )) == 0.0 || bunbo < distancemtx[i][j] )
+				distancemtx[i][j] = 2.0;
+			else
+				distancemtx[i][j] = ( 1.0 - distancemtx[i][j] / bunbo ) * 2.0;
+#if 0
+			fprintf( stdout, "distancemtx[i][j] => %f\n", distancemtx[i][j] );
+#endif
+		}
+	}
+
+	hat2p = fopen( hat2file, "w" );
+	if( !hat2p ) ErrorExit( "Cannot open hat2." );
+	if( out_align_instead_of_hat3 == 0 )
+		WriteHat2( hat2p, njob, name, distancemtx );
+	else
+		WriteHat2plain( hat2p, njob, distancemtx );
+	fclose( hat2p );
+
+	if( out_align_instead_of_hat3 == 0 )
+	{
+		fprintf( stderr, "##### writing hat3\n" );
+#ifndef LLVM
+		hat3p = fopen( "hat3", "w" );
+		if( !hat3p ) ErrorExit( "Cannot open hat3." );
+#endif
+		ilim = njob-1;	
+		for( i=0; i<ilim; i++ ) 
+		{
+			for( j=i+1; j<njob; j++ )
+			{
+				for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
+				{
+					if( tmpptr->opt == -1.0 ) continue;
+// tmptmptmptmptmp
+//					if( alg == 'B' || alg == 'T' )
+//						fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, 1.0, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next ); 
+//					else
+#ifdef LLVM
+						fprintf( stdout, "%d %d %d %7.5f %d %d %d %d\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2 ); 
+#else
+						fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next ); 
+#endif
+				}
+			}
+		}
+#ifndef LLVM
+		fclose( hat3p );
+#endif
+	}
+#if DEBUG
+	fprintf( stderr, "calling FreeLocalHomTable\n" );
+#endif
+	FreeLocalHomTable( localhomtable, njob );
+#if DEBUG
+	fprintf( stderr, "done. FreeLocalHomTable\n" );
+#endif
+
+	if( alg == 's' )
+	{
+		char **ptpt;
+		for( i=0; i<njob; i++ )
+		{
+			ptpt = bpp[i];
+			while( 1 )
+			{
+				if( *ptpt ) free( *ptpt );
+				else break;
+				ptpt++;
+			}
+			free( bpp[i] );
+		}
+	free( bpp );
+	}
+}
+
+static void WriteOptions( FILE *fp )
+{
+
+	if( dorp == 'd' ) fprintf( fp, "DNA\n" );
+	else
+	{
+		if     ( scoremtx ==  0 ) fprintf( fp, "JTT %dPAM\n", pamN );
+		else if( scoremtx ==  1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
+		else if( scoremtx ==  2 ) fprintf( fp, "M-Y\n" );
+	}
+    fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
+    if( use_fft ) fprintf( fp, "FFT on\n" );
+
+	fprintf( fp, "tree-base method\n" );
+	if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
+	else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
+	if( tbitr || tbweight ) 
+	{
+		fprintf( fp, "iterate at each step\n" );
+		if( tbitr && tbrweight == 0 ) fprintf( fp, "  unweighted\n" ); 
+		if( tbitr && tbrweight == 3 ) fprintf( fp, "  reversely weighted\n" ); 
+		if( tbweight ) fprintf( fp, "  weighted\n" ); 
+		fprintf( fp, "\n" );
+	}
+
+   	 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
+
+	if( alg == 'a' )
+		fprintf( fp, "Algorithm A\n" );
+	else if( alg == 'A' ) 
+		fprintf( fp, "Algorithm A+\n" );
+	else if( alg == 'S' ) 
+		fprintf( fp, "Apgorithm S\n" );
+	else if( alg == 'C' ) 
+		fprintf( fp, "Apgorithm A+/C\n" );
+	else
+		fprintf( fp, "Unknown algorithm\n" );
+
+    if( use_fft )
+    {
+        fprintf( fp, "FFT on\n" );
+        if( dorp == 'd' )
+            fprintf( fp, "Basis : 4 nucleotides\n" );
+        else
+        {
+            if( fftscore )
+                fprintf( fp, "Basis : Polarity and Volume\n" );
+            else
+                fprintf( fp, "Basis : 20 amino acids\n" );
+        }
+        fprintf( fp, "Threshold   of anchors = %d%%\n", fftThreshold );
+        fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
+    }
+	else
+        fprintf( fp, "FFT off\n" );
+	fflush( fp );
+}
+	 
+
+int main( int argc, char *argv[] )
+{
+	static int  nlen[M];	
+	static char name[M][B], **seq;
+	static char **mseq1, **mseq2;
+	static char **aseq;
+	static char **bseq;
+	static double *eff;
+	int i;
+	FILE *infp;
+	char c;
+	int alloclen;
+
+	arguments( argc, argv );
+
+	if( inputfile )
+	{
+		infp = fopen( inputfile, "r" );
+		if( !infp )
+		{
+			fprintf( stderr, "Cannot open %s\n", inputfile );
+			exit( 1 );
+		}
+	}
+	else
+		infp = stdin;
+
+	getnumlen( infp );
+	rewind( infp );
+
+	if( njob < 2 )
+	{
+		fprintf( stderr, "At least 2 sequences should be input!\n"
+						 "Only %d sequence found.\n", njob ); 
+		exit( 1 );
+	}
+	if( njob > M )
+	{
+		fprintf( stderr, "The number of sequences must be < %d\n", M );
+		fprintf( stderr, "Please try the splittbfast program for such large data.\n" );
+		exit( 1 );
+	}
+
+	seq = AllocateCharMtx( njob, nlenmax*9+1 );
+	aseq = AllocateCharMtx( njob, nlenmax*9+1 );
+	bseq = AllocateCharMtx( njob, nlenmax*9+1 );
+	mseq1 = AllocateCharMtx( njob, 0 );
+	mseq2 = AllocateCharMtx( njob, 0 );
+	alloclen = nlenmax*9;
+
+	eff = AllocateDoubleVec( njob );
+
+#if 0
+	Read( name, nlen, seq );
+#else
+	readData( infp, name, nlen, seq );
+#endif
+	fclose( infp );
+
+	constants( njob, seq );
+
+#if 0
+	fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
+#endif
+
+	initSignalSM();
+
+	initFiles();
+
+	WriteOptions( trap_g );
+
+	c = seqcheck( seq );
+	if( c )
+	{
+		fprintf( stderr, "Illegal character %c\n", c );
+		exit( 1 );
+	}
+
+//	writePre( njob, name, nlen, seq, 0 );
+
+	for( i=0; i<njob; i++ ) eff[i] = 1.0;
+
+
+	for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
+
+	pairalign( name, nlen, bseq, aseq, mseq1, mseq2, eff, alloclen );
+
+	fprintf( trap_g, "done.\n" );
+#if DEBUG
+	fprintf( stderr, "closing trap_g\n" );
+#endif
+	fclose( trap_g );
+
+//	writePre( njob, name, nlen, aseq, !contin );
+#if 0
+	writeData( stdout, njob, name, nlen, aseq );
+#endif
+#if IODEBUG
+	fprintf( stderr, "OSHIMAI\n" );
+#endif
+	SHOWVERSION;
+	return( 0 );
+}

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/partQalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/partQalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/partQalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/partQalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1258 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+
+static int impalloclen = 0;
+static float **impmtx = NULL;
+float part_imp_match_out_scQ( int i1, int j1 )
+{
+//	fprintf( stderr, "impalloclen = %d\n", impalloclen );
+//	fprintf( stderr, "i1,j1=%d,%d -> impmtx=%f\n", i1, j1, impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+#if 0
+	if( i1 == l1 || j1 == l2 ) return( 0.0 );
+	return( impmtx[i1+start1][j1+start2] );
+#endif
+}
+static void part_imp_match_out_vead_gapmapQ( float *imp, int i1, int lgth2, int start2, int *gapmap2 )
+{
+#if FASTMACHCALC
+	float *pt = imp;
+	int *gapmappt = gapmap2;
+	while( lgth2-- )
+		*pt++ += impmtx[i1][start2+*gapmappt++];
+#else
+	int j;
+	for( j=0; j<lgth2; j++ )
+	{
+		imp[j] += impmtx[i1][start2+gapmap2[j]];
+	}
+#endif
+}
+
+static void part_imp_match_out_vead_tate_gapmapQ( float *imp, int j1, int lgth1, int start1, int *gapmap1 )
+{
+#if FASTMACHCALC
+	float *pt = imp;
+	int *gapmappt = gapmap1;
+	while( lgth1-- )
+		*pt++ = impmtx[start1+*gapmappt++][j1];
+#else
+	int i;
+	for( i=0; i<lgth1; i++ )
+	{
+		imp[i] += impmtx[start1+gapmap1[i]][j1];
+	}
+#endif
+}
+
+void part_imp_match_init_strictQ( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	double effij, effijx; 
+	char *pt, *pt1, *pt2;
+	LocalHom *tmpptr;
+
+	if( impalloclen <= lgth1 + 2 || impalloclen <= lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen+100, impalloclen+100 );
+	}
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx = 1.0 * fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = eff1[i] * eff2[j] * effijx;
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = (int)( pt - seq1[i] ) - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = (int)( pt - seq1[i] ) - 1;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = (int)( pt - seq1[i] ) - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = (int)( pt - seq2[j] ) - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = (int)( pt - seq2[j] ) - 1;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = (int)( pt - seq2[j] ) - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "k1=%d, k2=%d, impalloclen=%d\n", k1, k2, impalloclen );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+#if 0
+	fprintf( stderr, "impmtx = \n" );
+	for( k2=0; k2<lgth2; k2++ )
+		fprintf( stderr, "%6.3f ", (double)k2 );
+	fprintf( stderr, "\n" );
+	for( k1=0; k1<lgth1; k1++ )
+	{
+		fprintf( stderr, "%d", k1 );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+		fprintf( stderr, "\n" );
+	}
+	exit( 1 );
+#endif
+}
+
+
+void part_imp_rnaQ( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, int *gapmap1, int *gapmap2, RNApair *additionalpair )
+{
+	foldrna( nseq1, nseq2, seq1, seq2, eff1, eff2, grouprna1, grouprna2, impmtx, gapmap1, gapmap2, additionalpair );
+}
+
+
+void part_imp_match_initQ( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom )
+{
+	int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	static int impalloclen = 0;
+	char *pt;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+
+	if( impalloclen < lgth1 || impalloclen < lgth2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+		impalloclen -= 2;
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	for( i=0; i<clus1; i++ )
+	{
+		fprintf( stderr, "i = %d, seq1 = %s\n", i, seq1[i] );
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stderr, "start1 = %d\n", localhom[i][j]->start1 );
+			fprintf( stderr, "end1   = %d\n", localhom[i][j]->end1   );
+			fprintf( stderr, "j = %d, seq2 = %s\n", j, seq2[j] );
+			pt = seq1[i];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start1 ) break;
+			}
+			start1 = pt - seq1[i] - 1;
+
+			while( *pt != 0 )
+			{
+//				fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, localhom[i][j].end1, pt-seq1[i] );
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end1 ) break;
+			}
+			end1 = pt - seq1[i] - 1;
+
+			pt = seq2[j];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start2 ) break;
+			}
+			start2 = pt - seq2[j] - 1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end2 ) break;
+			}
+			end2 = pt - seq2[j] - 1;
+//			fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+			k1 = start1;
+			k2 = start2;
+			fprintf( stderr, "step 0\n" );
+			while( k1 <= end1 && k2 <= end2 )
+			{
+#if 0
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j].wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#else
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j]->wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#endif
+			}
+
+			dif = ( end1 - start1 ) - ( end2 - start2 );
+			fprintf( stderr, "dif = %d\n", dif );
+			if( dif > 0 )
+			{
+				do
+				{
+					fprintf( stderr, "dif = %d\n", dif );
+					k1 = start1;
+					k2 = start2 - dif;
+					while( k1 <= end1 && k2 <= end2 )
+					{
+						if( 0 <= k2 && start2 <= k2 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif-- );
+			}
+			else
+			{
+				do
+				{
+					k1 = start1 + dif;
+					k2 = start2;
+					while( k1 <= end1 )
+					{
+						if( k1 >= 0 && k1 >= start1 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif++ );
+			}
+		}
+	}
+#if 0
+	fprintf( stderr, "impmtx = \n" );
+	for( k2=0; k2<lgth2; k2++ )
+		fprintf( stderr, "%6.3f ", (double)k2 );
+	fprintf( stderr, "\n" );
+	for( k1=0; k1<lgth1; k1++ )
+	{
+		fprintf( stderr, "%d", k1 );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", impmtx[k1][k2] );
+		fprintf( stderr, "\n" );
+	}
+	exit( 1 );
+#endif
+}
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+//				scarr[l] += n_dis[j][l] * cpmx1[j][i1];
+				scarr[l] += n_dis_consweight_multi[j][l] * cpmx1[j][i1];
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+//			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+			scarr[l] += n_dis_consweight_multi[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc,
+						int start1, int end1, int start2, int end2,
+						int *gapmap1, int *gapmap2 )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	char gap[] = "-";
+	float wm;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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][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][jfi+l];
+			k++;
+		}
+		if( iin != lgth1 && jin != lgth2 ) // ??
+		{
+			*impwmpt += part_imp_match_out_scQ( gapmap1[iin]+start1, gapmap2[jin]+start2 );
+//			fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+}
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, lastk;
+	char gap[] = "-";
+	float wm = 0.0;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	lastk = lgth1+lgth2;
+	for( k=0; k<=lastk; 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][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][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+float partQ__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *digf1; 
+	static float *digf2; 
+	static float *diaf1; 
+	static float *diaf2; 
+	static float *gapz1; 
+	static float *gapz2; 
+	static float *gapf1; 
+	static float *gapf2; 
+	static float *ogcp1g;
+	static float *ogcp2g;
+	static float *fgcp1g;
+	static float *fgcp2g;
+	static float *og_h_dg_n1_p;
+	static float *og_h_dg_n2_p;
+	static float *fg_h_dg_n1_p;
+	static float *fg_h_dg_n2_p;
+	static float *og_t_fg_h_dg_n1_p;
+	static float *og_t_fg_h_dg_n2_p;
+	static float *fg_t_og_h_dg_n1_p;
+	static float *fg_t_og_h_dg_n2_p;
+	static float *gapz_n1;
+	static float *gapz_n2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+	float tmppenal;
+	float *fg_t_og_h_dg_n2_p_pt;
+	float *og_t_fg_h_dg_n2_p_pt;
+	float *og_h_dg_n2_p_pt;
+	float *fg_h_dg_n2_p_pt;
+	float *gapz_n2_pt0;
+	float *gapz_n2_pt1;
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fg_t_og_h_dg_n1_p_va;
+	float og_t_fg_h_dg_n1_p_va;
+	float og_h_dg_n1_p_va;
+	float fg_h_dg_n1_p_va;
+	float gapz_n1_va0;
+	float gapz_n1_va1;
+	float fgcp1va;
+	float ogcp1va;
+
+
+
+#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
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( digf1 );
+			FreeFloatVec( digf2 );
+			FreeFloatVec( diaf1 );
+			FreeFloatVec( diaf2 );
+			FreeFloatVec( gapz1 );
+			FreeFloatVec( gapz2 );
+			FreeFloatVec( gapf1 );
+			FreeFloatVec( gapf2 );
+			FreeFloatVec( ogcp1g );
+			FreeFloatVec( ogcp2g );
+			FreeFloatVec( fgcp1g );
+			FreeFloatVec( fgcp2g );
+			FreeFloatVec( og_h_dg_n1_p );
+			FreeFloatVec( og_h_dg_n2_p );
+			FreeFloatVec( fg_h_dg_n1_p );
+			FreeFloatVec( fg_h_dg_n2_p );
+			FreeFloatVec( og_t_fg_h_dg_n1_p );
+			FreeFloatVec( og_t_fg_h_dg_n2_p );
+			FreeFloatVec( fg_t_og_h_dg_n1_p );
+			FreeFloatVec( fg_t_og_h_dg_n2_p );
+			FreeFloatVec( gapz_n1 );
+			FreeFloatVec( gapz_n2 );
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		digf1 = AllocateFloatVec( ll1+2 );
+		digf2 = AllocateFloatVec( ll2+2 );
+		diaf1 = AllocateFloatVec( ll1+2 );
+		diaf2 = AllocateFloatVec( ll2+2 );
+		gapz1 = AllocateFloatVec( ll1+2 );
+		gapz2 = AllocateFloatVec( ll2+2 );
+		gapf1 = AllocateFloatVec( ll1+2 );
+		gapf2 = AllocateFloatVec( ll2+2 );
+		ogcp1g = AllocateFloatVec( ll1+2 );
+		ogcp2g = AllocateFloatVec( ll2+2 );
+		fgcp1g = AllocateFloatVec( ll1+2 );
+		fgcp2g = AllocateFloatVec( ll2+2 );
+		og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		og_t_fg_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		og_t_fg_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		fg_t_og_h_dg_n1_p = AllocateFloatVec( ll1 + 2 );
+		fg_t_og_h_dg_n2_p = AllocateFloatVec( ll2 + 2 );
+		gapz_n1 = AllocateFloatVec( ll1+2 );
+		gapz_n2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 26 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ ) mseq1[i] = mseq[i];
+	for( j=0; j<jcyc; j++ ) mseq2[j] = mseq[icyc+j];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 );
+		getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure_part( gapz1, icyc, seq1, eff1, lgth1, sgap1 );
+		getgapfreq_zure_part( gapz2, jcyc, seq2, eff2, lgth2, sgap1 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
+		getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
+		getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
+		getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
+		getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
+		getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
+		getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
+		getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
+	}
+
+#if 1
+	lastj = lgth2+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n2_p[i] = ( 1.0-ogcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		fg_h_dg_n2_p[i] = ( 1.0-fgcp2g[i]-digf2[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n2_p[i] = (1.0-ogcp2g[i]+fgcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n2_p[i] = (1.0-fgcp2g[i]+ogcp2g[i]-digf2[i]) * 0.5 * fpenalty;
+		gapz_n2[i] = (1.0-gapz2[i]);
+	}
+	lastj = lgth1+2;
+	for( i=0; i<lastj; i++ )
+	{
+		og_h_dg_n1_p[i] = ( 1.0-ogcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		fg_h_dg_n1_p[i] = ( 1.0-fgcp1g[i]-digf1[i] ) * fpenalty * 0.5;
+		og_t_fg_h_dg_n1_p[i] = (1.0-ogcp1g[i]+fgcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		fg_t_og_h_dg_n1_p[i] = (1.0-fgcp1g[i]+ogcp1g[i]-digf1[i]) * 0.5 * fpenalty;
+		gapz_n1[i] = (1.0-gapz1[i]);
+	}
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		part_imp_match_out_vead_tate_gapmapQ( initverticalw, gapmap2[0]+start2, lgth1, start1, gapmap1 );
+
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		part_imp_match_out_vead_gapmapQ( currentw, gapmap1[0]+start1, lgth2, start2, gapmap2 );
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+	if( outgap == 1 )
+	{
+		g = 0.0;
+
+		g += ogcp1g[0] * og_h_dg_n2_p[0];
+
+		g += ogcp2g[0] * og_h_dg_n1_p[0];
+
+		g += fgcp1g[0] * fg_h_dg_n2_p[0];
+
+		g += fgcp2g[0] * fg_h_dg_n1_p[0];
+
+		initverticalw[0] += g;
+		currentw[0] += g;
+
+		for( i=1; i<lgth1+1; i++ )
+		{
+			tmppenal = gapz_n2[0]*og_t_fg_h_dg_n1_p[0];
+			initverticalw[i] += tmppenal;
+
+			tmppenal = gapz_n2[1]*fg_t_og_h_dg_n1_p[i];
+			initverticalw[i] += tmppenal;
+
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			tmppenal = gapz_n1[0]*og_t_fg_h_dg_n2_p[0];
+			currentw[j] += tmppenal;
+
+			tmppenal = gapz_n1[1]*fg_t_og_h_dg_n2_p[j];
+			currentw[j] += tmppenal;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+				currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	m[0] = 0.0; // iranai
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		mp[j] = 0;
+		m[j] = currentw[j-1] + 10000 * fpenalty; //iinoka?
+	}
+	if( lgth2 == 0 )
+		lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
+	else
+		lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+	lastj = lgth2+1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+//			imp_match_out_vead( currentw, i, lgth2 );
+			part_imp_match_out_vead_gapmapQ( currentw, gapmap1[i]+start1, lgth2, start2, gapmap2 );
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+		mpi = 0;
+		mi = previousw[0] + 10000 * fpenalty;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fg_t_og_h_dg_n2_p_pt = fg_t_og_h_dg_n2_p + 1;
+		og_t_fg_h_dg_n2_p_pt = og_t_fg_h_dg_n2_p + 1;
+		og_h_dg_n2_p_pt = og_h_dg_n2_p + 1;
+		fg_h_dg_n2_p_pt = fg_h_dg_n2_p + 1;
+		gapz_n2_pt0 = gapz_n2 + 1;
+		gapz_n2_pt1 = gapz_n2 + 2;
+		fgcp2pt = fgcp2g + 1;
+		ogcp2pt = ogcp2g + 1;
+
+		fg_t_og_h_dg_n1_p_va = fg_t_og_h_dg_n1_p[i];
+		og_t_fg_h_dg_n1_p_va = og_t_fg_h_dg_n1_p[i];
+		og_h_dg_n1_p_va = og_h_dg_n1_p[i];
+		fg_h_dg_n1_p_va = fg_h_dg_n1_p[i];
+		gapz_n1_va0 = gapz_n1[i];
+		gapz_n1_va1 = gapz_n1[i+1];
+		fgcp1va = fgcp1g[i];
+		ogcp1va = ogcp1g[i];
+
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+
+			g = ogcp1va * *og_h_dg_n2_p_pt;
+			wm += g;
+
+			g = *ogcp2pt * og_h_dg_n1_p_va;
+			wm += g;
+
+			g = fgcp1va * *fg_h_dg_n2_p_pt;
+			wm += g;
+
+			g = *fgcp2pt * fg_h_dg_n1_p_va;
+			wm += g;
+
+			*ijppt = 0;
+
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+			tmppenal = gapz_n1_va1 * *fg_t_og_h_dg_n2_p_pt;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=mi+tmppenal) > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+
+			tmppenal = gapz_n1_va0 * *og_t_fg_h_dg_n2_p_pt;
+			if( (g=*prept+tmppenal) >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			tmppenal = *gapz_n2_pt1 * fg_t_og_h_dg_n1_p_va;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( (g=*mjpt+tmppenal) > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+
+			tmppenal = *gapz_n2_pt0 * og_t_fg_h_dg_n1_p_va;
+			if( (g=*prept+tmppenal) >= *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++;
+			fg_t_og_h_dg_n2_p_pt++;
+			og_t_fg_h_dg_n2_p_pt++;
+			og_h_dg_n2_p_pt++;
+			fg_h_dg_n2_p_pt++;
+			gapz_n2_pt0++;
+			gapz_n2_pt1++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, start1, end1, start2, end2, gapmap1, gapmap2 );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+//	fprintf( stderr, "wm = %f\n", wm );
+
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/partSalignmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/partSalignmm.c?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/partSalignmm.c (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/partSalignmm.c Thu Feb 19 06:37:59 2009
@@ -0,0 +1,1154 @@
+#include "mltaln.h"
+#include "dp.h"
+
+#define MACHIGAI 0
+#define OUTGAP0TRY 1
+#define DEBUG 0
+#define XXXXXXX    0
+#define USE_PENALTY_EX  0
+#define FASTMATCHCALC 1
+
+#if 0
+static void st_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;
+		for( i=0; i<len; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			{
+				if( !gb *  gc ) ogcp[i] += feff;
+			}
+		}
+	}
+}
+
+static void st_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] == '-' );
+		for( i=1; i<len+1; i++ ) 
+		{
+			gb = gc;
+			gc = ( seq[j][i] == '-' );
+			{
+				if( gb * !gc ) fgcp[i-1] += feff;
+			}
+		}
+	}
+}
+#endif
+
+
+			
+		
+
+static int impalloclen = 0;
+static float **impmtx = NULL;
+float part_imp_match_out_sc( int i1, int j1 )
+{
+//	fprintf( stderr, "impalloclen = %d\n", impalloclen );
+//	fprintf( stderr, "i1,j1=%d,%d -> impmtx=%f\n", i1, j1, impmtx[i1][j1] );
+	return( impmtx[i1][j1] );
+#if 0
+	if( i1 == l1 || j1 == l2 ) return( 0.0 );
+	return( impmtx[i1+start1][j1+start2] );
+#endif
+}
+static void part_imp_match_out_vead_gapmap( float *imp, int i1, int lgth2, int start2, int *gapmap2 )
+{
+#if FASTMACHCALC
+	float *pt = imp;
+	int *gapmappt = gapmap2;
+	while( lgth2-- )
+		*pt++ += impmtx[i1][start2+*gapmappt++];
+#else
+	int j;
+	for( j=0; j<lgth2; j++ )
+	{
+		imp[j] += impmtx[i1][start2+gapmap2[j]];
+	}
+#endif
+}
+
+static void part_imp_match_out_vead_tate_gapmap( float *imp, int j1, int lgth1, int start1, int *gapmap1 )
+{
+#if FASTMACHCALC
+	float *pt = imp;
+	int *gapmappt = gapmap1;
+	while( lgth1-- )
+		*pt++ = impmtx[start1+*gapmappt++][j1];
+#else
+	int i;
+	for( i=0; i<lgth1; i++ )
+	{
+		imp[i] += impmtx[start1+gapmap1[i]][j1];
+	}
+#endif
+}
+
+void part_imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
+{
+	int i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	double effij, effijx; 
+	char *pt, *pt1, *pt2;
+	LocalHom *tmpptr;
+
+	if( impalloclen <= lgth1 + 2 || impalloclen <= lgth2 + 2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen+100, impalloclen+100 );
+	}
+
+
+#if 0
+	fprintf( stderr, "eff1 in _init_strict = \n" );
+	for( i=0; i<clus1; i++ )
+		fprintf( stderr, "eff1[] = %f\n", eff1[i] );
+	for( i=0; i<clus2; i++ )
+		fprintf( stderr, "eff2[] = %f\n", eff2[i] );
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	effijx = 1.0 * fastathreshold;
+	for( i=0; i<clus1; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+		{
+			effij = eff1[i] * eff2[j] * effijx;
+			tmpptr = localhom[i][j];
+			while( tmpptr )
+			{
+//				fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
+//				fprintf( stderr, "end1   = %d\n", tmpptr->end1   );
+//				fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
+//				fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
+				pt = seq1[i];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start1 ) break;
+				}
+				start1 = (int)( pt - seq1[i] ) - 1;
+	
+				if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end1 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end1 = (int)( pt - seq1[i] ) - 1;
+#else
+					while( *pt != 0 )
+					{
+//						fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end1 ) break;
+					}
+					end1 = (int)( pt - seq1[i] ) - 1;
+#endif
+				}
+	
+				pt = seq2[j];
+				tmpint = -1;
+				while( *pt != 0 )
+				{
+					if( *pt++ != '-' ) tmpint++;
+					if( tmpint == tmpptr->start2 ) break;
+				}
+				start2 = (int)( pt - seq2[j] ) - 1;
+				if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
+				else
+				{
+#if MACHIGAI
+					while( *pt != 0 )
+					{
+						if( tmpint == tmpptr->end2 ) break;
+						if( *pt++ != '-' ) tmpint++;
+					}
+					end2 = (int)( pt - seq2[j] ) - 1;
+#else
+					while( *pt != 0 )
+					{
+						if( *pt++ != '-' ) tmpint++;
+						if( tmpint == tmpptr->end2 ) break;
+					}
+					end2 = (int)( pt - seq2[j] ) - 1;
+#endif
+				}
+//				fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
+//				fprintf( stderr, "step 0\n" );
+				if( end1 - start1 != end2 - start2 )
+				{
+//					fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+				}
+
+				k1 = start1; k2 = start2;
+				pt1 = seq1[i] + k1;
+				pt2 = seq2[j] + k2;
+				while( *pt1 && *pt2 )
+				{
+					if( *pt1 != '-' && *pt2 != '-' )
+					{
+// ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+//						impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
+//						impmtx[k1][k2] += tmpptr->importance * effij;
+						impmtx[k1][k2] += tmpptr->fimportance * effij;
+//						fprintf( stderr, "k1=%d, k2=%d, impalloclen=%d\n", k1, k2, impalloclen );
+//						fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; k2++;
+						pt1++; pt2++;
+					}
+					else if( *pt1 != '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k2++; pt2++;
+					}
+					else if( *pt1 == '-' && *pt2 != '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+					}
+					else if( *pt1 == '-' && *pt2 == '-' )
+					{
+//						fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
+						k1++; pt1++;
+						k2++; pt2++;
+					}
+					if( k1 > end1 || k2 > end2 ) break;
+				}
+				tmpptr = tmpptr->next;
+			}
+		}
+	}
+#if 0
+	fprintf( stderr, "impmtx = \n" );
+	for( k2=0; k2<lgth2; k2++ )
+		fprintf( stderr, "%6.3f ", (double)k2 );
+	fprintf( stderr, "\n" );
+	for( k1=0; k1<lgth1; k1++ )
+	{
+		fprintf( stderr, "%d", k1 );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
+		fprintf( stderr, "\n" );
+	}
+	exit( 1 );
+#endif
+}
+
+
+void part_imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, int *gapmap1, int *gapmap2, RNApair *additionalpair )
+{
+	foldrna( nseq1, nseq2, seq1, seq2, eff1, eff2, grouprna1, grouprna2, impmtx, gapmap1, gapmap2, additionalpair );
+}
+
+
+void part_imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom )
+{
+	int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
+	static int impalloclen = 0;
+	char *pt;
+	static char *nocount1 = NULL;
+	static char *nocount2 = NULL;
+
+	if( impalloclen < lgth1 || impalloclen < lgth2 )
+	{
+		if( impmtx ) FreeFloatMtx( impmtx );
+		if( nocount1 ) free( nocount1 );
+		if( nocount2 ) free( nocount2 );
+		impalloclen = MAX( lgth1, lgth2 ) + 2;
+		impmtx = AllocateFloatMtx( impalloclen, impalloclen );
+		nocount1 = AllocateCharVec( impalloclen );
+		nocount2 = AllocateCharVec( impalloclen );
+		impalloclen -= 2;
+	}
+
+	for( i=0; i<lgth1; i++ )
+	{
+		for( j=0; j<clus1; j++ )
+			if( seq1[j][i] == '-' ) break;
+		if( j != clus1 ) nocount1[i] = 1; 
+		else			 nocount1[i] = 0;
+	}
+	for( i=0; i<lgth2; i++ )
+	{
+		for( j=0; j<clus2; j++ )
+			if( seq2[j][i] == '-' ) break;
+		if( j != clus2 ) nocount2[i] = 1;
+		else			 nocount2[i] = 0;
+	}
+
+#if 0
+fprintf( stderr, "nocount2 =\n" );
+for( i = 0; i<impalloclen; i++ )
+{
+	fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
+}
+#endif
+
+	for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
+		impmtx[i][j] = 0.0;
+	for( i=0; i<clus1; i++ )
+	{
+		fprintf( stderr, "i = %d, seq1 = %s\n", i, seq1[i] );
+		for( j=0; j<clus2; j++ )
+		{
+			fprintf( stderr, "start1 = %d\n", localhom[i][j]->start1 );
+			fprintf( stderr, "end1   = %d\n", localhom[i][j]->end1   );
+			fprintf( stderr, "j = %d, seq2 = %s\n", j, seq2[j] );
+			pt = seq1[i];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start1 ) break;
+			}
+			start1 = pt - seq1[i] - 1;
+
+			while( *pt != 0 )
+			{
+//				fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, localhom[i][j].end1, pt-seq1[i] );
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end1 ) break;
+			}
+			end1 = pt - seq1[i] - 1;
+
+			pt = seq2[j];
+			tmpint = -1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->start2 ) break;
+			}
+			start2 = pt - seq2[j] - 1;
+			while( *pt != 0 )
+			{
+				if( *pt++ != '-' ) tmpint++;
+				if( tmpint == localhom[i][j]->end2 ) break;
+			}
+			end2 = pt - seq2[j] - 1;
+//			fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
+			k1 = start1;
+			k2 = start2;
+			fprintf( stderr, "step 0\n" );
+			while( k1 <= end1 && k2 <= end2 )
+			{
+#if 0
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j].wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#else
+				if( !nocount1[k1] && !nocount2[k2] )
+					impmtx[k1][k2] += localhom[i][j]->wimportance * eff1[i] * eff2[j];
+				k1++; k2++;
+#endif
+			}
+
+			dif = ( end1 - start1 ) - ( end2 - start2 );
+			fprintf( stderr, "dif = %d\n", dif );
+			if( dif > 0 )
+			{
+				do
+				{
+					fprintf( stderr, "dif = %d\n", dif );
+					k1 = start1;
+					k2 = start2 - dif;
+					while( k1 <= end1 && k2 <= end2 )
+					{
+						if( 0 <= k2 && start2 <= k2 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif-- );
+			}
+			else
+			{
+				do
+				{
+					k1 = start1 + dif;
+					k2 = start2;
+					while( k1 <= end1 )
+					{
+						if( k1 >= 0 && k1 >= start1 && !nocount1[k1] && !nocount2[k2] )
+							impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
+						k1++; k2++;
+					}
+				}
+				while( dif++ );
+			}
+		}
+	}
+#if 0
+	fprintf( stderr, "impmtx = \n" );
+	for( k2=0; k2<lgth2; k2++ )
+		fprintf( stderr, "%6.3f ", (double)k2 );
+	fprintf( stderr, "\n" );
+	for( k1=0; k1<lgth1; k1++ )
+	{
+		fprintf( stderr, "%d", k1 );
+		for( k2=0; k2<lgth2; k2++ )
+			fprintf( stderr, "%6.3f ", impmtx[k1][k2] );
+		fprintf( stderr, "\n" );
+	}
+	exit( 1 );
+#endif
+}
+
+static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
+{
+#if FASTMATCHCALC
+	int j, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	float *matchpt, *cpmxpdpt, **cpmxpdptpt;
+	int *cpmxpdnpt, **cpmxpdnptpt;
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[j][count] = cpmx2[l][j];
+					cpmxpdn[j][count] = l;
+					count++;
+				}
+			}
+			cpmxpdn[j][count] = -1;
+		}
+	}
+
+	{
+		for( l=0; l<26; l++ )
+		{
+			scarr[l] = 0.0;
+			for( j=0; j<26; j++ )
+				scarr[l] += n_dis_consweight_multi[j][l] * cpmx1[j][i1];
+//				scarr[l] += n_dis[j][l] * cpmx1[j][i1];
+		}
+		matchpt = match;
+		cpmxpdnptpt = cpmxpdn;
+		cpmxpdptpt = cpmxpd;
+		while( lgth2-- )
+		{
+			*matchpt = 0.0;
+			cpmxpdnpt = *cpmxpdnptpt++;
+			cpmxpdpt = *cpmxpdptpt++;
+			while( *cpmxpdnpt>-1 )
+				*matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
+			matchpt++;
+		} 
+	}
+#else
+	int j, k, l;
+	float scarr[26];
+	float **cpmxpd = floatwork;
+	int **cpmxpdn = intwork;
+	// simple
+	if( initialize )
+	{
+		int count = 0;
+		for( j=0; j<lgth2; j++ )
+		{
+			count = 0;
+			for( l=0; l<26; l++ )
+			{
+				if( cpmx2[l][j] )
+				{
+					cpmxpd[count][j] = cpmx2[l][j];
+					cpmxpdn[count][j] = l;
+					count++;
+				}
+			}
+			cpmxpdn[count][j] = -1;
+		}
+	}
+	for( l=0; l<26; l++ )
+	{
+		scarr[l] = 0.0;
+		for( k=0; k<26; k++ )
+			scarr[l] += n_dis_consweight_multi[k][l] * cpmx1[k][i1];
+//			scarr[l] += n_dis[k][l] * cpmx1[k][i1];
+	}
+	for( j=0; j<lgth2; j++ )
+	{
+		match[j] = 0.0;
+		for( k=0; cpmxpdn[k][j]>-1; k++ )
+			match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
+	} 
+#endif
+}
+
+static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc,
+						int start1, int end1, int start2, int end2,
+						int *gapmap1, int *gapmap2 )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
+	char gap[] = "-";
+	float wm;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	*impwmpt = 0.0;
+	for( k=0; k<=lgth1+lgth2; 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][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][jfi+l];
+			k++;
+		}
+		if( iin != lgth1 && jin != lgth2 ) // ??
+		{
+			*impwmpt += part_imp_match_out_sc( gapmap1[iin]+start1, gapmap2[jin]+start2 );
+//			fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+}
+static float Atracking( float *lasthorizontalw, float *lastverticalw, 
+						char **seq1, char **seq2, 
+                        char **mseq1, char **mseq2, 
+                        float **cpmx1, float **cpmx2, 
+                        int **ijp, int icyc, int jcyc )
+{
+	int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, lastk;
+	char gap[] = "-";
+	float wm = 0.0;
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+	{
+		fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
+	}
+#endif
+ 
+	if( outgap == 1 )
+		;
+	else
+	{
+		wm = lastverticalw[0];
+		for( i=0; i<lgth1; i++ )
+		{
+			if( lastverticalw[i] >= wm )
+			{
+				wm = lastverticalw[i];
+				iin = i; jin = lgth2-1;
+				ijp[lgth1][lgth2] = +( lgth1 - i );
+			}
+		}
+		for( j=0; j<lgth2; j++ )
+		{
+			if( lasthorizontalw[j] >= wm )
+			{
+				wm = lasthorizontalw[j];
+				iin = lgth1-1; jin = j;
+				ijp[lgth1][lgth2] = -( lgth2 - j );
+			}
+		}
+	}
+
+    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;
+	}
+	iin = lgth1; jin = lgth2;
+	lastk = lgth1+lgth2;
+	for( k=0; k<=lastk; 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][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][jfi+l];
+			k++;
+		}
+		if( iin <= 0 || jin <= 0 ) break;
+		for( i=0; i<icyc; i++ ) 
+			*--mseq1[i] = seq1[i][ifi];
+		for( j=0; j<jcyc; j++ ) 
+			*--mseq2[j] = seq2[j][jfi];
+		k++;
+		iin = ifi; jin = jfi;
+	}
+	return( 0.0 );
+}
+
+float partA__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, char *sgap1, char *sgap2, char *egap1, char *egap2 )
+/* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
+{
+//	int k;
+	register int i, j;
+	int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
+	int lgth1, lgth2;
+	int resultlen;
+	float wm = 0.0;   /* int ?????? */
+	float g;
+	float *currentw, *previousw;
+#if 1
+	float *wtmp;
+	int *ijppt;
+	float *mjpt, *prept, *curpt;
+	int *mpjpt;
+#endif
+	static float mi, *m;
+	static int **ijp;
+	static int mpi, *mp;
+	static float *w1, *w2;
+	static float *match;
+	static float *initverticalw;    /* kufuu sureba iranai */
+	static float *lastverticalw;    /* kufuu sureba iranai */
+	static char **mseq1;
+	static char **mseq2;
+	static char **mseq;
+	static float *ogcp1;
+	static float *ogcp2;
+	static float *fgcp1;
+	static float *fgcp2;
+	static float **cpmx1;
+	static float **cpmx2;
+	static int **intwork;
+	static float **floatwork;
+	static int orlgth1 = 0, orlgth2 = 0;
+	float fpenalty = (float)penalty;
+#if USE_PENALTY_EX
+	float fpenalty_ex = (float)penalty_ex;
+#endif
+	float *fgcp2pt;
+	float *ogcp2pt;
+	float fgcp1va;
+	float ogcp1va;
+
+
+
+#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
+	if( orlgth1 == 0 )
+	{
+		mseq1 = AllocateCharMtx( njob, 0 );
+		mseq2 = AllocateCharMtx( njob, 0 );
+	}
+
+
+	lgth1 = strlen( seq1[0] );
+	lgth2 = strlen( seq2[0] );
+
+	if( lgth1 > orlgth1 || lgth2 > orlgth2 )
+	{
+		int ll1, ll2;
+
+		if( orlgth1 > 0 && orlgth2 > 0 )
+		{
+			FreeFloatVec( w1 );
+			FreeFloatVec( w2 );
+			FreeFloatVec( match );
+			FreeFloatVec( initverticalw );
+			FreeFloatVec( lastverticalw );
+
+			FreeFloatVec( m );
+			FreeIntVec( mp );
+
+			FreeCharMtx( mseq );
+
+			FreeFloatVec( ogcp1 );
+			FreeFloatVec( ogcp2 );
+			FreeFloatVec( fgcp1 );
+			FreeFloatVec( fgcp2 );
+
+
+			FreeFloatMtx( cpmx1 );
+			FreeFloatMtx( cpmx2 );
+
+			FreeFloatMtx( floatwork );
+			FreeIntMtx( intwork );
+		}
+
+		ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
+		ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
+
+#if DEBUG
+		fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
+#endif
+
+		w1 = AllocateFloatVec( ll2+2 );
+		w2 = AllocateFloatVec( ll2+2 );
+		match = AllocateFloatVec( ll2+2 );
+
+		initverticalw = AllocateFloatVec( ll1+2 );
+		lastverticalw = AllocateFloatVec( ll1+2 );
+
+		m = AllocateFloatVec( ll2+2 );
+		mp = AllocateIntVec( ll2+2 );
+
+		mseq = AllocateCharMtx( njob, ll1+ll2 );
+
+		ogcp1 = AllocateFloatVec( ll1+2 );
+		ogcp2 = AllocateFloatVec( ll2+2 );
+		fgcp1 = AllocateFloatVec( ll1+2 );
+		fgcp2 = AllocateFloatVec( ll2+2 );
+
+		cpmx1 = AllocateFloatMtx( 26, ll1+2 );
+		cpmx2 = AllocateFloatMtx( 26, ll2+2 );
+
+#if FASTMATCHCALC
+		floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 ); 
+		intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 26 ); 
+#else
+		floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 ); 
+		intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 ); 
+#endif
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n" );
+#endif
+
+		orlgth1 = ll1 - 100;
+		orlgth2 = ll2 - 100;
+	}
+
+
+	for( i=0; i<icyc; i++ ) mseq1[i] = mseq[i];
+	for( j=0; j<jcyc; j++ ) mseq2[j] = mseq[icyc+j];
+
+
+	if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
+	{
+		int ll1, ll2;
+
+		if( commonAlloc1 && commonAlloc2 )
+		{
+			FreeIntMtx( commonIP );
+		}
+
+		ll1 = MAX( orlgth1, commonAlloc1 );
+		ll2 = MAX( orlgth2, commonAlloc2 );
+
+#if DEBUG
+		fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
+#endif
+
+		commonIP = AllocateIntMtx( ll1+10, ll2+10 );
+
+#if DEBUG
+		fprintf( stderr, "succeeded\n\n" );
+#endif
+
+		commonAlloc1 = ll1;
+		commonAlloc2 = ll2;
+	}
+	ijp = commonIP;
+
+	cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
+	cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
+
+	if( sgap1 )
+	{
+		new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
+		new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
+		new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap1 );
+		new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
+	}
+	else
+	{
+		st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
+		st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
+		st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
+		st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
+	}
+
+	for( i=0; i<lgth1; i++ ) 
+	{
+		ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
+		fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
+	}
+	for( i=0; i<lgth2; i++ ) 
+	{
+		ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
+		fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
+	}
+#if 0
+	for( i=0; i<lgth1; i++ ) 
+		fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
+#endif
+
+	currentw = w1;
+	previousw = w2;
+
+
+	match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
+	if( localhom )
+		part_imp_match_out_vead_tate_gapmap( initverticalw, gapmap2[0]+start2, lgth1, start1, gapmap1 );
+
+
+	match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
+	if( localhom )
+		part_imp_match_out_vead_gapmap( currentw, gapmap1[0]+start1, lgth2, start2, gapmap2 );
+#if 0 // -> tbfast.c
+	if( localhom )
+		imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
+
+#endif
+
+	if( outgap == 1 )
+	{
+		for( i=1; i<lgth1+1; i++ )
+		{
+			initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
+		}
+		for( j=1; j<lgth2+1; j++ )
+		{
+			currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
+		}
+	}
+#if OUTGAP0TRY
+	else
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * j / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			initverticalw[i] -= offset * i / 2.0;
+	}
+#endif
+
+	for( j=1; j<lgth2+1; ++j ) 
+	{
+		m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
+	}
+
+	lastverticalw[0] = currentw[lgth2-1];
+
+	if( outgap ) lasti = lgth1+1; else lasti = lgth1;
+	lastj = lgth2+1;
+
+#if XXXXXXX
+fprintf( stderr, "currentw = \n" );
+for( i=0; i<lgth1+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "initverticalw = \n" );
+for( i=0; i<lgth2+1; i++ )
+{
+	fprintf( stderr, "%5.2f ", initverticalw[i] );
+}
+fprintf( stderr, "\n" );
+fprintf( stderr, "fcgp\n" );
+for( i=0; i<lgth1; i++ ) 
+	fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
+for( i=0; i<lgth2; i++ ) 
+	fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
+#endif
+
+	for( i=1; i<lasti; i++ )
+	{
+		wtmp = previousw; 
+		previousw = currentw;
+		currentw = wtmp;
+
+		previousw[0] = initverticalw[i-1];
+
+		match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		if( localhom )
+		{
+//			fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
+//			imp_match_out_vead( currentw, i, lgth2 );
+			part_imp_match_out_vead_gapmap( currentw, gapmap1[i]+start1, lgth2, start2, gapmap2 );
+		}
+#if XXXXXXX
+fprintf( stderr, "\n" );
+fprintf( stderr, "i=%d\n", i );
+fprintf( stderr, "currentw = \n" );
+for( j=0; j<lgth2; j++ )
+{
+	fprintf( stderr, "%5.2f ", currentw[j] );
+}
+fprintf( stderr, "\n" );
+#endif
+		currentw[0] = initverticalw[i];
+
+
+		mi = previousw[0] + ogcp2[1]; mpi = 0;
+
+		ijppt = ijp[i] + 1;
+		mjpt = m + 1;
+		prept = previousw;
+		curpt = currentw + 1;
+		mpjpt = mp + 1;
+		fgcp2pt = fgcp2;
+		ogcp2pt = ogcp2+1;
+		fgcp1va = fgcp1[i-1];
+		ogcp1va = ogcp1[i];
+		for( j=1; j<lastj; j++ )
+		{
+			wm = *prept;
+			*ijppt = 0;
+
+#if 0
+			fprintf( stderr, "%5.0f->", wm );
+#endif
+			g = mi + *fgcp2pt;
+#if 0
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = -( j - mpi );
+			}
+			g = *prept + *ogcp2pt;
+			if( g >= mi )
+			{
+				mi = g;
+				mpi = j-1;
+			}
+#if USE_PENALTY_EX
+			mi += fpenalty_ex;
+#endif
+
+			g = *mjpt + fgcp1va;
+#if 0 
+			fprintf( stderr, "%5.0f?", g );
+#endif
+			if( g > wm )
+			{
+				wm = g;
+				*ijppt = +( i - *mpjpt );
+			}
+			g = *prept + ogcp1va;
+			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++;
+			fgcp2pt++;
+			ogcp2pt++;
+		}
+		lastverticalw[i] = currentw[lgth2-1];
+	}
+
+#if OUTGAP0TRY
+	if( !outgap )
+	{
+		for( j=1; j<lgth2+1; j++ )
+			currentw[j] -= offset * ( lgth2 - j ) / 2.0;
+		for( i=1; i<lgth1+1; i++ )
+			lastverticalw[i] -= offset * ( lgth1 - i  / 2.0);
+	}
+#endif
+		
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
+	fprintf( stderr, "====>" );
+	for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
+	*/
+	if( localhom )
+	{
+		Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, start1, end1, start2, end2, gapmap1, gapmap2 );
+	}
+	else
+		Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
+
+//	fprintf( stderr, "### impmatch = %f\n", *impmatch );
+
+	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" );
+	}
+
+
+	for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
+	for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
+	/*
+	fprintf( stderr, "\n" );
+	for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
+	fprintf( stderr, "#####\n" );
+	for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
+	*/
+
+
+	return( wm );
+}
+

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/pyruvate_decarboxylase.fasta
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/pyruvate_decarboxylase.fasta?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/pyruvate_decarboxylase.fasta (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/pyruvate_decarboxylase.fasta Thu Feb 19 06:37:59 2009
@@ -0,0 +1,942 @@
+>gi|189091826|ref|XP_001929746.1| [Podospora anserina]
+MAIDIRTQGLKKPVPVAQYLFARLYEIGIRSVHGLPGDFNLVALDYIPKAKLKWVGSVNELNAAYAADGY
+ARALGISALVTTFGVGELSAMNGVAGAYSEHVPVVHIVGCPSTISQRNGMLLHHTLGNGDFNVFANMGSQ
+IACNTARLNNPAEIAEQIDFALRECWIHSRPVYIMLPTDMVEKQIEGARLDTPIDLSDPPNEPEREDYVV
+DVVLRYLHAAKNPIILVDACAIRHRCLEEVRNLVDKAKLPVFVTPMGKGAVNESSPTYGGVYAGTGSQPA
+VQELVESADLVLSIGALKSDFNTTGFSYRTSQLNTIDFHSDHCKVRYSEYPGVAMKGVLRKLIERVDTTK
+LSSEKLAPKVVNEVSENRDSTETITQAWFWPRVGEYFKEKDLVVTETGTSNFGIWESKFPPDVVGITQIL
+WGSIGWSVGAAQGVAQAVKDMGEDRRTILFVGDGSFQLTVQEVSTMIKHKLRVTIFLIYNEGFTIERCIH
+GMEAEYNDIRRWNYTEIPTVFGATDKEVRKHIIKTKSELEKLLADKDFNDAKGLQLVELWMPKHDAPRAL
+KLTAEQSAKNNARME
+
+>gi|154300316|ref|XP_001550574.1| hypothetical protein BC1G_11347 [Botryotinia fuckeliana B05.10]
+MVDLRTESLKSPVDLAEYLFTRLKQIGIDSVHGLPGDYNLVALDYIPKLGLKWVGNCNELNAGYAADGYA
+RVKGISAIMTTFGVGELSAINAIAGAYSERVPIVHIVGTPSTISQKDGMLLHHTLGNGNFNVFADMSKEI
+SCAMAKINDPHEAAALIDHTLQQCWVHSQPVYITLPTDMVQKKVEGERLKTPIDLSLPSNDPDKEDYVVD
+VILKYFEAAKNPIILVDACAIRHRVIPEVHGLIEKTGLPVFVTPMGKGAVDETSENYGGVYAGSGSHPDV
+KHRVESSDLILTIGAIKSDFNTAGFSYKTSQLNTIDFHSTKIAVRYSEYPGVHMRGVLQKIIKKVDLRKL
+SAVPGPKMENKVTANEDSSETITQAWFWPRAGEFLKENDIVITETGTANFGIWETKFPKGVTALSQVLWG
+SIGYSVGACQGAALAARDAGSDSRTILFVGDGSFQLTAQEVSTMIRLGLKPIIFVICNDGYTIERFIHGM
+EEEYNDIATWNNKDLVPAFGAKEGKYKLHQIKTKDQVNELFTNKEFNSADCLQFVELYIPKEDAPRALVL
+TAEASAKNNAKD
+
+>gi|116179618|ref|XP_001219658.1| pyruvate decarboxylase [Chaetomium globosum CBS 148.51]
+MTDIREQGLKKPIAITEYLFKRLHEIGIRSVHGLPGDFNLVALDYIPKAGLRWVGSVNELNAAYAADGYA
+RTKGISAILTTFGVGELSAINGIAGAFSEHVPVVHIVGCPSTISQRNGMLLHHTLGNGDFNVFANMSSQI
+SCDMARLNKPAEIPDQIDHALRECWIRSRPVYIMLPTDMAEKKVEGARLDTPIDLAEPENDPEREDYVVD
+VVLKYLHAAKSPVILVDACAIRHRVLEEVHDLVEKTQLPVFVTPMGKGAINENHPSYGGVYAGTGSQPAV
+AERVESADLVLSIGALKSDFNTAGFSYRTSQLNTIDFHSTHCTVRYSEYPGVAMRGVLRKVNERVDLTKL
+CRPSSPDVANEVTKNRDSSETITQAFFWPRVGEYLKEDDIVVTETGTSNFGIWETKYPRGVTGVTQILWG
+SIGWSVGAAQGAALAAKDMGTDRRTILFVGDGSFQLTAQEVSTMMRHNLKVTIFLIYNEGFTIERYIHGM
+EAEYNDVVRWQYTDVPTVFGGSDKQVRKFVIKTKDELEKLLTDKEFNEAGGLQFVELWMPKDDAPRALKI
+TAEIAAKNNAKMSD
+
+>gi|156042376|ref|XP_001587745.1| hypothetical protein SS1G_10985 [Sclerotinia sclerotiorum 1980]
+MVDLRTESLKSPVDIAEYLFTRLKQIGIDSIHGLPGDYNLVALDYIPKLGLKWVGNCNELNAGYAADGYA
+RVKGISAIMTTFGVGELSAINAIAGAYSERVPVVHIVGTPSTISQKDGMLLHHTLGNGNFHVFADMFKEI
+SCAMAKINDPNEAAALIDHTLQQCWIHSQPVYISLPTDMVQKKVEGERLKTPIDLSLPPNDPDKEDYVVD
+VVLKYLEAAKNPIILVDACAIRHRVIPEVHGLIEKTGLPVFVTPMGKGAVDETYENYGGVYAGSGSQPDV
+KDRVESSDLILTIGAIKSDFNTAGFSYKTSQLNTIDFHSTTIVVRYSEYPGVHMRGVLQKIINKIDLEKL
+SAVPGPKMENKVTANEDSSDTITQAWFWPRAGEFLKENDIVITETGTANFGIWETKFPKGVTALSQVLWG
+SIGYSVGACQGAALAARDAGNDRRTVLFVGDGSFQLTVQEVSTMIRLGLKPIIFVICNDGYTIERFIHGM
+EAEYNDIAAWKHKDLVPAFGAQEGKYQLHQIKTKDQVNELFTNKEFNAADCLQFVELYIPKEDAPRALVL
+TAEASAKNNAKV
+
+>gi|162424687|gb|ABX90025.1| indole-3-pyruvate decarboxylase [Chaetomium globosum]
+MTDIREQGLNKPIAIAEYLFKRLHEIGIRSVHGLPGDFNLVALDYLPKAGLRWVGSVNELNAAYAADGYA
+RTKGISAVLTTFGVGELSAINGIAGAFSEHVPVVHIVGCPSTISQRKGMLLHHTLGNGDFNVFANMSSQI
+SCDMARLNKPAEVPDQIDHALRECWIRSRPVYIMLPTDMAEKKVDGARLDTPIDLSEPKNETEREDYVVD
+VVLKYLHAAKAPVILVDACAIRHRVLEEVHDLMEKTPLPVFVTPMGKGAINENHPSYGGVYAGTGSQPAV
+AERVESADLVLSIGALKSDFNTAGFSYRTSQLNTIDFHSTHCTVRYSEYPGVAMRGVLRKVNERVDLSKL
+CRPSSPEVANDVTKNRDSSETITQAFFWPRVGEYLKEDDIVVTETGTSNFGIWETKYPRGVTGVTQILWG
+SIGWSVGAAQGAALAAKDMGADRRTVLFVGDGSFQLTAQEVTTMLRHNLKVTIFLIYNEGFTIERYIHGM
+DAEYNDIVRWQYTDVPTVFGGSDKQVRKFVIKTKDELEKLLTNKEFNEAGGLQFVELWMPKEDAPRALKI
+TAEIAAKNNAKMSD
+
+>gi|164427080|ref|XP_959717.2| pyruvate decarboxylase [Neurospora crassa OR74A]
+MSDIRTQSLQKPVTVAEYLFRRLHQIGIRSVHGLPGDFNLVALDYVPKAGLKWVGSVNELNAAYAADGYA
+RAKGISALVTTFGVGELSAINGVAGAYSEHVPIVHIVGCPSTISQRNGMLLHHTLGNGDFHVFANMSENI
+SCDVAKLVKPSEIAYQIDHAIRECWIRSRPVYIWLPTDMVEKKIEGARLDTEIDLSEPENDPDREDYVVD
+VVLRYLHGAKNPVVLVDACAIRHRVTEEVKRFIEKTKLPVFVTPMGKGAFDETSEHYGGVYAGTGSLPEV
+AKRVEGSDLVLSIGAIKSDFNTAGFSYHTSQLNTIDLHSDHCTVRYSEYPGVAMRGVLRKVTERIDMSKL
+SITPSPPVENAVAENRDDSQAITQAWFWPRVGEYFQEGDVVVTETGTANFGIWESRFPKDVMGVTQVLWG
+SIGWSVGAAQGAALAVKDLEQDRRTILFVGDGSFQLTCQEVSTMLKHNLRVTMLHYRTLHPWHGRGLQRC
+HPLELYRYPRGLWRQGRPVSEVRYQDKG
+
+>gi|46136637|ref|XP_390010.1| hypothetical protein FG09834.1 [Gibberella zeae PH-1]
+MSNSSLQKPIDVAEYLFKRLYEVGVRSIHGVPGDYNLVALDYLPQCNLRWVGSVNELNAAYAADGYARVT
+KMAALITTFGVGELSAINGVAGSYSEHIPVVHIVGCPSTISQRDQMLLHHTLGNGDFDVFANMSSQISCN
+VAKLNKPSEIAEQIDTALRTCWLRSRPVYIMVPTDMVQEKVEGARLDTPIDLSEPKNDPGNEDFVVDEIL
+KAMYAAKRPVILVDSCAIRHRVVEEVHQLVDKLDLPVFVTPMGKGAVNEDHPNYGGVFAGDGSHPPRAQT
+IVEESDLLLTIGALKSDFNTTGFSYRTSQINSVDFHSTHCKVRYSTYPGVAMRGVLRKIIDKVDPKSMPA
+PSIPEVRNEVEKNNDDSETITQAWFWPRVGEYLIPNDIVVTETGTANFGIWDTRFPRNVTALSQVLWGSI
+GWSVGACQGAALAAKDAGKDGRTILFVGDGSFQLTAQELSTMIRHGLKPTIFVICNDGFTIERFIHGMDA
+VYNDINNWKYKDLVSVFGGEKTCKTFQIKTKNELNELLTNKEFNAAECLQFVELYMPREDAPRALVLTAE
+ASARNNAKKH
+
+>gi|110611696|dbj|BAE98181.1| putative pyruvate decarboxylase [Fusarium oxysporum f. sp. lycopersici]
+MSNSNLQKPIDVAEYLFKRLYEVGVRSVHGVPGDYNLVALDYLPQCNLKWVGSVNELNAAYAADGYARVT
+KMAALITTFGVGELSAVNGVAGSYSEHIPVVHIVGCPSTISQRDQMLLHHTLGNGDFDVFANMSAQISCN
+VAKLNKPSEIAEQIDTALRTCWLRSRPVYIMVPTDMVQEKVEGARLDTSIDLSEPQNDPGNEDFVVDEIL
+KAMYAAQRPVILVDSCAIRHRVVKEVHQLIDKLDLPVFVTPMGKGAVNEDHPNYGGVFAGDGSHPARAQS
+IVEGSDLLLTIGALKSDFNTTGFSYRTSQINSVDFHSTHCKVRYSTYPGVAMRGVLRKIIDRVDPKSMPA
+PSIPEVRNEVEKNTDDSEIITQAWLWPRVGEYLIPNDIVVTETGTANFGIWDTRFPRNVTALSQVLWGSI
+GWSVGACQGAALAAKDAGKEGRTILFVGDGSFQLTAQELSTMIRHHLKPTIFVICNDGFTIERFIHGMDA
+VYNDINNWKYKDLVSVFGGEKTCKTFQIKTKTELNELLTNKEFNAAECLQFVELYMPREDAPRALIMTAE
+ASARNNAKKH
+
+>gi|119187483|ref|XP_001244348.1| hypothetical protein CIMG_03789 [Coccidioides immitis RS]
+MTDLATKELKNPVDVAEYLFTRLHQLGIRSIHGVPGDYNLVALDYIPKCGLRWVGNCNELNAGYAADGYA
+RINGISALMTTFGVGELSALNAVAGAFSEFVPIVHIIGQPSTISQKDGMLLHHTLGNGDYNAFANMSANI
+SCAVAKLNDPHQAATYIDSALRECWIRSRPVYIALPTDLVQKKVDGERLKTPIDLSPPANEEEKEEYVVD
+VVLKYLHAAKNPVILVDACAIRHRVLDEVHDFVKKSGLPTFVAPMGKGAVDETLPNYGGVYAGDGSNAGV
+KDRVESSDLILSIGAIKSDFNTTGFTYRIGRMNTIDFHSNYVAVRYSEYPGVGMKGVLRKVVQRMGKVNV
+APGPKVINEPHEDPSASNPAITHEWFWPIVGKWLQENDIVITETGTANFGIWETRFPKGVTAVSQVLWGS
+IGYSLGACQGAALATQEGLKRRTILFIGDGSFQMTGQELSTMIRRKLTPIIFVICNEGYTIERYIHGWES
+SYNDIQEWKFKDLVPAFGAKPENYRTYQIRTKQEVLDLFANKEFAAAEVLQLVELYMPLEDAPAALRLTA
+EASARRNAE
+
+>gi|119491715|ref|XP_001263352.1| pyruvate decarboxylase [Neosartorya fischeri NRRL 181]
+MATDIATRELRKPIDVAEYLFRRLHEVGIRSVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGY
+ARVNGISALITTFGVGELSAINAIAGAYSEFVPIVHIVGQPHTRSQRDGMLLHHTLGNGDYNVFARMNAG
+ISTTVGRLNDTHEVATLIDNAIRECWIRSRPVYITLPTDMINKKIEGERLNTPIDLSLPSNDPEKEDYVV
+DVVLKYLHAAQRPVILVDACAIRHKVLQEVHDLMEASGLPTFVAPMGKGAVNETHKNYGGVYAGDGSNTG
+VREQVESSDLILSIGAIKSDFNTAGFTYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLRKVIQKLGRVN
+AQPVPQLSNKLPDDEPKSGDQPITHRWFWPKVGQWLKENDVVITETGTANFGIWETRFPAGVTAISQVLW
+GSIGYSVGACQGAALAAKEQGNRRTILFVGDGSIQLTLQEISTMIRNKLNPIIFVICNEGYTIERYIHGW
+EASYNDIQQWDYKSLPVAFGAGKDYKGYQVKTKDDMIKLFENKEFASAPCLQLVELYMPREDAPSALKLT
+AEAAASRNK
+
+>gi|70999590|ref|XP_754512.1| pyruvate decarboxylase PdcA [Aspergillus fumigatus Af293]
+MATDIATRELRKPVDVAEYLFRRLHEVGIRSVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGY
+ARVNGISALITTFGVGELSAINAIAGAYSEFVPIVHIVGQPHTRSQRDGMLLHHTLGNGDYNVFARMNAG
+VSTTVGRLNDTHEVATLIDNAIRECWIRSRPVYITLPTDMVTKKIEGERLNTPIDLSLPANDPEKEDYVV
+DVVLKYLHAAQRPVILVDACAIRHKVLQEVHDLMEASGLPTFVAPMGKGAVDETHKNYGGVYAGDGSNTG
+VREQVESSDLILSIGAIKSDFNTAGFTYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLRKVIQKLGRVN
+AQPVPHLSNNLPDDEPKSGDQPITHRWFWPKIGQWLKENDIVITETGTANFGIWETRFPAGVTAISQVLW
+GSIGYSVGACQGAALAAKEQGNRRTILFVGDGSIQLTLQEISTMIRNKLNPIIFVICNEGYTIERYIHGW
+EASYNDIQQWDYKSLPVAFGAGKDYKGYRVKTKDDMIKLFENTEFASAPFLQLVELYMPREDAPSALKLT
+AEAAASRNK
+
+>gi|121705694|ref|XP_001271110.1| pyruvate decarboxylase [Aspergillus clavatus NRRL 1]
+MATDIATRELRKPMPVAEYLFRRLYEVGVRSVHGVPGDYNLAALDLLPKCNLRWVGNCNELNAGYAADGY
+ARVNGMGALVTTFGVGELSALNAIAGAYSEFVPIVHIVGQPNTTSQRDGMLLHHTLGNGDFNVFARMSAG
+ISTTIGRLNEAHEAATLIDNAIRECWLRSRPVYITLPTDMILKDIEGDRLDTPLDLSLPPNDPEKEDYVV
+DVVLKYLHAAKKPVILVDACAIRHRVLPEVHDLMEASGLPTFVAPMGKGAVNEAHKNYGGVYAGDGSNAG
+VREQVEESDLILSIGAIKSDFNTAGFTYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLRKVIQRLGHVN
+ALPVNVVSNTIPVDEQASGNDVISHRWFWPRIGQWLQENDIVITETGTANFGIWETRFPAGVTAISQVLW
+GSIGYSVGACQGAALAAKEQGNRRTILLVGDGSFQLTVQEVSTMIRNKLNPIIFVICNQGYTIERYIHGW
+DAGYNDIQEWDNKNIPTVFGGGDFYKGYVVKTQDEMNKLFENEEFASAPCLQLVELHMPRDDAPSALKLT
+ADAAAARNR
+
+>gi|154271205|ref|XP_001536456.1| pyruvate decarboxylase [Ajellomyces capsulatus NAm1]
+MATEIPSKELKSPVDIAHYLFTRLYQVGIRAVHGVPVALDYLPNCGLQWVGNCNELNAGYAADGYARVNG
+MGALVTTFGVGELSALNAVAGSYSEFVPVVHIVGQPSTASQRDGMLLHHTLGNGDFNVFANMSANISCYV
+AKLNDPHEAAALIDSAIRECWIRSRPVYITLPTDMTKKKVEGERLKTPIDLKRPENEVEKEEYVVDIVLK
+YLHAAKSPVILVDACAIRHRVLDEVQDLVIKSGLQTFVTPMGKSAIDESLPNYGGVYAGNGSNPGVKERV
+ESSDLILNIGAIKSDFNTAGFTYRIGRMNSIDFHSNFVAVRYSEYPNVHMKGVLRKVVDRMGQLNVTPDP
+HVINQPSKQEPSETSAISHAWFWPTVGQWLREKDIIITETGTANFGIWETRFPKGVTALSQVLWGSIGYA
+LGACQGAALAAKRGNQNRRTVLFIGDGSFQLTAQELSTIIRYNLTPIIFVICNDGYTIERCIHGWDASYN
+DIQPWKFGDLVPAFGAKSSTFKTHAVKTKKELADLFADESFSSAKTLQLVELHIPKTDTPAALRLTAEAA
+SKTNAEHE
+
+>gi|169618050|ref|XP_001802439.1| hypothetical protein SNOG_12213 [Phaeosphaeria nodorum SN15]
+MAQDLRSQEIKNPVDVAEYLFRRLQQVGVESIHGVPGDYNLVALDYIPKVGLRWVGNCNELNAGYAADGY
+ARVKGISALVTTFGVGELSAVNAIAGAYSEYVPIVHIVGYPSTLSQKNGALLHHTLGNGDFTVFSRMSKE
+ISCAVSMLNHQHEAAMLIDNAIRECILQSRPVYISLPSDMVQKKIDGDRLNTPLDLNYPPNDQEAEDYVV
+DVVLKYLHAAKNPVIVVDGCAIRHRALKETHDLVAKSGIPTFVAPMGKGAVDETLPNYGGVYAGDGSNAG
+VKDRVESADLVLSIGAIQSDFNTAGFTVRMSQMNTIDFHSYAVKVRYSEYPGVRMNGVLAKVTAKLGKLN
+IESGPEPNNTIPNHEKIDNSNSTITHAYLWPRLGQWLQPHDILITETGTSNFGVWETRFPADITAISQVL
+WGSIGYATGSCQGAALAAREKGIKRTILFTGDGSFQLTAQEISTMLRHKLNPIIFVICNKGYTIERLIHG
+MEDSYNDVQEWKYKDLPAAFGATEGSVKTYRVQTKEELEGLFEDKEFSSGDTQMMRFVELVMPWDDAPVN
+LKAIAEKAAKANSRVE
+
+>gi|189194739|ref|XP_001933708.1| pyruvate decarboxylase [Pyrenophora tritici-repentis Pt-1C-BFP]
+MASDLRSQEIKNPIDVAEYLFRRLQQVGVDSIHGVPGDYNLVALDYIPKVGLKWVGNCNELNAGYAADGY
+ARIKGIAALVTTFGVGELSAVNAIAGAYSEYVPIVHIVGYPSTISQKNGALLHHTLGNGDFTVFSRMSKE
+ISCAVSMLNSQHEAAMLIDNAIRECYLQSRPVYISLPSDMVTKKVDGDRLKTPLDLKYPSNNPEAEDYVV
+DVVLKSLHAAKNPVILVDACAIRHRALEETHELVKKSGIPTFVAPMGKGAVNETLPNYGGVYAGDGSNAG
+VRERVESSDLVLSIGAIKSDFNTAGFTIRMSQLTTIDLHSFGCKVRYSEYPGVRMNGVLAKVTAKLGDLN
+IESGPNPNNNVPEHESSSTESAIKHAWFWPKLGQWLKKDDILITETGTSNFGVWETRFPEGVRAISQVLW
+GSIGYATGACQGAALAAKESNVKRTILFTGDGSFQLTAQEVSTMIRNKLAPIIFVICNKGYTIERLIHGW
+EDPYNDVQEWKYKDIPAVFGAEEGSVLTYRVETKDDVEKLFKDEEFSSGETKKMRFVELVMPWDDAPAAL
+KAVCEAAARTNATTAE
+
+>gi|145232889|ref|XP_001399817.1| hypothetical protein An02g06820 [Aspergillus niger]
+MATDIATRDLRKPTTVAEYLFRRLHEVGVRSVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGY
+ARVNGIGALITTFGVGELSALNAIAGSYSEFVPVVHIVGQPNTKSQKDGMLLHHTLGNGDFNVFAKMSAG
+ISCTLGRLNETLEAATLIDNAIRECWIRSRPVYISLPTDMIVKQIEGDRLDKPLDLSLPANDPEKEDYVV
+DVVLKYLHAAKKPVILVDACAIRHRVLDEVHDLMEASGLPTFVAPMGKGAVDETRPNYGGVYAGTGSNAG
+VREQVESSDLILSIGAIKSDFNTSGFSYHIGQLNTIDFHSTYVRVRYSEYPEINMKGVLRKVIQRMGAVN
+AAPVPHLSNTLPESEKSSSSQEITHDWLWPNVGQWLKENDIVITETGTANFGIWETRFPANVTAISQVLW
+GSIGYSVGACQGAALAAKELGNRRTVLFVGDGSLQLTVQELSTMIRNNLNPIIFVICNNGYTIERYIHGW
+DESYNDIQPWDIEGLPRVFGAKDKYKGYKVKTRDELRQLFANQEFASAPYLQFTCLVMMLPPRXKSRLRR
+LPPGTSK
+
+>gi|67537436|ref|XP_662492.1| DCPY_EMENI Pyruvate decarboxylase [Aspergillus nidulans FGSC A4]
+MADIATRELRQPIDIAEYLFRRLHEVGIRSVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGYA
+RVNGIAALVTTFGVGELSAINAIAGAYSEFVPIIHIVGQPHSRSQKDGLLLHHTLGNGDYNVFSSMNKGI
+SVTTANLNDTYDAATLIDNAIRECWIHSRPVYLALPTDMITKKIEGERLKTPIDLSLPANDPEKEDYVVD
+VVLKYLHAAKNPVILVDACAIRHRVLEEVHDLIEVSGLPTFVAPMGKGAVNETHRCYGGVYAGTGSNPGV
+REQVESSDLILSIGAIKSDFNTAGFSYRIGQLNTIDFHSTYVRVRYSEYPDTNMKGVLRKVIQRLGFIKA
+DPVPHISNALPEHEKNSSEQRITHAWMWPMVGQWLKENDIVITETGTANFGIWDTRFPSGVTAISQVLWG
+SIGYSVGACQGAALAAKEQGNRRTVLWVGDGSLQLTLQEISTMIRNNLNPIIFVICNEGYTIERFIHGWD
+ESYNDIQTWDIKGLPVAFGGKGRYKGYKVTTRDELTKLFASEEFSSAPCLQVSLCDLTHYLSDANFEQLV
+EVHMPREDAPASLKITAEAAASRNK
+
+>gi|169770687|ref|XP_001819813.1| hypothetical protein [Aspergillus oryzae RIB40]
+MATDIATRDLRKPIDVAEYLFRRLREVGVRAVHGVPGDYNLVALDYLPKCDLHWVGNCNELNAGYAADGY
+ARINGMSALVTTFGVGELSALNAIAGAYSEFVPIVHIVGQPHTKSQKDGMLLHHTLGNGDFNVFTRMSAD
+ISCTLGCLNSTHEVATLIDNAIRECWIRSRPVYISLPTDMVTKKIEGERLDTPLDLSLPPNDPEKEDYVV
+DVVLKYLHAAKKPVILVDACAIRHRVLDEVHEFVEKSGLPTFVAPMGKGAVDETHKNYGGVYAGTGSNPG
+VREQVESSDLILSIGAIKSDFNTTGFSYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLQKIVQRMGNLN
+VGPVSPPSNLLPDNEKASTEQAITHAWLWPTVGQWLKEKDVVITETGTANFGIWDTRFPAGVTAISQVLW
+GSIGYSVGACQGAALAAKEQGRRTVLFVGDGSFQLTLQEVSTMIRNNLNPIIFVICNEGYTIERYIHGWE
+AVYNDIQPWDFLNIPVAFGAKDKYKGYKVTTRDELRELFANEEFASAPCLQLVELHMPRDDCPASLKLTA
+ESAAERNKSL
+
+>gi|115396344|ref|XP_001213811.1| pyruvate decarboxylase [Aspergillus terreus NIH2624]
+MATDIATKELHKPVDVAEYLFRRLYEVGVRAVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGY
+ARINGISALVTTFGVGELSALNAIAGAYSEFVPIVHIVGQPHTRSQRDGMLLHHTLGNGDFNVFAKMSGG
+ISCAMGRLNETHEVATLIDNAIRECWLRSRPVYIGLPTDIIVKKIEGQRLDTPLDLSLPPNDPEKEDYVV
+DVVLKYLHAAKNPVILVDACAIRHRVLDEVHDLMETSGLPTFVAPMGKGAVDETRKNYGGVYAGTGSNPG
+VREQVESSDLILSIGAIKSDFNTTGFSYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLRKVVQRMGHVN
+ALPVQRLSNALPDNEKGSSSQEITHAWLWPIVGQWLKERDIVITETGTANFGIWDTRFPANVTAISQVLW
+GSIGYSVGACQGAALAAKEQNNRRTVLFVGDGSLQLTVQEISTMIRNNLNPIVFVICNQGYTIERFIHGW
+DEAYNDIQPWDIKGLPVVFGAKDKYKGYRVKTRDELTKLFANDEFNSVPCLQLVELHMPRDDAPASLKLT
+AESAAHRNA
+
+>gi|164427078|ref|XP_959713.2| mitogen-activated kinase-2 [Neurospora crassa OR74A]
+MSSAQRGGARKISFNVSEQYDIQDVVGEGAYGVVCSAVHKPSGQKVAIKKITPFDHSMFCLRTLREMKLL
+RYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSANV
+LHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSVG
+CILAEMLSGKPLFPGKDCMYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPNTS
+ELALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIYQ
+EIMR
+
+>gi|189091818|ref|XP_001929742.1| [Podospora anserina]
+MSNAQARGGARKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQKPRSYESFNEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPNTSD
+MALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIYQE
+IMR
+
+>gi|116179624|ref|XP_001219661.1| mitogen-activated protein kinase [Chaetomium globosum CBS 148.51]
+MSNAQNRGGARKISFNVSEQYDIQDVVGEGAYGVVCSAVHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFDGTSD
+LALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIFQE
+IMR
+
+>gi|13430383|gb|AAK25816.1|AF348490_1 MAP kinase [Neurospora crassa]
+MSSAQRGGARKISFNVSEQYDIQDVVGEGAYGVVCSAVHKPSGQKVAIKKITPFDHSMFCLRTLREMKLL
+RYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSANV
+LHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSVG
+CILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPNTSEL
+ALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIYQEI
+MR
+
+>gi|58372548|gb|AAW71477.1| mitogen-activated protein kinase [Verticillium dahliae]
+MSRSNAPNPSGSRKISFNVSEQYDIQDVVGEGAYGPPSSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRGYDTFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLIY
+QEIMR
+
+>gi|5739482|gb|AAD50496.1|AF174649_1 mitogen activated protein kinase [Colletotrichum lagenarium]
+MSRANAPNPSGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|12657601|dbj|BAB21569.1| mitogen-activated protein kinase [Glomerella cingulata]
+MSRANPPNASGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|39961816|ref|XP_364720.1| mitogen-activated protein kinase [Magnaporthe grisea 70-15]
+MSRANPPSNSSGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPK
+TSDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQFI
+YQEIMR
+
+>gi|9858841|gb|AAG01162.1|AF286533_1 mitogen-activated protein kinase [Fusarium oxysporum f. sp. lycopersici]
+MSRSNPPNAAGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|12005890|gb|AAG44657.1|AF258529_1 MAP kinase 1 [Gaeumannomyces graminis]
+MSRAANPPSNSGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPQ
+DVGSRLDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQFI
+YQEIMR
+
+>gi|4321114|gb|AAC49521.2| pathogenicity MAP kinase 1; Pmk1; MAP kinase homolog [Magnaporthe grisea]
+MSRANPPSNSSGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYETFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQENNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPK
+TSDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDNLSKEQLKQFI
+YQEIMR
+
+>gi|45477412|gb|AAP93199.2| mitogen activated protein kinase [Metarhizium anisopliae]
+MSRSNPPNAGGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRGYDTFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPTPEEFFDFDKHKDTLSKEQLKQLIY
+QEIMR
+
+>gi|46124015|ref|XP_386561.1| hypothetical protein FG06385.1 [Gibberella zeae PH-1]
+MSRANPPNAAGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYESFQEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|62184237|gb|AAX73416.1| mitogen activated protein kinase 1 [Verticillium dahliae]
+MSRSNAPNPSGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRGYDTFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKCRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLIY
+QEIMR
+
+>gi|41688570|sp|Q00859.1|MAPK_FUSSO Mitogen-activated protein kinase (FsMAPK)
+MSRSNPPNPTGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFNEVYLIQELMETDMHRAIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|53988395|gb|AAV28228.1| mitogen-activated protein kinase [Trichoderma asperellum]
+MSRSNAPNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLIY
+QEIMR
+
+>gi|30313609|gb|AAO46014.1| MAP kinase TVK1 [Hypocrea virens]
+MSRSNPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVAARWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDLTFPDHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRT
+LFPKTSDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDTLSKEQL
+KQLIYQEIMR
+
+>gi|31322228|gb|AAO63561.1| mitogen activated protein kinase [Verticillium fungicola]
+MSRANPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRGYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPK
+TSDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLI
+YQEIMR
+
+>gi|23534536|gb|AAN34610.1| MAP kinase TmkA [Hypocrea virens]
+MSRSNPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPK
+TSDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLI
+YQEIMR
+
+>gi|13620175|emb|CAC36428.1| mitogen activated protein kinase [Gibberella fujikuroi]
+MSRSNPPNAAGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPQD
+LGSALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QEIMR
+
+>gi|32709397|gb|AAP86959.1| ERK-like protein CpMK2 [Cryphonectria parasitica]
+MSRSQAPNPAGSRKISFNVSEQYDIKDVVGEGAYCVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDKSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFKTLFPKT
+SELALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEEFFDFDKHKENLSKEQLKQLIY
+QEIMR
+
+>gi|18479080|gb|AAL73403.1| pathogenicity MAP kinase 1 [Gibberella zeae]
+MSRANPPNAAGSRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYESFQEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLIY
+QVIMW
+
+>gi|21636306|gb|AAM69918.1|AF452096_1 MAP kinase Tmk1 [Trichoderma atroviride]
+MSRSTAPNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPKT
+SDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLIY
+QEIMR
+
+>gi|83016539|dbj|BAE53432.1| MAP kinase Pmk1 [Hypocrea lixii]
+MSRSNPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRSYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFRTLFPK
+TSDLALDLLEKLLAFNPVKRITVEDALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDTLSKEQLKQLI
+YQEIMR
+
+>gi|156039459|ref|XP_001586837.1| mitogen-activated protein kinase [Sclerotinia sclerotiorum 1980]
+MASRAPNPSSGSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFKTMFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTANPIPEEFFDFDKNKDNLTKEQLKQLIY
+EEIMR
+
+>gi|10798897|gb|AAG23132.1|AF205375_1 MAP kinase [Botryotinia fuckeliana]
+MTARAPNPASGSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFKTMFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTANPIPEEFFDFDKNKDNLTKEQLKKLIY
+DEIMR
+
+>gi|15072770|emb|CAC47939.1| MAP kinase 1 [Claviceps purpurea]
+MSRANPPNAGGSRKISFNVSEHYDIQDVVGEGAYGVVCSAVHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRGYDSFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPPRVLFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTAPPIPEAFFDFDKHKDNLSKEQLKLLIY
+EEIMR
+
+>gi|33860247|gb|AAQ54908.1| mitogen activated protein kinase SMK1 [Sclerotinia sclerotiorum]
+MASRAPNPSSGSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRNYESFTEVYPIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFKTMFPKT
+SDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTANPIPEEFFDFDKNKDNLTKEQLKQLIY
+HEIMR
+
+>gi|119194681|ref|XP_001247944.1| mitogen-activated protein kinase [Coccidioides immitis RS]
+MVQPGAQGGSRKISFNVSDQYDIQDVIGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQKPRNYESFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPLKALFPKTSD
+LALDLLEKLLAFNPVKRITVEEALRHPYLEPYHDPDDEPTAEPIPEEFFDFDKNKDSLSKEQLKVLIYEE
+IMR
+
+>gi|23664456|gb|AAM89501.1| mitogen-activated protein kinase [Leptosphaeria maculans]
+MPPTGSGSSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREMKLL
+RYFNHENIISILDIQKPRNYETFTEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSANV
+LHRDLKPSNLLLNANCDLKVCDFGLARSAASTEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSVG
+CILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPWKAMFPKTNDL
+ALDLLERLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTADPIPEEFFDFDKNKDNLTKEQLKLLIYQEI
+MR
+
+>gi|169600893|ref|XP_001793869.1| MAP kinase [Phaeosphaeria nodorum SN15]
+MPPAGSGSSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREMKLL
+RYFNHENIISILDIQKPRNYETFTEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMHSANV
+LHRDLKPSNLLLNANCDLKVCDFGLARSAASTEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSVG
+CILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPWKAMFPKTNDL
+ALDLLERLLAFNPVKRITVEEALKHPYLEPYHDPDDEPTADPIPEEFFDFDKNKDNLTKEQLKLLIYQEI
+MR
+
+>gi|33242579|gb|AAQ01000.1| MAP kinase 1 [Beauveria bassiana]
+MSRANPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFDHENIISILDIQKPRGFDSFNEVYLIQELMETDMHRVIRTQVLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVLFRTLFAD
+TSDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDNLSKEQLKQLI
+YQEIMR
+
+>gi|15147362|gb|AAG53654.2|AF301165_1 MAP kinase-I [Blumeria graminis]
+MSTRAPNATTGSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPTGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQKPRSFDSFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLINANCDLKVCDFGLARSAASQEDCSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKQMFPKT
+SDLALDLLEKLLAFNPVKRITVDEALQHPYLEPYHDPEDEPTADPIPEEFFDFDKNKDNLSKEQLKELIF
+QEIMR
+
+>gi|154277902|ref|XP_001539783.1| mitogen-activated protein kinase [Ajellomyces capsulatus NAm1]
+MSLSVRSCLNTITMVQPSTSQGGSRKISFNVSDQYDIQDVIGEGAYGVVCSALHKPSSQKVAIKKITPFD
+HSMFCLRTLREMKLLRYFNHENIISILDIQKPRSYESFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFI
+YQTLRALKAMHSANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIML
+TFKEYTKAIDVWSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFK
+KKIPLKALFPKTSDLALDLLEKLLAFNPVKRISVEEALRHPYLEPYHDPEDEPTADPIPEEFFDFDKNKD
+SLSKEQLKVLIYEEIMR
+
+>gi|62362067|gb|AAX81518.1| putative MAP kinase [Mycosphaerella graminicola]
+MSRTAQQQQQQGSRKISFNVSEQYDIQDVVGEGAYGVVCSALHKPSGQKVAIKKISPFDHSMFALRTLRE
+MKLLRYFNHENIISILDIQKPKSYETFTEVYLIQELMETDMHRVIRTQELSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTEDNQGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPWKAMFPK
+TSDLALDLLEKLLAFNPTKRITVEEALKHPYLEPYHDPEDEPNAEPIPEEFFDFDKNKDNLSKEQLKRLI
+YEEIMR
+
+>gi|70992623|ref|XP_751160.1| MAP kinase MpkB [Aspergillus fumigatus Af293]
+MVQQPPQGGSRKISFNVSEQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSNE
+LALDLLEKLLAFNPAKRITVEEALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKTLIYEE
+IMR
+
+>gi|121700140|ref|XP_001268335.1| MAP kinase MpkB/Fus3 [Aspergillus clavatus NRRL 1]
+MVQQPPQGGSRKISFNVSEQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSNE
+LALDLLEKLLAFNPAKRITVEDALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKSLIYEE
+IMR
+
+>gi|145241049|ref|XP_001393171.1| hypothetical protein An08g10670 [Aspergillus niger]
+MVQQMPPQGGSRKISFNVSDQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMK
+LLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFRAMFPKSN
+ELALDLLEKLLAFNPAKRITVEEALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKLLIYE
+EIMR
+
+>gi|119472832|ref|XP_001258423.1| MAP kinase MpkB/Fus3 [Neosartorya fischeri NRRL 181]
+MVQQPPQGGSRKISFNVSEQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMKL
+LRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSAN
+VLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSV
+GCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSNE
+LALDLLEKLLAFNPAKRITVEDALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKTLIYEE
+IMR
+
+>gi|118345322|gb|AAF12815.2|AF198118_1 mitogen-activated protein kinase [Emericella nidulans]
+MVQQMPPQGGSRKISFNVSDQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMK
+LLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSN
+DLALDLLEKLLAFNPTKRITVEEALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKILIYE
+EIMR
+
+>gi|115389978|ref|XP_001212494.1| mitogen-activated protein kinase [Aspergillus terreus NIH2624]
+MVQQLPPQGGSRKISFNVSDQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMK
+LLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSN
+ELALDLLERLLAFNPAKRITVEEALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKILIYE
+EIMR
+
+>gi|169770233|ref|XP_001819586.1| hypothetical protein [Aspergillus oryzae RIB40]
+MVQQLPPQGGSRKISFNVSDQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMK
+LLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKAN
+DLALDLLERLLAFNPAKRITVEEALRHPYLEPYHDPEDEPTAPPIPEGFFDFDKNKDALSKEQLKILIYE
+EIMR
+
+>gi|4323053|gb|AAD16178.1| pyruvate decarboxylase [Aspergillus oryzae]
+MSLSTSSGDFVRLAFVQYTVFLVSINAPAWDYNLVALDYLPKCDLHWVGNCNELNAGYAADGYARINGMS
+ALVTTFGVGELSALNAIAGAYSEFVPIVHIVGQPHTKSQKDGMLLHHTLGNGDFNVFTRMSADISCTLGC
+LNSTHEVATLIDNAIRECWIRSRPVYISLPTDMVTKKIEGERLDTPLDLSLPPNDPEKEDYVVDVVLKYL
+HAAKKPVILVDACAIRHRVLDEVHEFVEKSGLPTFVAPMGKGAVDETHKNYGGVYAGTGSNPGVREQVES
+SDLILSIGAIKSDFNTTGFSYRIGQLNTIDFHSTYVRVRYSEYPDINMKGVLQKIVQRMGNLNVGPVSPP
+SNLLPDNEKASTEQAITHAWLWPTVGQWLKEKDVVITETGTANFGIWDTRFPAGVTAISQVLWGSIGYSV
+GACQGAALAAKEQGRRTVLFVGDGSFQLTLQEVSTMIRNNLNPIIFVICNEGYTIERYIHGWEAVYNDIQ
+PWDFLNIPVAFGAKDKYKGYKVTTRDELRELFANEEFASAPCLQFEIDSRIGR
+
+>gi|111380705|gb|ABH09728.1| FUS3-like protein [Penicillium marneffei]
+MAQGQNSTHGGSRKISFNVSDQYDIQDVIGEGAYGVVCSALHKPSGQKVAIKKITPFDHSMFCLRTLREM
+KLLRYFNHENIISILDIQRPRSYDSFTEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHS
+ANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVW
+SVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKHLFPKT
+TDLALDLLEKLLAFNPAKRITVEEALRHPYLEPYHDPDDEPTADPIPEEFFDFDKNKDTLSKEQLKLCRD
+NPGSSFTLTQSDLELNPSRYGIKHSKISRSPPTLSELAEKLQGSLSANYERSSVTVVPCLDLREPPFLLA
+HEGLSGDEKVADVGGQTHLYPRPMRDKTYALISISREMEIEVGESHEQVMIIGAGAGSSDIVGQNCEMAI
+NFGWRYGGGGGGGGGGGGGVPQGSWRHNGGRYVKIEPGTDSVLLEKTDSARWWFGLMGNLFASDGGPGDV
+LKITARKRVGEEGSFTECIRKALHAAYGDSQIVSLGGVFVIKSGKARYHIMPDFPPEELPFRDRQRFNDW
+LTYHDFKGPMTCLTVLHSVDPDKKLGLRMEHTHALSTVGENAGGHYHYDVEEEKEEIEYEGYFNTAKALY
+RIDKPEFSLEQVLQK
+
+>gi|67526523|ref|XP_661323.1| hypothetical protein AN3719.2 [Aspergillus nidulans FGSC A4]
+MVQQMPPQGGSRKISFNVSDQYEIQDVIGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLREMK
+LLRYFNHENIISILDIQRPRNYESFNEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKVCDFGLARSAASTDDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKIPFKALFPKSN
+DLALDLLEKLLAFNPTKRITVEEALRHPYLEPYHDPDDEPTAPPIPEGFFDFDKNKDALSKEQLKSKYLA
+PIDSISYATIN
+
+>gi|33088202|gb|AAP93200.1| mitogen activated protein kinase [Beauveria bassiana]
+MSRANPPNNASASRKISFNVSEQYDIQDVVGEGAYGVVCSAIHKPSGQKVAIKKITPFDHSMFCLRTLRE
+MKLLRYFNHENIISILDIQKPRGFDSFNEVYLIQELMETDMHRVIRTQVLSDDHCQYFIYQTLRALKAMH
+SANVLHRDLKPSNLLLNANCDLKVCDFGLARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDV
+WSVGCILAEMLSGKPLFPGKDYHHQLTLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVLFRTLFAD
+TSDLALDLLEKLLAFNPVKRITVEEALKHPYLEPYHDPEDEPTAPPIPEEFFDFDKHKDN
+
+>gi|2160688|gb|AAB63012.1| pyruvate decarboxylase [Emericella nidulans]
+MADIATRDVRQPIDIAEYLFRRLHEVGIRSVHGVPGDYNLAALDYLPKCGLHWVGNCNELNAGYAADGYA
+RVNGIAALVTTFGVGELSAINAIAGRYSEFVPIIHIVGQPHSRSQKDGLLLHHTLGNGDYNVFSSMNKGI
+SVTTANLNDTYDAATLIDNAIRECWIHSRPVYLALPTDMITKKIEGERLKTPIDLSLPANDPEKEDYVLV
+DARAQVFARSAKNPVILVDDSCVFDDSTGLSLEEVHDLIEVSGLPTFVAPMGKGAVNETHRCYGGVYAGT
+GSNPGVREQVESSDLILSIGAIKSDFNTAGFSYRIGQLNTIDFHTTYVRVRYSEYPDTNMKGVLRKVIQR
+LGFIKADPVPHISNALPEHEKNSSEQRITHAWMWPMVGQWLKENDIVITETGTANFGICWNLLPSELQPI
+SQVLWGSIGYSVGACQGAALAAKEQGNRRTVLWVGDGSLQLTLQEISTMIRNNLNPIIFVICGEGYTIER
+FIHGWDESYNDIQTWDIKGLPVAFGGKGRYKGYKVTTRDELTKLFASEEFSSTPCLQVSLCDLTHYLSDA
+NFEQLG
+
+>gi|162312366|ref|XP_001713041.1| pyruvate decarboxylase [Schizosaccharomyces pombe]
+MSGDILVGEYLFKRLEQLGVKSILGVPGDFNLALLDLIEKVGDEKFRWVGNTNELNGAYAADGYARVNGL
+SAIVTTFGVGELSAINGVAGSYAEHVPVVHIVGMPSTKVQDTGALLHHTLGDGDFRTFMDMFKKVSAYSI
+MIDNGNDAAEKIDEALSICYKKARPVYIGIPSDAGYFKASSSNLGKRLKLEEDTNDPAVEQEVINHISEM
+VVNAKKPVILIDACAVRHRVVPEVHELIKLTHFPTYVTPMGKSAIDETSQFFDGVYVGSISDPEVKDRIE
+STDLLLSIGALKSDFNTGSFSYHLSQKNAVEFHSDHMRIRYALYPNVAMKYILRKLLKVLDASMCHSKAA
+PTIGYNIKPKHAEGYSSNEITHCWFWPKFSEFLKPRDVLITETGTANFGVLDCRFPKDVTAISQVLWGSI
+GYSVGAMFGAVLAVHDSKEPDRRTILVVGDGSLQLTITEISTCIRHNLKPIIFIINNDGYTIERLIHGLH
+ASYNEINTKWGYQQIPKFFGAAENHFRTYCVKTPTDVEKLFSDKEFANADVIQVVELVMPMLDAPRVLVE
+QAKLTSKINKQ
+
+>gi|74675981|sp|O42781.1|MAPK2_PNECA Mitogen-activated protein kinase 2 (PCM)
+MTASSRNVRFNVSDDYEILDVIGEGAYGIVCSAIHKPSGQKVAIKKISPFDHSMFCLRTLREMKLLRYFN
+HENIISILDIQQPQDFESFSEVYLIQELMETDMHRVIRTQDLSDDHCQYFIYQILRALKAMHSADILHRD
+LKPSNLLLNANCDLKVCDFGLARSAVSTEDSSSFMTEYVATRWYRAPEIMLTFKEYTKAIDIWSVGCILA
+EMLSGRPLFPGKDYHHQLMLILDVLGTPTMEDYYGIKSRRAREYIRSLPFKKRVSFASIFPRANPLALDL
+LEKLLAFNPAKRVTAEEALQHNYLEPYHDPDDEPTAPPISPSFFDFDRIKDSLTKNDLKILIYKEIMSMN
+N
+
+>gi|50553802|ref|XP_504312.1| hypothetical protein [Yarrowia lipolytica]
+MSKPKPSEVRTLAFNVSDHYQILDMVGEGAYGIVCSALHTPSGQKVAIKKITPFGRSMFCLRTLREIKLL
+RHFSHENIIGILDVQKPASFESFNEVYLIQELMDTDLHRVIRTQELSDDHCQYFVYQTLRAIKALHSANV
+LHRDLKPSNLLLNASCDLKICDFGLARSAASTEDNFGFMTEYVATRWYRAPEIMLTFKEYTKAIDMWSIG
+CILAEMLGGRPLFPGRDYHSQLTMILDVLGTPTMEDYYSVKSRRAREYIRSLPFKKKLPFSQLFPKANPL
+AIDLLEKLLTFNPAKRITVEEALVHPYLEQYHDADDEPTAEPIPDEFFDFDRNKDELSVEQLKTLIYNEI
+MYWKRP
+
+>gi|45185554|ref|NP_983270.1| ACL134Cp [Ashbya gossypii ATCC 10895]
+MVSGLSKKKTTAKQLSKLTINTMSEITLGRYLFERLRQIEVQTIFGLPGDFNLSLLDKIYEVEGMRWAGN
+ANELNAAYAADGYARLKGMSCLITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISAQAKQLLLHHTLG
+NGDFTVFHRMSANISGTTAMISDITSAPAEIDRCIRTCYITQRPVYLGLPANMVDLKVPASLLETPIDLN
+LKPNDPEAEAEVVETVLEMIAAAKNPVILSDACASRHDVKAETMKLIDVTQFPAFVTPMGKGSIYEQHPR
+FGGVYVGTLSSPEVKEAVESADLVLSVGALLSDFNTGSFSYSYKTKNVVEFHSDHIKIRNATFPGVQMKY
+VLRKLVDNVAEVIKSYVPVPVPSKPANNEEIDSATPLKQEWLWNQVGKFLREGDVVITETGTSAFGINQT
+HFPNNTYGISQVLWGSIGFTTGACLGAAFAAEELDPNRRVILFIGDGSLQLTVQEISTMVRWGLKPYLFV
+LNNDGYTIERLIHGETAQYNDIQPWQHLNLLPTFGAKDYEAVRVSTTGEWDALTQDKAFNENSKIRMIEV
+MLPVMDAPSNLVKQAELTAATNAKQE
+
+>gi|82491927|gb|ABB77843.1| MAP kinase [Phycomyces blakesleeanus]
+MTQPSRRNDMSRLQQFDAGEQYSIVDIVGEGAYGVVCSAVHKPTGQTVAIKRILPFDHAMFCLRTLREIK
+LLKYFNHENIISILDIVKPKSYDEFTEVYLIQELMETDLHRVIRTQDLSDDHCQYFTYQTLRALKAMHSA
+NVLHRDLKPSNLLLNANCDLKICDLGLARSANSADENSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWS
+VGCILAEMLSGKPLFPGRDYHHQLTLILDVLGTPTMDDFYGIKSRGARDYIRSLPFKKRIPFARLFPEAT
+VDLLEKLLSFNPDRRITVEEALKHPYLEAYHDPDDEPNATPIHESFFDFDKYKDQLTKEQLKRKFFFHII
+KRKKERLTQNIYINMYITEMLYEEITQ
+
+>gi|146418962|ref|XP_001485446.1| hypothetical protein PGUG_03175 [Pichia guilliermondii ATCC 6260]
+MTEITLGRYLFERLSQLNVNSIFGVPGDFNLSLLDKIYEVDGMRWAGNANELNAAYAADGYSRIKGLSCL
+VTTFGVGELSALNGVAGAYAEHVGLLHVVGIPSITSQAKQLLLHHTLGNGDFTVFHRMSNNISQTTAFIS
+DINHAPKEIDRCIREAYVYQRPVYVGLPANLVDLKVPASLLDTPLDTSLKPNDPDAQEEVVDLVLKLISE
+AKDPIILVDACASRHNCRGEVEKLVDVTQFPVFTTPMGKSTINESHKRFGGVYVGTLSQPEVKEAVESAD
+LVLSVGALLSDFNTGSFSYSYKTKNIVEFHSDYTKIRQATYPGVQMKEALRKLLESVAQALKGYQPCPVP
+NVKLLNTPGPASTQLSQEWLWTKVSSWFREGDIIITETGTSAFGIVQSRFPNQTVGISQVLWGSIGFTVG
+ATLGAVMAAQEIDPAKRVILFVGDGSLQLTVQEISTMVKWETTPYLFVLNNDGYTIERLIHGVNATYNDI
+QPWNNLALLPLFNARNYETYQVSTTGEIDKLFSDPDFATNSKIRMIEVMLPRMDAPANLVAQATLSAQTN
+AEN
+
+>gi|25992752|gb|AAN77243.1| pyruvate decarboxylase [Candida glabrata]
+MSEITLGRYLFERLNQVDVKTIFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMVT
+DIATAPAEIDRCIRTTYITQRPVYLGLPANLVDLKVPAKLLETPIDLSLKPNDPEAETEVVDTVLELIKA
+AKNPVILADACASRHDVKAETKKLIDATQFPSFVTPMGKGSIDEQHPRFGGVYVGTLSRPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDYIKIRNATFPGVQMKFALQKLLNAVPEAIKGYKPVPVP
+ARVPENKSCDPATPLKQEWMWNQVSKFLQEGDVVITETGTSAFGINQTPFPNNAYGISQVLWGSIGFTTG
+ACLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGEKAGYNDI
+QNWDHLALLPTFGAKDYENHRVATTGEWDKLTQDKEFNKNSKIRMIEVMLPVMDAPTSLIEQAKLTASTN
+AKQ
+
+>gi|156845801|ref|XP_001645790.1| hypothetical protein Kpol_1010p48 [Vanderwaltozyma polyspora DSM 70294]
+MSEITLGRYLFERLKQVQVQTIFGLPGDFNLSLLDKIYEVPGMRWAGNANELNAAYAADGYARIKGMACL
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSLSSQAKQLLLHHTLGNGDFTVFHRMSACISETTAMIT
+DIANAPAEIDRCIRTTYITQRTVYLGLPANMVDLMVPADLLKTPIDLSLKPNDPEAETEVLDTILAMVKE
+AKNPIILADACASRHDVKAETKQLIDTTQFPCFVTPMGKGSIDEQHPRFGGVYVGTLSRPEVKAAVESAD
+LILSVGALLSDFNTGSFSYSYQTKNVVEFHSDHTKIKKASFPGVQMKFVLQKLVAQIGAAVKDYKPVAAP
+ALPASNAECPASTPLKQEWLWNQVGKFLQEGDIVLTETGTSAFGINQTHFPNNTYGISQVLWGSIGFTGG
+ATLGAAFAAEEIDPKKRTIVFIGDGSLQLTVQEISTMIRWNLKPYIFVLNNDGYTIEKLIHGPTAQYNEI
+QNWKHLDILPTFGAKDYEAIRVATTGEFNKLCEDKAFNENSKIRMIEIMLPVMDAPSNLVAQAKLTASIN
+AKQ
+
+>gi|6323073|ref|NP_013145.1| Major of three pyruvate decarboxylase isozymes, key enzyme in alcoholic fermentation, decarboxylates pyruvate to acetaldehyde; subject to glucose-, ethanol-, and autoregulation; involved in amino acid catabolism; Pdc1p [Saccharomyces cerevisiae]
+MSEITLGKYLFERLKQVNVNTVFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISAQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLNVPAKLLQTPIDMSLKPNDAESEKEVIDTILALVKD
+AKNPVILADACCSRHDVKAETKKLIDLTQFPAFVTPMGKGSIDEQHPRYGGVYVGTLSKPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHMKIRNATFPGVQMKFVLQKLLTTIADAAKGYKPVAVP
+ARTPANAAVPASTPLKQEWMWNQLGNFLQEGDVVIAETGTSAFGINQTTFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIEKLIHGPKAQYNEI
+QGWDHLSLLPTFGAKDYETHRVATTGEWDKLTQDKSFNDNSKIRMIEIMLPVFDAPQNLVEQAKLTAATN
+AKQ
+
+>gi|416888|sp|P33149.1|PDC1_KLUMA Pyruvate decarboxylase
+MSEITLGRYLFERLKQVEVQTIFGLPGDFNLSLLDKIYEVPGMRWAGNANELNAAYAADGYARLKGMACV
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSSNISETTAMIT
+DINSAPSEIDRCIRTTYISQRPVYLGLPANLVDLKVPASLLETPIDLSLKPNDPEAENEVLETVLELIKD
+AKNPVILADACCSRHNVKAETKKLIDITQFPAFVTPMGKGSIDEQHPRFGGVYVGTLSSPEVKEAVESAD
+LVLSVGALLSDFNTGSFSYSYKTKNIVEFHSDYIKVRNATFPGVQMKFVLQKLLTKVKDAAKGYKPVPVP
+HAPRDNKPVADSTPLKQEWVWTQVGKFLQEGDVVLTETGTSAFGINQTHFPNDTYGISQVLWGSIGFTGG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGETAQYNCI
+QSWKHLDLLPTFGAKDYEAVRVATTGEWNKLTTDKKFQENSKIRLIEVMLPVMDAPSNLVKQAQLTASIN
+AKQE
+
+>gi|7245976|pdb|1QPB|A Chain A, Pyruvate Decarboyxlase From Yeast (Form B) Complexed With Pyruvamide
+MSEITLGKYLFERLKQVNVNTVFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISAQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLNVPAKLLQTPIDMSLKPNDAESEKEVIDTILVLIKD
+AKNPVILADACCSRHDVKAETKKLIDLTQFPAFVTPMGKGSIDEQHPRYGGVYVGTLSKPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHMKIRNATFPGVQMKFVLQKLLTAIADAAKGYKPVAVP
+ARTPANAAVPASTPLKQEWMWNQLGNFLQEGDVVIAETGTSAFGINQTTFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIEKLIHGPKAQYNEI
+QGWDHLSLLPTFGAKDYETHRVATTGEWDKLTQDKSFNDNSKIRMIEVMLPVFDAPQNLVEQAKLTAATN
+AKQ
+
+>gi|50294560|ref|XP_449691.1| hypothetical protein CAGL0M07920g [Candida glabrata CBS138]
+MSEITLGRYLFERLNQVDVKTIFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMVT
+DIATAPAEIDRCIRTTYITQRPVYLGLPANLVDLKVPAKLLETPIDLSLKPNDPEAETEVVDTVLELIKA
+AKNPVILADACASRHDVKAETKKLIDATQFPSFVTPMGKGSIDEQHPRFGGVYVGTLSRPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDYIKIRNATFPGVQMKFALQKLLNAVPEAIKGYKPVPVP
+ARVPENKSCDPATPLKQEWMWNQVSKFLQEGDVVITETGTSAFGINQTPFPNNAYGISQVLWGSIGFTTG
+ACLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGEKAGYNDI
+QNWDHLALLPTFGAKDYENHRVATTGEWDKLTQDKEFNKNSKIRMIEVMLPVMDAPTSLIEQAKLTASIN
+AKQE
+
+>gi|37359468|gb|AAP75898.1| pyruvate decarboxylase [Saccharomyces kluyveri]
+MSEITLGRYLFERLNQVEVQTIFGLPGDFNLSLLDKIYEVPGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSVSSQAKQLLLHHTLGNGDFTVFHRMSANISETTAWVT
+DIATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLMVPASLLDTPIDLSLKPNDPEAEAEVVNTVLELIKD
+AKNPVILADACASRHNVKSETKQLIDITQFPAFVTPLGKGSIDEQHPRFGGVYVGTLSNDDVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDYIKIRNATFPGVQMKFALQKLLSQVGEVVKDYKPVAVP
+AKPTPNPACDPSTPLKQEWVWNQVGRFLQEGDVVITETGTSAFGINQTHFPNNTYGISQVLWGSIGFTTG
+ACLGAACAAEELDKNKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGENAQYNEI
+QPWKNLDLLPTFGAKDYETYRVATTGEWDKLAQDEAFNKNSRIRMVEVMLPVMDAPSNLVKQAQLTASIN
+AKQE
+
+>gi|50288125|ref|XP_446491.1| unnamed protein product [Candida glabrata]
+MTEITLGRYLFERLHQIHIDTIFGLPGDFNLTLLDKIYEVEGLRWAGNANELNAAYAADGYARLKGMACL
+LTTFGVGELSALNGIAGSYAEHVGVLHVVGVPSTVSRAKQLLLHHTLGNGDFDAFHRMSSVISETTFIVS
+DPQTAPAEIDRCIRVCYLTQRPVYLGIPANMFDSKVSSKLLDTPIDLALRPNLPDAEREVLDEIITMIKA
+SKRPIILADACTSRHDVKKETKRLIEVTQFPSFTTPMGKGSIDEDTPRFGGVYVGNLSDPEVKTFVEESD
+LVLSVGALLSDFNTGSFSYSLNTRNVIEFHSDHMKIRNATFPGVQMKFVLEKLLEELPAVVKGRTDNRVV
+PRQKEPSTTLNGKDAIKQEWMWKHVGKFLQEGDVVVTETGTSGFGIVESKFPRNTVGISQVLWGSIGYAL
+GSTVGAAFAAQEIDPKKRVILFIGDGSLQLTVQELSTAARWGLTPYIFVLNNNGYTIERLIHGETQGYND
+IQSWDHSLILPAFGAKNYENKRVATYGEWNDMVNDKQFNKNDKLRMIEVMLPTMDGPENLKKQAKLTASI
+NAKN
+
+>gi|45184751|ref|NP_982469.1| AAL073Wp [Ashbya gossypii ATCC 10895]
+MSEITLGRYLFERLKQVEVRTIFGVPGDFNLSLLDKVYEVDGMRWAGNANELNASYAADGYARVKKISCL
+VTTFGVGELSALNGIAGSYAEHVGVLHVVGVPSTSAQAKQLLLHHTLGNGDFTVFHRMSANISDTTAVIT
+DISSAPAEIDRCIRACYVHQRPVYLGLPANMVDLTVPASLLNTEIDLSLKPNDPEAEEEVVSTVLELVAN
+AKHPVILSDACASRHDVKQETKQLIDVTQFPAFVTPMGKGSIDEQHPRFGGVYVGTLSAPDVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHTKIRSATFPGIKMKTVLQNLVKRIGEAAKGYQPSPVP
+TYAAPNEDADPKTPLKQEWLWNQVSSFLKEGDIVITETGTAAFGINQTRFPSSTIGISQVLWGSIGFTTG
+ACLGAAFAAEEIDPNKRVILFIGDGSLQLTVQEISTMVRWGLKPYLFVLNNDGYTIERLIHGETAQYNCI
+QPWKHLDLLPTFGAKDYETHRVATTGEWRALTEKQEFNKNSSIRMIEIMLDVMDAPSSLIKQAKLTAATN
+AQP
+
+>gi|871533|emb|CAA54522.1| pyruvate decarboxylase [Saccharomyces cerevisiae]
+MSEITLGKYLFERLKQVNVNTVFGLPGDFNLSLLDKIYEVEGMRWAGNANELNARYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DICTAPAEIDRCIRTTYVTQRPVYLGLPANLVDLNVPAKLLQTPIDMSLKPNDAESEKEVIDTILVLAKD
+AKNPVILADACCSRHDVKAETKKLIDLTQFPAFVTPMGKGSISEQHPRYGGVYVGTLSKPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHMKIRNATFPGVQMKFVLQKLLTNIADAAKGYKPVAVP
+ARTPANAAVPASTPLKQEWMWNQLGNFLQEGDVVIAETGTSAFGINQTTFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIEKLIHGPKAQYNEI
+QGWDHLSLLPTFGAKDYETHRVATTGEWDKLTQDKSFNDNSKIRMIEVMLPVFDAPQNLVEQAKLTAATN
+AKQ
+
+>gi|40645549|dbj|BAD06585.1| MAP kinase [Candida tropicalis]
+MMNIDQHHQQLQQQSQAQAQAQAQAQAQAQAQAQAQAQAQAAAAAVAASSQRQVSFNVSDHYQILEIVGE
+GAYGIVCSAIHKPSNQKVAIKKIEPFERSMLCLRTLRELKLLKHFNHENIISILAIQRPLNFESFNEIYL
+IQELMETDLHRVIRTQNLTDDHIQYFIYQTLRALKAMHSANVLHRDLKPSNLLLNSNCDLKVCDFGLARS
+IASQEDNYGFMTEYVATRWYRAPEIMLTFQEYTTAIDVWSVGCILAEMLSGRPLFPGRDYHNQLWLIMEV
+LGTPNMEDYYNIKSKRAREYIRSLPFCKKIPFQELFSNKPGINPLALDLLEKLLIFNPAKRITVEDALKH
+PYLQLYHDPNDEPISDKIPEDFFDFDKKKDSLTIEDLKKMLYEEIMKPL
+
+>gi|157879677|pdb|1PVD|A Chain A, Crystal Structure Of The Thiamin Diphosphate Dependent Enzyme Pyruvate Decarboxylase From The Yeast Saccharomyces Cerevisiae At 2.3 Angstroms Resolution
+SEITLGKYLFERLKQVNVNTVFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCII
+TTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMITD
+IATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLNVPAKLLQTPIDMSLKPNDAESEKEVIDTILALVKDA
+KNPVILADACCSRHDVKAETKKLIDLTQFPAFVTPMGKGSISEQHPRYGGVYVGTLSKPEVKEAVESADL
+ILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHMKIRNATFPGVQMKFVLQKLLTNIADAAKGYKPVAVPA
+RTPANAAVPASTPLKQEWMWNQLGNFLQEGDVVIAETGTSAFGINQTTFPNNTYGISQVLWGSIGFTTGA
+TLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIEKLIHGPKAQYNEIQ
+GWDHLSLLPTFGAKDYETHRVATTGEWDKLTQDKSFNDNSKIRMIEIMLPVFDAPQNLVKQAKLT
+
+>gi|515236|pdb|1PYD|A Chain A, Catalytic Centers In The Thiamin Diphosphate Dependent Enzyme Pyruvate Decarboxylase At 2.4 Angstroms Resolution
+MSEITLGKYLFERLKQVNVNTVFGLPGDFNLSLLDKIYEVEGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLNVPAKLLQTPIDMSLKPNDAESEKEVIDTILALVKD
+AKNPVILADACCSRHDVKAETKKLIDLTQFPAFVTPMGKGSISEQHPRYGGVYVGTLSKPEVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDHMKIRNATFPGVQMKFVLQKLLTNIADAAKGYKPVAVP
+ARTPANAAVPASTPLKQEWMWNQLGNFLQEGDVVIAETGTSAFGINQTTFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIEKLIHGPKAQYNEI
+QGWDHLSLLPTFGAKDYETHRVATTGEWDKLTQDKSFNDNSKIRMIEIMLPVFDAPQNLVKQAKLT
+
+>gi|37359470|gb|AAP75899.1| pyruvate decarboxylase [Saccharomyces kluyveri]
+MSEITLGRYLFERLKQVQVQTIFGLPGDFNLSLLDKIYEVPGLRWAGNANELNAAYAADGYARVKGMSCI
+VTTFGVGELSALNGIAGSYAEHVGVLHVVGVPSVSSQAQQLLLHHTLGNGDFTVFHRMSSEISETTAVIT
+DIKDAPKEIDRCIKVTYSKQRPVYLGLPANLVDLKVSASLLDTPIDLSMTPNDADAEDEVVETVLAMVSK
+AKNPVILADACCTRHDVKRETKKLIDLTQFPAFVTPMGKGSIDEDHPRFGGVYVGTLSDPEVKEAVESAD
+LVLSVGALLSDFNTGSFSYSYKTKNIVEFHSDYTKVRNATFPGVQMKLVLQKLLSKVSDAASGYKPVPVP
+KGTRSNPGVESSTPLKQEWIWNHISDWLEEGDVVITETGTSAFGINQSRFPNSTYGISQVLWGSIGYSVG
+SCLGAAFAAEELDKNRRVILFVGDGSLQLTVQEISTMVRWGLKPYLFVLNNDGYTIERLIHGETAQYNDV
+QPWLHLNLLPTFGAKDYDSIRISTTGEFLKLTEDQAFSRNSKIRLIEVMLPVMDAPSTLVKQAQLTAATN
+AKQG
+
+>gi|34500072|gb|AAQ73618.1| pyruvate decarboxylase [Saccharomyces kluyveri]
+MSEITLGLYLFERLNQVDVKTIFGLPGDFNLSLLDKIYEVPGMRWAGNANELNAAYAADGYARVKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSVSSQAKQLLLHHTLGNGDFTVFHRMSANISETTAWVT
+DIATAPAEIDRCIRTTYVTQRPVYLGLPANLVDLMVPASLLDTPIDLSLKPNDPEAEAEVVNSVLELIKD
+AKNPIILADACASRHDVKPETKQLIDITQFPAFVTPLGKGSIDEQHPRFGGVYVGTLSNDDVKEAVESAD
+LILSVGALLSDFNTGSFSYSYKTKNIVEFHSDYIKIRNATFPGVQMKFALQKLLSEIGAVVKDYKPVAVP
+PKPTPNPACDPSTPLKQEWVWNQVGRFLQEGDVVITETGTSAFGINQTHFPNNTYGISQVLWGSIGFTTG
+ACLGAACAAEELDKNKRVILFIGDGSLQLTVQEISTMIRWGLRPYLFVLNNDGYTIERLIHGENAQYNEI
+QPWKNLDLLPTFGAKDYETYRVATTGEWDKLAQDEAFNKNSRIRMVEVMLPVMDAPSNLVKQAQLTASIN
+AKQD
+
+>gi|6689662|emb|CAB65554.1| putative pyruvate decarboxylase [Zygosaccharomyces bisporus]
+MSEITLGRYLFERLRQVDTNTIFGVPGDFNLSLLDKIYEVQGLRWAGNANELNAAYAADGYARVKGMAAL
+VTTFGVGELSALNGIAGSYAEHVGVLHIEGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAWLT
+DITTAPAEIDRCIRVTYLTQRPVYLGLPANLTDQKVPASLLNTPIDLSLKENDPEAEAEVVETVLELIKE
+AKNPIILADACCSRXDVKAETKKLIDITQFPSFVTPMGKGSIDEQNPRFGGVYVGTLSSPAVKKAVESAD
+LVLSVGALLSDFNTGSFSYSYKTKNVVEFHSDHIKIRNATFPGVQMKFVLEDLLKKVPAAVKGYNPGPVP
+PAPSPNAEVAASTPLKQEWLWRQVGKFLQEGDIVITETGTSAFGINQSHFPNRTYGISQVLWGSIGYTTG
+STLGAAFAAEEIDPKKRVVLFIGDGSLQLTVQEISTMVRWGLKPYLFVLNNDGYTIERLIHGEKAQYNDI
+QPWKNLELLHAFGATDYETHRVATVGDWDKLTTDSKFNENSRIRMIEVMLETMDAPSSLVAQAQLTAAIN
+AKQ
+
+>gi|50412425|ref|XP_457131.1| hypothetical protein DEHA0B03784g [Debaryomyces hansenii CBS767]
+MSEVSLGRYIFERLRQLLVQTVFGLPGDFNLSLLDKIYEVDGLRWAGNANELNAAYAADGYSRVKGLACL
+ITTFGVGELSALNGIGGAFAEHVGLVHIVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSNNISQTTAFIS
+DIKSAPKEIDRCIREAYIFQRPVYIGLPANLVDINVPAVLLNIPIDLSLRENDPEAQEEVIDNILQLISE
+ASNPVILVDACTSRHNCNGEVEALVNKTQFPVLTTPMGKSSFNESHPRFAGVYVGTMSHVEVKNLVDGAD
+LILAVGALLSDFNTGSFSYSYKTKNVIEFHADCIKIKQGTYPGVQMKEVLNVLIDKIDPAVKHYNPIAIP
+SPTFLTNSVTNSDVLSALLTQEWLWSKVSAWFREGDIIITETGTSAFGIVQTKFPNNTIGISQVLWGSVG
+FTVGATLGAVMAAEEIDPNKRVILFVGDGSLQLTVQEISTMVKWETRPYLFVLNNDGYTIDRLIHGMSAT
+YNDIQPWNNLALLPLFNAKYYDAIQVSTTDELEKLFCDEEFAINSKIRMIEVMLPRMDAPINLIKQMEFI
+SKMNADT
+
+>gi|50309353|ref|XP_454684.1| DCPY_KLULA [Kluyveromyces lactis]
+MSEITLGRYLFERLKQVEVQTIFGLPGDFNLSLLDNIYEVPGMRWAGNANELNAAYAADGYARLKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSVSSQAKQLLLHHTLGNGDFTVFHRMSSNISETTAMIT
+DINTAPAEIDRCIRTTYVSQRPVYLGLPANLVDLTVPASLLDTPIDLSLKPNDPEAEEEVIENVLQLIKE
+AKNPVILADACCSRHDAKAETKKLIDLTQFPAFVTPMGKGSIDEKHPRFGGVYVGTLSSPAVKEAVESAD
+LVLSVGALLSDFNTGSFSYSYKTKNIVEFHSDYTKIRSATFPGVQMKFALQKLLTKVADAAKGYKPVPVP
+SEPEHNEAVADSTPLKQEWVWTQVGEFLREGDVVITETGTSAFGINQTHFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGETAQYNCI
+QNWQHLELLPTFGAKDYEAVRVSTTGEWNKLTTDEKFQDNTRIRLIEVMLPTMDAPSNLVKQAQLTAATN
+AKN
+
+>gi|1169549|sp|P28869.2|ERK1_CANAL Extracellular signal-regulated kinase 1 (ERK1) (MAP kinase 1) (MAPK 1)
+MMNIDQHHQLQQQHQQQMLQQQAQAQAQAQAQAQQQQQAAAAAAAANAAATTSSSSPRQVSFNVSDHYQI
+LEIVGEGAYGIVCSAIHKPSQQKVAIKKIEPFERSMLCLRTLRELKLLKHFNHENIISILAIQRPINYES
+FNEIYLIQELMETDLHRVIRTQNLSDDHIQYFIYQTLRALKAMHSANVLHRDLKPSNLLLNSNCDLKICD
+FGLARSIASQEDNYGFMTEYVATRWYRAPEIMLTFQEYTTAIDVWSVGCILAEMLSGRPLFPGRDYHNQL
+WLIMEVLGTPNMEDYYNIKSKRAREYIRSLPFCKKIPFSELFANTNNNTSTSNTGGRTNINPLALDLLEK
+LLIFNPAKRITVEDALKHPYLQLYHDPNDEPISDKIPEDFFDFDKMKDQLTIEDLKKLLYEEIMKPL
+
+>gi|461921|sp|P34734.1|PDC_HANUV Pyruvate decarboxylase
+MSEITLGRYVFERIKQVGVNTIFGLPGDFNLSLLDKIYEVEGLRWAASLNELNAAYAADGYSRIKGLGVI
+ITTFGVGELSALNGIAGAYAEHVGVLHIVGVPSLASQAKQLLLHHTLGNGDFDVFHRMSANISETTAMIT
+DLAAAPAEIDRCIRTAYIAQRPVYLGLPANLVDLNVPAKLLETKIDLALKANDAEAENEVVETILALVAD
+AKNPVILSDACASRHNVKAEVKQLIDATQFPAFVTPLGKGSIDEKHPRFGGVYVGTLSSPEVKQSVESAD
+LILSVGALLSDFNTGSFSYSYQTKNIVEFHSDYIKIKNASFPGVQMKFVLEKLIAKVGAKIANYSPVPVP
+AGLPKNAPVADSTPLAQEWLWNELGEFLEEGDIVVTETGTSAFGINQTRFPTDAYGISQVLWGSIGYSVG
+AMVGATFAAEELDKAKRVILFVGDGSLQLTVQEIACLIRWGLKPYIFVLNNNGYTIEKLIHGPTAQYNMI
+QNWKQLRYLTNFGATDYEAIPVKTVGEWKKLTADPAFKKNSTIRLIEVFLPEMDAPSSLVAQANLTAAIN
+AKQD
+
+>gi|151941296|gb|EDN59674.1| pyruvate decarboxylase [Saccharomyces cerevisiae YJM789]
+MSEITLGKYLFERLSQVNCNTVFGLPGDFNLSLLDKLYEVKGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIANAPAEIDRCIRTTYTTQRPVYLGLPANLVDLNVPAKLLETPIDLSLKPNDAEAEAEVVRTVVELIKD
+AKNPVILADACASRHDVKAETKKLMDLTQFPVYVTPMGKGAIDEQHPRYGGVYVGTLSRPEVKKAVESAD
+LILSIGALLSDFNTGSFSYSYKTKNIVEFHSDHIKIRNATFPGVQMKFALQKLLDAIPEVVKDYKPVAVP
+ARVPITKSTPANTPMKQEWMWNQLGNFLREGDIVIAETGTSAFGINQTTFPTDVYAIVQVLWGSIGFTVG
+ALLGATMAAEELDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYIFVLNNNGYTIEKLIHGPHAEYNEI
+QGWDHLALLPTFGARNYETHRVATTGEWEKLTQDKDFQDNSKIRMIEVMLPVFDAPQNLVKQAQLTAATN
+AKQ
+
+>gi|170089333|ref|XP_001875889.1| pyruvate decarboxylase THI3 [Laccaria bicolor S238N-H82]
+MSSHPPASVLQSEVDRLRLQLHTLQAEQGVQNISIGNYLLERLAQLGVTSMFGVPGDFNLGFLDLVEDHS
+KIEWIGNCNELNAAYAADGYARVKEHSIGVVTTTFGVGELSATNGIAGAFSEMVPVLHIVGTPTTVQQRA
+KPILHHTLGDGRYEAYGLAAAQFSIFQANLKDKNTAASLIDRALTECIKLARPVYVTLPMDMVTQEISSE
+RLKVPLSRSPPPNDQSTEEFVVDLIAERVKEAEGDVVVIVDACVIRHDVRKETLDFLKKTGFPVYATPMG
+KTAINEDYERYGGIYIGTITHPDIKKKVEQAKLIISIGGLQSDFNTGNFSYKIPTLRHIELHSTHTKVQY
+ATFAGVEMKQLLPKLGEALKGLHSLVRKFEVPPFIKALPKEDTPVISQLWFWPRLSYFFKPKDVIVTETG
+TSNFGILEVPLPAESVLVSQILWGSIGWSVGSCLGAALAARDVGLGRVILFVGDGSLQLTVQEISPMLRL
+GLKPIIFVLNNSGYTIEKFIHGKKRKYNNIANWKYAELLNVFSEDDKHKSYTVRTKDELSSLLDDKAFAS
+ANQIQLVEVIMDPLDAPRALKVQTELSAKSDPYKERK
+
+>gi|6323163|ref|NP_013235.1| Minor isoform of pyruvate decarboxylase, key enzyme in alcoholic fermentation, decarboxylates pyruvate to acetaldehyde, regulation is glucose- and ethanol-dependent, repressed by thiamine, involved in amino acid catabolism; Pdc5p [Saccharomyces cerevisiae]
+MSEITLGKYLFERLSQVNCNTVFGLPGDFNLSLLDKLYEVKGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIANAPAEIDRCIRTTYTTQRPVYLGLPANLVDLNVPAKLLETPIDLSLKPNDAEAEAEVVRTVVELIKD
+AKNPVILADACASRHDVKAETKKLMDLTQFPVYVTPMGKGAIDEQHPRYGGVYVGTLSRPEVKKAVESAD
+LILSIGALLSDFNTGSFSYSYKTKNIVEFHSDHIKIRNATFPGVQMKFALQKLLDAIPEVVKDYKPVAVP
+ARVPITKSTPANTPMKQEWMWNHLGNFLREGDIVIAETGTSAFGINQTTFPTDVYAIVQVLWGSIGFTVG
+ALLGATMAAEELDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYIFVLNNNGYTIEKLIHGPHAEYNEI
+QGWDHLALLPTFGARNYETHRVATTGEWEKLTQDKDFQDNSKIRMIEVMLPVFDAPQNLVKQAQLTAATN
+AKQ
+
+>gi|150951385|ref|XP_001387701.2| Extracellular signal-regulated kinase 1 (ERK1) (MAP kinase 1) (MAPK 1) [Pichia stipitis CBS 6054]
+MNIEQPEQAPARQISFNVSSHYQILEIVGEGAYGIVCSAIHKPSNQKVAIKKIEPFERSMLCLRTLRELK
+LLKHFNHENIISILAIQRPVSYEFFNEIYLIQELMETDLHRVIRTQKLTDDHIQYFIYQTLRALKAMHSA
+NVLHRDLKPSNLLLNSNCDLKVCDFGLARSIASSEDNFGYMTEYVATRWYRAPEIMLTFQEYTTAIDVWS
+VGCILAEMLSGRPLFPGRDYHNQLWLIMEVLGTPNMEDYYNIKSKRAREYIRSLPFCKKIPFQDLFGNIN
+PNVQINPLAIDLLENLLIFNPAKRITVDDALKHPYLKLYHDPNDEPVSEKIPEDFFDFDKRKDELSIDDL
+KKMLYEEIMKPL
+
+>gi|19114995|ref|NP_594083.1| pyruvate decarboxylase (predicted) [Schizosaccharomyces pombe 972h-]
+MSSEKVLVGEYLFTRLLQLGIKSILGVPGDFNLALLDLIEKVGDETFRWVGNENELNGAYAADAYARVKG
+ISAIVTTFGVGELSALNGFAGAYSERIPVVHIVGVPNTKAQATRPLLHHTLGNGDFKVFQRMSSELSADV
+AFLDSGDSAGRLIDNLLETCVRTSRPVYLAVPSDAGYFYTDASPLKTPLVFPVPENNKEIEHEVVSEILE
+LIEKSKNPSILVDACVSRFHIQQETQDFIDATHFPTYVTPMGKTAINESSPYFDGVYIGSLTEPSIKERA
+ESTDLLLIIGGLRSDFNSGTFTYATPASQTIEFHSDYTKIRSGVYEGISMKHLLPKLTAAIDKKSVQAKA
+RPVHFEPPKAVAAEGYAEGTITHKWFWPTFASFLRESDVVTTETGTSNFGILDCIFPKGCQNLSQVLWGS
+IGWSVGAMFGATLGIKDSDAPHRRSILIVGDGSLHLTVQEISATIRNGLTPIIFVINNKGYTIERLIHGL
+HAVYNDINTEWDYQNLLKGYGAKNSRSYNIHSEKELLDLFKDEEFGKADVIQLVEVHMPVLDAPRVLIEQ
+AKLTASLNKQ
+
+>gi|4114|emb|CAA33709.1| unnamed protein product [Saccharomyces cerevisiae]
+MSEITLGKYLFERLSQVNCNTVFGLPGDFNLSLLNKLYEVKGMRWAGNANELNAAYAADGYARIKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSISSQAKQLLLHHTLGNGDFTVFHRMSANISETTAMIT
+DIRNAPAEIDRCIRTTYTTQRPVYLGLPANLVDLNVPAKLLETPIDLSLKPNDAEAEAEVVRTVVEFIKD
+AKNPVILADACCSRHDVKAETKKLMDLTQFPVYVTPMGKGAIDEQHPRYGGVYVGTLSRPEVKKAVESAD
+LILSIGALLSDFNTGSFSYSYKTKNIVEFHSDHIKIRNATFPGVQMKFALQKLLDAIPEVAKDYKPVAVP
+ARVPITKSTPANTPMKQEWMWNQLGNFLREGDIVIAETGTSAFGINQTTFPTDVYAIVQVLWGSIGFTVG
+ALLGATMAAEELDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYIFVLNNNGYTIEKLIHGPHAEYNEI
+QGWDHLALLPTFGARNYETHRVATTGEWEKLTQDKDFQDNSKIRMIEVMLPVFDAPQNLVKQAQLTAATN
+AKQ
+
+>gi|1226007|emb|CAA59953.1| pyruvate decarboxylase [Kluyveromyces lactis]
+MSEITLGRYLFERLKQVEVQTIFGLPGDFNLSLLDNIYEVPGMRWAGNANELNAAYAADGYARLKGMSCI
+ITTFGVGELSALNGIAGSYAEHVGVLHVVGVPSVSSQAKQLLLHHTLGNGDFTVFHRMCSNISETTAMIT
+DINTAPAEIDRCIRTTYVSQRPVYLGLPANLVDLTVPASLLDTPIDLSLKPNDPEAEEEVIENVLQLIKE
+AKNPVILADACCSRHDAKAETKKLIDLTQFPAFVTPMGKGSIDEKHPRFGGVYVGTLSSPAVKEAVESAH
+LVLSVGALLSDFNTGSFSYSYKTKNIVEFHSDYTKIRRPTFPGVQMKFALQKLLTKVADAAKGYKPVPVP
+SEPEHNEDVADSTPLKQEWVWTQVGEFLREGDVVITETGTSAFGINQTHFPNNTYGISQVLWGSIGFTTG
+ATLGAAFAAEEIDPKKRVILFIGDGSLQLTVQEISTMIRWGLKPYLFVLNNDGYTIERLIHGETAQYNCI
+QNWQHLELLPTFGAKDYEAVRVSTTGEWNKLTTDEKFQDNTRIRLIEVMLPTMDAPSNLVKQAQLTAASN
+AKN
+
+>gi|154294387|ref|XP_001547635.1| mitogen-activated protein kinase [Botryotinia fuckeliana B05.10]
+MTARAPNPASGSRKISFNVSEQYDIQDVVGEGAYGVVWYATPLCYSCNLSNGGRPWNLQKMEINYESFTE
+VYLIQELMETDMHRVIRTQDLSDDHCQYFIYQTLRALKAMHSANVLHRDLKPSNLLLNANCDLKVCDFGL
+ARSAASQEDNSGFMTEYVATRWYRAPEIMLTFKEYTKAIDVWSVGCILAEMLSGKPLFPGKDYHHQLTLI
+LDVLGTPTMEDYYGIKSRRAREYIRSLPFKKKVPFKTMFPKTSDLALDLLEKLLAFNPVKRITVEEALKH
+PYLEPYHDPEDEPTANPIPEEFFDFDKNKDNLTKEQLKKLIYDEIMR
\ No newline at end of file

Added: test-suite/trunk/MultiSource/Benchmarks/mafft/readme
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/mafft/readme?rev=65043&view=auto

==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/mafft/readme (added)
+++ test-suite/trunk/MultiSource/Benchmarks/mafft/readme Thu Feb 19 06:37:59 2009
@@ -0,0 +1,99 @@
+-----------------------------------------------------------------------
+  MAFFT: a multiple sequence alignment program
+  version 6.624beta, 2008/12/18
+
+  http://align.bmr.kyushu-u.ac.jp/mafft/software/
+  katoh at bioreg.kyushu-u.ac.jp
+-----------------------------------------------------------------------
+
+1. COMPILE
+% cd core
+% make clean
+% make
+% cd ..
+
+If you have the './extensions' directory, which is for RNA alignments,
+% cd extensions
+% make clean
+% make
+% cd ..
+
+
+2. INSTALL (with make)
+# cd core
+# make install
+# cd ..
+
+If you have the './extensions' directory,
+# cd extensions 
+# make install
+# cd ..
+
+By default, programs are installed into /usr/local/bin/ and 
+some binaries are installed into /usr/local/lib/mafft/.
+
+
+2. INSTALL (without make)
+If you want to install the binaries to a different directory 
+than /usr/local/lib/mafft/, 
+% cp ./binaries/* /somewhere/else/
+
+In this case, you have to set the MAFFT_BINARIES environment 
+variable to point to the directory where the binaries are.
+% setenv MAFFT_BINARIES /somewhere/else/  # for csh, tcsh
+$ export MAFFT_BINARIES=/somewhere/else/  # for sh, bash
+
+
+3. CHECK
+% cd test
+% rehash                                                   # if necessary
+% setenv MAFFT_BINARIES /where/binaries/were/installed     # if necessary
+% mafft sample > test.fftns2                               # FFT-NS-2
+% mafft --maxiterate 100  sample > test.fftnsi             # FFT-NS-i
+% mafft --globalpair sample > test.gins1                   # G-INS-1 
+% mafft --globalpair --maxiterate 100  sample > test.ginsi # G-INS-i 
+% mafft --localpair sample > test.lins1                    # L-INS-1 
+% mafft --localpair --maxiterate 100  sample > test.linsi  # L-INS-i 
+% diff test.fftns2 sample.fftns2
+% diff test.fftnsi sample.fftnsi
+% diff test.gins1 sample.gins1
+% diff test.ginsi sample.ginsi
+% diff test.lins1 sample.lins1
+
+If you have the './extensions' directory,
+% mafft-qinsi samplerna > test.qinsi                       # Q-INS-i
+% mafft-xinsi samplerna > test.xinsi                       # X-INS-i
+% diff test.linsi sample.linsi
+% diff test.qinsi sample.qinsi
+% diff test.xinsi sample.xinsi
+
+
+4. INPUT FORMAT
+fasta format.
+
+The type of input sequences (nucleotide or amino acid) is 
+automatically recognized based on the frequency of A, T, G, C, U and N.
+
+
+5.  USAGE
+% /usr/local/bin/mafft input > output
+
+See also http://align.bmr.kyushu-u.ac.jp/mafft/software/
+
+
+6. UNINSTALL
+# rm -r /usr/local/lib/mafft
+# rm /usr/local/bin/mafft
+# rm /usr/local/bin/fftns
+# rm /usr/local/bin/fftnsi
+# rm /usr/local/bin/nwns
+# rm /usr/local/bin/nwnsi
+# rm /usr/local/bin/linsi
+# rm /usr/local/bin/ginsi
+# rm /usr/local/bin/mafft-*
+
+
+7. LICENSE
+See the './license' file.
+
+If you have the extensions, see the './license.extensions' file, 





More information about the llvm-commits mailing list