8 #define USE_PENALTY_EX 0
9 #define FASTMATCHCALC 1
11 static float **impmtx = NULL;
14 static float countnocountxx( Gappat *pat1, float diaf1, Gappat *pat2, int offset1, int offset2 )
19 Gappat *pat1bk = pat1;
20 Gappat *pat2bk = pat2;
23 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
25 if( pat2->len + offset2 == offset1 )
27 gmatch = diaf1 * pat2->freq;
30 for( pat1=pat1bk+1; pat1->len != 0; pat1++ ) // excl. len=0
32 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
34 if( pat1->len + offset1 == pat2->len + offset2 )
36 gmatch += pat1->freq * pat2->freq;
37 // if( r ) fprintf( stderr, "match1!!, len=%d, gmatch=%f * %f\n", pat2->len, pat1->freq, pat2->freq );
45 static float countnocountmatchx( Gappat *pat1, Gappat *pat2, int offset1, int offset2, int r )
47 Gappat *pat1bk = pat1;
48 Gappat *pat2bk = pat2;
50 // pat1[][0] ha total gap.
51 for( pat1=pat1bk+1; pat1->len != 0; pat1++ )
53 for( pat2=pat2bk+1; pat2->len != 0; pat2++ )
55 if( pat1->len + offset1 == pat2->len + offset2 )
57 val += pat1->freq * pat2->freq;
58 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
59 // if( r ) fprintf( stderr, "y %d-%d, len=%d,%d, val = %f\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len, val );
63 if( r ) fprintf( stderr, "nocountmatch=%f\n", val );
68 static float countnocountmatch( Gappat *pat1, Gappat *pat2, int r )
71 Gappat *pat1bk = pat1;
72 Gappat *pat2bk = pat2;
74 // pat1[][0] ha total gap.
75 for( pat1=pat1bk+1; pat1->len != 0; pat1++ )
77 // if( r ) fprintf( stderr, "b %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
78 for( pat2=pat2bk+1; pat2->len != 0; pat2++ )
80 if( pat1->len == pat2->len )
82 // if( r ) fprintf( stderr, " x%d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
83 val += pat1->freq * pat2->freq;
84 // if( r ) fprintf( stderr, "y %d-%d, val = %f\n", pat1-pat1bk, pat2-pat2bk,val );
85 // if( r ) fprintf( stderr, "z tsugi, %d-%d, len=%d,%d\n", pat1-pat1bk+1, pat2-pat2bk+1, (pat1+1)->len, (pat2+1)->len );
87 // if( r ) fprintf( stderr, "a %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
90 // fprintf( stderr, "nocountmatch=%f\n", val );
95 static float countnocountx( Gappat *pat1, float diaf1, Gappat *pat2, int offset1, int r )
99 Gappat *pat1bk = pat1;
100 Gappat *pat2bk = pat2;
103 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
105 if( pat2->len == offset1 )
107 gmatch = diaf1 * pat2->freq;
108 // if( r ) fprintf( stderr, "match0!!, len=%d, gmatch=%f * %f\n", pat2->len, diaf1, pat2->freq );
111 for( pat1=pat1bk+1; pat1->len != 0; pat1++ ) // excl. len=0
113 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
115 if( pat1->len + offset1 == pat2->len )
117 gmatch += pat1->freq * pat2->freq;
118 // if( r ) fprintf( stderr, "match1!!, len=%d, gmatch=%f * %f\n", pat2->len, pat1->freq, pat2->freq );
126 static float countnocount( Gappat *pat1, Gappat *pat2, int offset1, int offset2 ) //osoi
129 Gappat *pat1bk = pat1;
130 Gappat *pat2bk = pat2;
132 // pat1[][0] ha total gap.
133 for( pat1=pat1bk+1; pat1->len != -1; pat1++ )
135 for( pat2=pat2bk+1; pat2->len != -1; pat2++ )
137 if( pat1->len+offset1 == pat2->len+offset2 )
139 val += pat1->freq * pat2->freq;
143 // fprintf( stderr, "nocount=%f\n", val );
151 float imp_match_out_scH( int i1, int j1 )
153 // fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
154 // fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
155 return( impmtx[i1][j1] );
159 static void imp_match_out_veadH( float *imp, int i1, int lgth2 )
162 float *pt = impmtx[i1];
167 float *pt = impmtx[i1];
168 for( j=0; j<lgth2; j++ )
172 static void imp_match_out_vead_tateH( float *imp, int j1, int lgth1 )
175 for( i=0; i<lgth1; i++ )
176 *imp++ += impmtx[i][j1];
179 #if 1 // tbfast.c kara yobareru.
180 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 )
182 int i, j, k1, k2, tmpint, start1, start2, end1, end2;
183 static int impalloclen = 0;
186 char *pt, *pt1, *pt2;
187 static char *nocount1 = NULL;
188 static char *nocount2 = NULL;
191 if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
193 if( impmtx ) FreeFloatMtx( impmtx );
194 if( nocount1 ) free( nocount1 );
195 if( nocount2 ) free( nocount2 );
196 impalloclen = MAX( lgth1, lgth2 ) + 2;
197 impmtx = AllocateFloatMtx( impalloclen, impalloclen );
198 nocount1 = AllocateCharVec( impalloclen );
199 nocount2 = AllocateCharVec( impalloclen );
202 for( i=0; i<lgth1; i++ )
204 for( j=0; j<clus1; j++ )
205 if( seq1[j][i] == '-' ) break;
206 if( j != clus1 ) nocount1[i] = 1;
207 else nocount1[i] = 0;
209 for( i=0; i<lgth2; i++ )
211 for( j=0; j<clus2; j++ )
212 if( seq2[j][i] == '-' ) break;
213 if( j != clus2 ) nocount2[i] = 1;
214 else nocount2[i] = 0;
218 fprintf( stderr, "nocount2 =\n" );
219 for( i = 0; i<impalloclen; i++ )
221 fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
228 fprintf( stderr, "eff1 in _init_strict = \n" );
229 for( i=0; i<clus1; i++ )
230 fprintf( stderr, "eff1[] = %f\n", eff1[i] );
231 for( i=0; i<clus2; i++ )
232 fprintf( stderr, "eff2[] = %f\n", eff2[i] );
235 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
237 effijx = fastathreshold;
238 for( i=0; i<clus1; i++ )
240 for( j=0; j<clus2; j++ )
242 effij = (float)( eff1[i] * eff2[j] * effijx );
243 tmpptr = localhom[i][j];
246 // fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
247 // fprintf( stderr, "end1 = %d\n", tmpptr->end1 );
248 // fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
249 // fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
254 if( *pt++ != '-' ) tmpint++;
255 if( tmpint == tmpptr->start1 ) break;
257 start1 = pt - seq1[i] - 1;
259 if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
265 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
266 if( tmpint == tmpptr->end1 ) break;
267 if( *pt++ != '-' ) tmpint++;
269 end1 = pt - seq1[i] - 0;
273 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
274 if( *pt++ != '-' ) tmpint++;
275 if( tmpint == tmpptr->end1 ) break;
277 end1 = pt - seq1[i] - 1;
285 if( *pt++ != '-' ) tmpint++;
286 if( tmpint == tmpptr->start2 ) break;
288 start2 = pt - seq2[j] - 1;
289 if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
295 if( tmpint == tmpptr->end2 ) break;
296 if( *pt++ != '-' ) tmpint++;
298 end2 = pt - seq2[j] - 0;
302 if( *pt++ != '-' ) tmpint++;
303 if( tmpint == tmpptr->end2 ) break;
305 end2 = pt - seq2[j] - 1;
308 // 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] );
309 // fprintf( stderr, "step 0\n" );
310 if( end1 - start1 != end2 - start2 )
312 // fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
316 k1 = start1; k2 = start2;
319 while( *pt1 && *pt2 )
321 if( *pt1 != '-' && *pt2 != '-' )
323 // ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃðդ·¤Æ²¼¤µ¤¤¡£
324 // impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
325 // impmtx[k1][k2] += tmpptr->importance * effij;
326 impmtx[k1][k2] += tmpptr->fimportance * effij;
327 // fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
328 // fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
329 // fprintf( stderr, "%d (%c) - %d (%c) - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
333 else if( *pt1 != '-' && *pt2 == '-' )
335 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
338 else if( *pt1 == '-' && *pt2 != '-' )
340 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
343 else if( *pt1 == '-' && *pt2 == '-' )
345 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
349 if( k1 > end1 || k2 > end2 ) break;
352 while( k1 <= end1 && k2 <= end2 )
354 fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
355 if( !nocount1[k1] && !nocount2[k2] )
357 impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j] * fastathreshold;
358 fprintf( stderr, "marked\n" );
361 fprintf( stderr, "no count\n" );
365 tmpptr = tmpptr->next;
370 if( clus1 == 1 && clus2 == 6 )
372 fprintf( stderr, "\n" );
373 fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
374 fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
375 fprintf( stderr, "impmtx = \n" );
376 for( k2=0; k2<lgth2; k2++ )
377 fprintf( stderr, "%6.3f ", (double)k2 );
378 fprintf( stderr, "\n" );
379 for( k1=0; k1<lgth1; k1++ )
381 fprintf( stderr, "%d ", k1 );
382 for( k2=0; k2<3; k2++ )
383 fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
384 fprintf( stderr, "\n" );
393 static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
398 float **cpmxpd = floatwork;
399 int **cpmxpdn = intwork;
400 float *matchpt, *cpmxpdpt, **cpmxpdptpt;
401 int *cpmxpdnpt, **cpmxpdnptpt;
405 for( j=0; j<lgth2; j++ )
408 for( l=0; l<26; l++ )
412 cpmxpd[j][count] = cpmx2[l][j];
413 cpmxpdn[j][count] = l;
417 cpmxpdn[j][count] = -1;
422 for( l=0; l<26; l++ )
425 for( j=0; j<26; j++ )
426 scarr[l] += n_dis[j][l] * cpmx1[j][i1];
429 cpmxpdnptpt = cpmxpdn;
434 cpmxpdnpt = *cpmxpdnptpt++;
435 cpmxpdpt = *cpmxpdptpt++;
436 while( *cpmxpdnpt>-1 )
437 *matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
444 float **cpmxpd = floatwork;
445 int **cpmxpdn = intwork;
450 for( j=0; j<lgth2; j++ )
453 for( l=0; l<26; l++ )
457 cpmxpd[count][j] = cpmx2[l][j];
458 cpmxpdn[count][j] = l;
462 cpmxpdn[count][j] = -1;
465 for( l=0; l<26; l++ )
468 for( k=0; k<26; k++ )
469 scarr[l] += n_dis[k][l] * cpmx1[k][i1];
471 for( j=0; j<lgth2; j++ )
474 for( k=0; cpmxpdn[k][j]>-1; k++ )
475 match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
480 static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw,
481 char **seq1, char **seq2,
482 char **mseq1, char **mseq2,
483 float **cpmx1, float **cpmx2,
484 int **ijp, int icyc, int jcyc )
486 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
488 char *gaptable1, *gt1bk;
489 char *gaptable2, *gt2bk;
490 lgth1 = strlen( seq1[0] );
491 lgth2 = strlen( seq2[0] );
492 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
493 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
496 for( i=0; i<lgth1; i++ )
498 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
506 wm = lastverticalw[0];
507 for( i=0; i<lgth1; i++ )
509 if( lastverticalw[i] >= wm )
511 wm = lastverticalw[i];
512 iin = i; jin = lgth2-1;
513 ijp[lgth1][lgth2] = +( lgth1 - i );
516 for( j=0; j<lgth2; j++ )
518 if( lasthorizontalw[j] >= wm )
520 wm = lasthorizontalw[j];
521 iin = lgth1-1; jin = j;
522 ijp[lgth1][lgth2] = -( lgth2 - j );
527 for( i=0; i<lgth1+1; i++ )
531 for( j=0; j<lgth2+1; j++ )
533 ijp[0][j] = -( j + 1 );
536 gaptable1 = gt1bk + lgth1+lgth2;
538 gaptable2 = gt2bk + lgth1+lgth2;
541 iin = lgth1; jin = lgth2;
543 for( k=0; k<=lgth1+lgth2; k++ )
545 if( ijp[iin][jin] < 0 )
547 ifi = iin-1; jfi = jin+ijp[iin][jin];
549 else if( ijp[iin][jin] > 0 )
551 ifi = iin-ijp[iin][jin]; jfi = jin-1;
555 ifi = iin-1; jfi = jin-1;
571 if( iin == lgth1 || jin == lgth2 )
575 *impwmpt += imp_match_out_scH( iin, jin );
577 // fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
579 if( iin <= 0 || jin <= 0 ) break;
583 iin = ifi; jin = jfi;
586 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
587 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
593 static float Atracking( float *lasthorizontalw, float *lastverticalw,
594 char **seq1, char **seq2,
595 char **mseq1, char **mseq2,
596 float **cpmx1, float **cpmx2,
597 int **ijp, int icyc, int jcyc )
599 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
601 char *gaptable1, *gt1bk;
602 char *gaptable2, *gt2bk;
603 lgth1 = strlen( seq1[0] );
604 lgth2 = strlen( seq2[0] );
606 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
607 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
610 for( i=0; i<lgth1; i++ )
612 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
620 wm = lastverticalw[0];
621 for( i=0; i<lgth1; i++ )
623 if( lastverticalw[i] >= wm )
625 wm = lastverticalw[i];
626 iin = i; jin = lgth2-1;
627 ijp[lgth1][lgth2] = +( lgth1 - i );
630 for( j=0; j<lgth2; j++ )
632 if( lasthorizontalw[j] >= wm )
634 wm = lasthorizontalw[j];
635 iin = lgth1-1; jin = j;
636 ijp[lgth1][lgth2] = -( lgth2 - j );
641 for( i=0; i<lgth1+1; i++ )
645 for( j=0; j<lgth2+1; j++ )
647 ijp[0][j] = -( j + 1 );
650 gaptable1 = gt1bk + lgth1+lgth2;
652 gaptable2 = gt2bk + lgth1+lgth2;
655 iin = lgth1; jin = lgth2;
656 for( k=0; k<=lgth1+lgth2; k++ )
658 if( ijp[iin][jin] < 0 )
660 ifi = iin-1; jfi = jin+ijp[iin][jin];
662 else if( ijp[iin][jin] > 0 )
664 ifi = iin-ijp[iin][jin]; jfi = jin-1;
668 ifi = iin-1; jfi = jin-1;
684 if( iin <= 0 || jin <= 0 ) break;
688 iin = ifi; jin = jfi;
691 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
692 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
700 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 )
701 /* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
705 int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
708 float wm = 0.0; /* int ?????? */
710 float *currentw, *previousw;
711 // float fpenalty = (float)penalty;
713 float fpenalty_ex = (float)penalty_ex;
718 float *mjpt, *prept, *curpt;
724 static float *w1, *w2;
726 static float *initverticalw; /* kufuu sureba iranai */
727 static float *lastverticalw; /* kufuu sureba iranai */
731 static Gappat **gappat1;
732 static Gappat **gappat2;
741 static float *ogcp1g;
742 static float *ogcp2g;
743 static float *fgcp1g;
744 static float *fgcp2g;
749 static float **cpmx1;
750 static float **cpmx2;
751 static int **intwork;
752 static float **floatwork;
753 static int orlgth1 = 0, orlgth2 = 0;
754 float fpenalty = (float)penalty;
766 fprintf( stderr, "#### eff in SA+++align\n" );
767 fprintf( stderr, "#### seq1[0] = %s\n", seq1[0] );
768 fprintf( stderr, "#### strlen( seq1[0] ) = %d\n", strlen( seq1[0] ) );
769 for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
773 mseq1 = AllocateCharMtx( njob, 0 );
774 mseq2 = AllocateCharMtx( njob, 0 );
778 lgth1 = strlen( seq1[0] );
779 lgth2 = strlen( seq2[0] );
781 if( lgth1 == 0 || lgth2 == 0 )
783 fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
787 if( lgth1 > orlgth1 || lgth2 > orlgth2 )
791 if( orlgth1 > 0 && orlgth2 > 0 )
795 FreeFloatVec( match );
796 FreeFloatVec( initverticalw );
797 FreeFloatVec( lastverticalw );
806 FreeFloatVec( digf1 );
807 FreeFloatVec( digf2 );
808 FreeFloatVec( diaf1 );
809 FreeFloatVec( diaf2 );
810 FreeFloatVec( gapz1 );
811 FreeFloatVec( gapz2 );
812 FreeFloatVec( gapf1 );
813 FreeFloatVec( gapf2 );
814 FreeFloatVec( ogcp1 );
815 FreeFloatVec( ogcp2 );
816 FreeFloatVec( fgcp1 );
817 FreeFloatVec( fgcp2 );
818 FreeFloatVec( ogcp1g );
819 FreeFloatVec( ogcp2g );
820 FreeFloatVec( fgcp1g );
821 FreeFloatVec( fgcp2g );
824 FreeFloatMtx( cpmx1 );
825 FreeFloatMtx( cpmx2 );
827 FreeFloatMtx( floatwork );
828 FreeIntMtx( intwork );
831 ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
832 ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
835 fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
838 w1 = AllocateFloatVec( ll2+2 );
839 w2 = AllocateFloatVec( ll2+2 );
840 match = AllocateFloatVec( ll2+2 );
842 initverticalw = AllocateFloatVec( ll1+2 );
843 lastverticalw = AllocateFloatVec( ll1+2 );
845 m = AllocateFloatVec( ll2+2 );
846 mp = AllocateIntVec( ll2+2 );
848 mseq = AllocateCharMtx( njob, ll1+ll2 );
850 digf1 = AllocateFloatVec( ll1+2 );
851 digf2 = AllocateFloatVec( ll2+2 );
852 diaf1 = AllocateFloatVec( ll1+2 );
853 diaf2 = AllocateFloatVec( ll2+2 );
854 gappat1 = (Gappat **)calloc( ll1+2, sizeof( Gappat * ) );
855 gappat2 = (Gappat **)calloc( ll2+2, sizeof( Gappat * ) );
856 gapz1 = AllocateFloatVec( ll1+2 );
857 gapz2 = AllocateFloatVec( ll2+2 );
858 gapf1 = AllocateFloatVec( ll1+2 );
859 gapf2 = AllocateFloatVec( ll2+2 );
860 ogcp1 = AllocateFloatVec( ll1+2 );
861 ogcp2 = AllocateFloatVec( ll2+2 );
862 fgcp1 = AllocateFloatVec( ll1+2 );
863 fgcp2 = AllocateFloatVec( ll2+2 );
864 ogcp1g = AllocateFloatVec( ll1+2 );
865 ogcp2g = AllocateFloatVec( ll2+2 );
866 fgcp1g = AllocateFloatVec( ll1+2 );
867 fgcp2g = AllocateFloatVec( ll2+2 );
869 cpmx1 = AllocateFloatMtx( 26, ll1+2 );
870 cpmx2 = AllocateFloatMtx( 26, ll2+2 );
873 floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 );
874 intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 );
876 floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 );
877 intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 );
881 fprintf( stderr, "succeeded\n" );
889 for( i=0; i<icyc; i++ )
894 for( j=0; j<jcyc; j++ )
896 mseq2[j] = mseq[icyc+j];
901 if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
905 if( commonAlloc1 && commonAlloc2 )
907 FreeIntMtx( commonIP );
910 ll1 = MAX( orlgth1, commonAlloc1 );
911 ll2 = MAX( orlgth2, commonAlloc2 );
914 fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
917 commonIP = AllocateIntMtx( ll1+10, ll2+10 );
920 fprintf( stderr, "succeeded\n\n" );
931 for( i=0; i<icyc; i++ )
933 fprintf( stderr, "## totaleff = %f\n", t );
937 cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
938 cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
942 new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
943 new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap1 );
944 new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
945 new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap1, egap2 );
946 getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
947 getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 ); // sgap1 ha iranai ?
948 getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
949 getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap1, egap2 ); // sgap1 ha iranai ?
950 getgapfreq( gapf1, icyc, seq1, eff1, lgth1 ); // atode
951 getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 ); // atode
952 getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 ); // atode
953 getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 ); // atode
957 st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
958 st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
959 st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
960 st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
961 st_getGapPattern( gappat1, icyc, seq1, eff1, lgth1 );
962 st_getGapPattern( gappat2, jcyc, seq2, eff2, lgth2 );
963 getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
964 getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
965 getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
966 getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
967 getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
968 getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
969 getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
970 getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
974 for( i=0; i<lgth1; i++ )
975 fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
981 match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
983 imp_match_out_vead_tateH( initverticalw, 0, lgth1 ); // 060306
985 match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
987 imp_match_out_veadH( currentw, 0, lgth2 ); // 060306
992 imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
998 // if( g ) fprintf( stderr, "init-match penal1=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
999 // initverticalw[0] += g;
1000 // currentw[0] += g;
1002 // if( g ) fprintf( stderr, "init-match penal2=%f, %c-%c\n", g, seq1[0][0], seq2[0][0] );
1003 // initverticalw[0] += g;
1004 // currentw[0] += g;
1006 for( i=1; i<lgth1+1; i++ )
1008 // initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
1011 // 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
1012 // tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+0.0) + gapz2[0]*(1.0-digf1[0] - diaf1[0]) ) * 0.5 * fpenalty; // mada
1013 // tmppenal = ( (1.0-0.0)*(1.0-ogcp1g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
1014 // tmppenal = 0.5 * fpenalty;
1015 // tmppenal -= ( (1.0-0.0) * (1.0-diaf1[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
1016 // tmppenal -= ( (1.0-gapf2[j-1]) * ogcp1g[i] + gapf2[j-1] ) * 0.5 * fpenalty;
1017 // fprintf( stderr, "0,0<-%d,%d, tmppenal 1 = %f\n", i, 0, tmppenal );
1018 initverticalw[i] += tmppenal;
1020 tmppenal = diaf1[i] * ( 1.0 - gapf2[0] ) * fpenalty;
1021 if( gappat1[i][0].freq )
1023 tmppenal += ( gappat1[i][0].freq ) * ( 1.0 - gapf2[0] ) * fpenalty;
1024 tmppenal -= ( countnocountx( gappat2[0], diaf2[0], gappat1[i], i, 1 ) ) * fpenalty;
1026 // tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1027 // tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1028 // tmppenal = ( (1.0-gapf2[0])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[0]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1029 // tmppenal = 0.5 * fpenalty;
1030 // tmppenal -= ( (1.0-gapf2[0]) * (1.0-diaf1[i]) + gapf2[0] ) * 0.5 * fpenalty;
1031 // tmppenal -= ( (1.0-gapf2[j]) * fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
1032 initverticalw[i] += tmppenal;
1033 // 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] );
1037 for( j=1; j<lgth2+1; j++ )
1039 // currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
1042 // 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
1043 // tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+0.0) + gapz1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1044 // tmppenal = ( (1.0-0.0)*(1.0-ogcp2g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
1045 // tmppenal = 0.5 * fpenalty;
1046 // tmppenal -= ( (1.0-0.0) * (1.0-diaf2[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
1047 // tmppenal -= ( (1.0-gapf1[0]) * fgcp2g[j] + gapf1[0] ) * 0.5 * fpenalty;
1048 // fprintf( stderr, "0,0<-%d,%d, tmppenal 3 = %f\n", 0, j, tmppenal );
1049 currentw[j] += tmppenal;
1051 tmppenal = diaf2[j] * ( 1.0 - gapf1[0] ) * fpenalty;
1052 if( gappat2[j][0].freq )
1054 tmppenal += ( gappat2[j][0].freq ) * ( 1.0 - gapf1[0] ) * fpenalty;
1055 tmppenal -= ( countnocountx( gappat1[0], diaf1[0], gappat2[j], j, 1 ) ) * fpenalty;
1057 // tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1058 // tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1059 // tmppenal = ( (1.0-gapf1[0])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1060 // tmppenal = 0.5 * fpenalty;
1061 // tmppenal -= ( (1.0-gapf1[0]) * (1.0-diaf2[j]) + gapf1[0] ) * 0.5 * fpenalty;
1062 // tmppenal -= ( (1.0-gapf1[0]) * ogcp2g[j] + gapf1[i-1] ) * 0.5 * fpenalty;
1063 // fprintf( stderr, "0,0<-%d,%d, tmppenal 4 = %f\n", 0, j, tmppenal );
1064 currentw[j] += tmppenal;
1070 for( j=1; j<lgth2+1; j++ )
1071 currentw[j] -= offset * j / 2.0;
1072 for( i=1; i<lgth1+1; i++ )
1073 initverticalw[i] -= offset * i / 2.0;
1077 m[0] = 0.0; // iranai
1078 for( j=1; j<lgth2+1; ++j )
1080 // m[j] = currentw[j-1] + ogcp1[1];
1084 // tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[1]+fgcp1g[1]) + gapz2[j]*(1.0-digf1[1]-diaf1[1]) ) * 0.5 * fpenalty; // mada
1085 // 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
1086 // 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
1087 // tmppenal = 0.5 * fpenalty;
1088 // tmppenal -= ( (1.0-0.0) * (1.0-0.0) + 0.0 ) * 0.5 * fpenalty;
1089 // tmppenal -= ( (1.0-gapf2[-1]) * (1.0-diaf1[0]) + gapf2[-1] ) * 0.5 * fpenalty;
1090 // if( tmppenal ) fprintf( stderr, "%c=%c, end j tmppenal=%f\n", seq1[0][0], seq2[0][j-1], tmppenal );
1091 m[j] = currentw[j-1] + tmppenal + fpenalty * 10000;
1092 // m[j] = currentw[j-1] + ogcp1[1];
1095 lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
1097 lastverticalw[0] = currentw[lgth2-1];
1099 if( outgap ) lasti = lgth1+1; else lasti = lgth1;
1102 fprintf( stderr, "currentw = \n" );
1103 for( i=0; i<lgth1+1; i++ )
1105 fprintf( stderr, "%5.2f ", currentw[i] );
1107 fprintf( stderr, "\n" );
1108 fprintf( stderr, "initverticalw = \n" );
1109 for( i=0; i<lgth2+1; i++ )
1111 fprintf( stderr, "%5.2f ", initverticalw[i] );
1113 fprintf( stderr, "\n" );
1114 fprintf( stderr, "fcgp\n" );
1115 for( i=0; i<lgth1; i++ )
1116 fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
1117 for( i=0; i<lgth2; i++ )
1118 fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
1121 for( i=1; i<lasti; i++ )
1124 previousw = currentw;
1127 previousw[0] = initverticalw[i-1];
1129 match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
1131 fprintf( stderr, "\n" );
1132 fprintf( stderr, "i=%d\n", i );
1133 fprintf( stderr, "currentw = \n" );
1134 for( j=0; j<lgth2; j++ )
1136 fprintf( stderr, "%5.2f ", currentw[j] );
1138 fprintf( stderr, "\n" );
1142 // fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
1144 imp_match_out_veadH( currentw, i, lgth2 );
1146 imp_match_out_veadH( currentw, i, lgth2 );
1150 fprintf( stderr, "\n" );
1151 fprintf( stderr, "i=%d\n", i );
1152 fprintf( stderr, "currentw = \n" );
1153 for( j=0; j<lgth2; j++ )
1155 fprintf( stderr, "%5.2f ", currentw[j] );
1157 fprintf( stderr, "\n" );
1159 currentw[0] = initverticalw[i];
1162 // mi = previousw[0] + ogcp2[1]; // machigai
1164 // tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[1]+fgcp2g[1]) + gapz1[i]*(1.0-digf2[1]-diaf2[1]) ) * 0.5 * fpenalty; // mada
1165 // 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
1166 // fprintf( stderr, "%c=%c, end i tmppenal=%f, ogcp2g[1]=%f\n", seq1[0][i-1], seq2[0][0], tmppenal, ogcp2g[1] );
1167 // mi = previousw[0] + tmppenal;
1168 mi = previousw[0] + tmppenal + fpenalty * 10000;
1174 curpt = currentw + 1;
1177 ogcp2pt = ogcp2 + 1;
1178 fgcp1va = fgcp1[i-1];
1181 for( j=1; j<lastj; j++ )
1185 if( gappat2[j][0].freq )
1187 g = diaf1[i] * gappat2[j][0].freq * fpenalty;
1188 // if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
1189 // if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
1193 if( gappat1[i][0].freq )
1195 g = diaf2[j] * gappat1[i][0].freq * fpenalty;
1196 // if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
1197 // if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
1201 g = ( (gappat1[i][0].freq) * (gappat2[j][0].freq) ) * fpenalty;
1202 // if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
1203 // if( g ) fprintf( stderr, "match penal3=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
1208 maegap = ijp[i-1][j-1];
1209 // if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
1210 // fprintf( stderr, "i,j=%d,%d, maegap=%d\n", i, j, maegap );
1215 g = ( countnocountmatchx( gappat1[i], gappat2[j], 0, 0, 0 ) ) * fpenalty;
1216 // if( seq1[0][i] == 'D' && seq2[0][j] == 'D' )
1217 // 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 ) );
1219 #if 0 // atta houga yoi hazu
1220 else if( maegap < 0 ) // i jump
1222 g = ( countnocountmatchx( gappat1[i], gappat2[j], 0, -maegap, 0 ) ) * fpenalty;
1223 if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
1225 fprintf( stderr, "i-jumped, offset1=%d\n", maegap );
1226 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 ) );
1231 g = ( countnocountmatchx( gappat1[i], gappat2[j], maegap, 0, 0 ) ) * fpenalty;
1232 if( seq1[0][i] == 'Y' && seq2[0][j] == 'Y' )
1234 fprintf( stderr, "j-jumped, offset1=%d\n", maegap );
1235 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 ) );
1245 fprintf( stderr, "%5.0f->", wm );
1248 fprintf( stderr, "%5.0f?", g );
1250 // tmppenal = fpenalty;
1251 tmppenal = diaf2[j] * ( 1.0 - gapf1[i] ) * fpenalty;
1252 if( gappat2[j][0].freq )
1254 tmppenal += ( gappat2[j][0].freq ) * ( 1.0 - gapf1[i] ) * fpenalty;
1255 // tmppenal -= ( countnocountx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
1256 maegap = ijp[i-1][mpi];
1260 tmppenal -= ( countnocountx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
1262 #if 0 // attahouga yoi hazu
1263 else if( maegap < 0 ) // i jump
1266 tmppenal -= ( countnocountxx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1+maegap, 0 ) ) * fpenalty;
1270 tmppenal -= ( countnocountxx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, maegap ) ) * fpenalty;
1274 if( (g=mi+tmppenal) > wm )
1276 // 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] );
1278 *ijppt = -( j - mpi );
1280 if( (g=*prept) >= mi )
1282 // fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
1288 // mi += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5;
1289 // 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 );
1296 fprintf( stderr, "%5.0f?", g );
1299 // tmppenal = fpenalty;
1300 tmppenal = diaf1[i] * ( 1.0 - gapf2[j] ) * fpenalty;
1301 if( gappat1[i][0].freq )
1303 tmppenal += ( gappat1[i][0].freq ) * ( 1.0 - gapf2[j] ) * fpenalty;
1304 // tmppenal -= ( countnocountx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, 1 ) ) * fpenalty;
1305 maegap = ijp[*mpjpt][j-1];
1308 tmppenal -= ( countnocountx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, 1 ) ) * fpenalty;
1310 #if 0 // attahouga yoi hazu
1311 else if( maegap > 0 ) // j jump
1313 tmppenal -= ( countnocountxx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1+maegap, 0 ) ) * fpenalty;
1318 tmppenal -= ( countnocountxx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, maegap ) ) * fpenalty;
1322 if( (g=*mjpt+tmppenal) > wm )
1324 // 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] );
1326 *ijppt = +( i - *mpjpt );
1328 if( (g=*prept) >= *mjpt )
1330 // fprintf( stderr, "jump j end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
1336 // m[j] += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5;
1337 // 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 );
1340 m[j] += fpenalty_ex;
1344 fprintf( stderr, "%5.0f ", wm );
1354 lastverticalw[i] = currentw[lgth2-1];
1357 // fprintf( stderr, "wm = %f\n", wm );
1362 for( j=1; j<lgth2+1; j++ )
1363 currentw[j] -= offset * ( lgth2 - j ) / 2.0;
1364 for( i=1; i<lgth1+1; i++ )
1365 lastverticalw[i] -= offset * ( lgth1 - i / 2.0);
1370 fprintf( stderr, "\n" );
1371 for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
1372 fprintf( stderr, "#####\n" );
1373 for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
1374 fprintf( stderr, "====>" );
1375 for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
1376 for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
1380 Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1383 Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1385 // fprintf( stderr, "### impmatch = %f\n", *impmatch );
1387 resultlen = strlen( mseq1[0] );
1388 if( alloclen < resultlen || resultlen > N )
1390 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1391 ErrorExit( "LENGTH OVER!\n" );
1395 for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
1396 for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
1398 fprintf( stderr, "\n" );
1399 for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
1400 fprintf( stderr, "#####\n" );
1401 for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
1404 fprintf( stderr, "wm = %f\n", wm );
1406 for( i=0; i<lgth1+1; i++ )
1411 for( i=0; i<lgth2+1; i++ )