1 /* Tree-dependent-iteration */
2 /* Devide to segments */
8 static int subalignment;
9 static int subalignmentoffset;
10 static int specifictarget;
14 static double autosubalignment;
17 static void calcmaxdistclass( void )
21 for( c=0; c<ndistclass; c++ )
23 rep = (double) 2 * c / ndistclass; // dist:0-2 for dist2offset
24 // fprintf( stderr, "c=%d, rep=%f, offset=%f\n", c, rep, dist2offset( rep ) );
25 if( dist2offset( rep ) == 0.0 )
28 fprintf( stderr, "ndistclass = %d, maxdistclass = %d\n", ndistclass, c+1 );
30 // maxdistclass = ndistclass; // CHUUI!!!!
34 void arguments( int argc, char *argv[] )
44 parallelizationstrategy = BAATARI1;
61 divWinSize = 20; /* 70 */
75 use_fft = 0; // CHUUI dochira demo mafft.tmpl deha F
77 alg = 'A'; /* chuui */
85 ppenalty = NOTSPECIFIED;
86 penalty_shift_factor = 1000.0;
87 ppenalty_ex = NOTSPECIFIED;
88 poffset = NOTSPECIFIED;
89 kimuraR = NOTSPECIFIED;
92 fftWinSize = NOTSPECIFIED;
93 fftThreshold = NOTSPECIFIED;
94 RNAppenalty = NOTSPECIFIED;
95 RNAppenalty_ex = NOTSPECIFIED;
96 RNApthr = NOTSPECIFIED;
98 consweight_multi = 1.0;
101 subalignmentoffset = 0;
103 specificityconsideration = 0.0;
104 autosubalignment = 0.0;
108 while( --argc > 0 && (*++argv)[0] == '-' )
110 while ( (c = *++argv[0]) )
116 fprintf( stderr, "inputfile = %s\n", inputfile );
120 niter = myatoi( *++argv );
121 fprintf( stderr, "niter = %d\n", niter );
125 RNApthr = (int)( atof( *++argv ) * 1000 - 0.5 );
129 RNAppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
133 ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
134 // fprintf( stderr, "ppenalty = %d\n", ppenalty );
138 penalty_shift_factor = atof( *++argv );
139 if( penalty_shift_factor < 100.0 && penalty_shift_factor != 2.0 )
141 fprintf( stderr, "%f, penalty_shift is fixed to penalty x 2 in the iterative refinement phase.\n", penalty_shift_factor );
142 penalty_shift_factor = 2.0;
147 ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
148 // fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex );
152 poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
153 fprintf( stderr, "poffset = %d\n", poffset );
157 kimuraR = myatoi( *++argv );
158 fprintf( stderr, "kappa = %d\n", kimuraR );
162 nblosum = myatoi( *++argv );
164 fprintf( stderr, "blosum %d / kimura 200\n", nblosum );
168 pamN = myatoi( *++argv );
171 fprintf( stderr, "jtt/kimura %d\n", pamN );
175 pamN = myatoi( *++argv );
178 fprintf( stderr, "tm %d\n", pamN );
182 fastathreshold = atof( *++argv );
187 consweight_rna = atof( *++argv );
192 consweight_multi = atof( *++argv );
196 nthread = myatoi( *++argv );
197 fprintf( stderr, "nthread = %d\n", nthread );
202 subalignmentoffset = myatoi( *++argv );
206 randomseed = myatoi( *++argv );
207 fprintf( stderr, "randomseed = %d\n", randomseed );
212 if( !strcmp( argkey, "BESTFIRST" ) ) parallelizationstrategy = BESTFIRST;
213 else if( !strcmp( argkey, "BAATARI0" ) ) parallelizationstrategy = BAATARI0;
214 else if( !strcmp( argkey, "BAATARI1" ) ) parallelizationstrategy = BAATARI1;
215 else if( !strcmp( argkey, "BAATARI2" ) ) parallelizationstrategy = BAATARI2;
218 fprintf( stderr, "Unknown parallelization strategy, %s\n", argkey );
225 specificityconsideration = (double)myatof( *++argv );
226 // fprintf( stderr, "specificityconsideration = %f\n", specificityconsideration );
231 scoreout = 1; // for checking parallel calculation
235 spscoreout = 1; // 2014/Dec/30, sp score
352 sueff_global = atof( *++argv );
353 fprintf( stderr, "sueff_global = %f\n", sueff_global );
365 autosubalignment = atof( *++argv );
366 fprintf( stderr, "autosubalignment = %f\n", autosubalignment );
370 minimumweight = atof( *++argv );
371 fprintf( stderr, "minimumweight = %f\n", minimumweight );
375 fftThreshold = myatoi( *++argv );
379 fftWinSize = myatoi( *++argv );
389 fprintf( stderr, "illegal option %c\n", c );
399 cut = atof( (*argv) );
404 fprintf( stderr, "options : Check source file!\n" );
408 if( alg == 'A' && weight == 0 )
409 ErrorExit( "ERROR : Algorithm A+ and un-weighted\n" );
414 int main( int argc, char *argv[] )
418 static char **name, **seq, **aseq, **bseq;
419 static Segment *segment = NULL;
420 static int anchors[MAXSEG];
434 LocalHom **localhomtable = NULL; // by D.Mathog
435 RNApair ***singlerna;
437 static char **nogap1seq;
438 static char *kozoarivec;
441 int **skipthisbranch;
443 int nsubalignments, maxmem;
448 int ntarget, *targetmap, *targetmapr;
451 arguments( argc, argv );
452 #ifndef enablemultithread
455 if( fastathreshold < 0.0001 ) constraint = 0;
459 infp = fopen( inputfile, "r" );
462 fprintf( stderr, "Cannot open %s\n", inputfile );
470 PreRead( stdin, &njob, &nlenmax );
480 fprintf( stderr, "At least 2 sequences should be input!\n"
481 "Only %d sequence found.\n", njob );
488 readsubalignmentstable( njob, NULL, NULL, &nsubalignments, &maxmem );
489 fprintf( stderr, "nsubalignments = %d\n", nsubalignments );
490 fprintf( stderr, "maxmem = %d\n", maxmem );
491 subtable = AllocateIntMtx( nsubalignments, maxmem+1 );
492 insubtable = AllocateIntVec( njob );
493 preservegaps = AllocateIntVec( njob );
494 for( i=0; i<njob; i++ ) insubtable[i] = 0;
495 for( i=0; i<njob; i++ ) preservegaps[i] = 0;
496 subalnpt = AllocateCharCub( nsubalignments, maxmem, 0 );
497 readsubalignmentstable( njob, subtable, preservegaps, NULL, NULL );
498 for( i=0; i<nsubalignments; i++ ) for( j=0; j<insubtable[i]; j++ )
500 if( subtable[i][j] < 0 )
502 fprintf( stderr, "Not supported in the iterative refinmenment mode.\n" );
503 fprintf( stderr, "Please use a positive number to represent a sequence.\n" );
510 segment = (Segment *)calloc( MAXSEG, sizeof( Segment ) );
511 // if( treemethod == 'X' || treemethod == 'E' || treemethod == 'q' )
512 topol = AllocateIntCub( njob, 2, njob );
513 len = AllocateDoubleMtx( njob, 2 );
514 eff = AllocateDoubleMtx( njob, njob );
515 seq = AllocateCharMtx( njob, nlenmax*9+1 );
516 name = AllocateCharMtx( njob, B+1 );
517 seq_g = AllocateCharMtx( njob, nlenmax*9+1 );
518 res_g = AllocateCharMtx( njob, nlenmax*9+1 );
519 aseq = AllocateCharMtx( njob, nlenmax*9+1 );
520 bseq = AllocateCharMtx( njob, nlenmax*9+1 );
521 nogap1seq = AllocateCharMtx( 1, nlenmax*1+1 );
522 alloclen = nlenmax * 9;
523 seq_g_bk = AllocateCharMtx( njob, 0 );
524 for( i=0; i<njob; i++ ) seq_g_bk[i] = seq_g[i];
525 kozoarivec = AllocateCharVec( njob );
526 skipthisbranch = AllocateIntMtx( njob, 2 );
527 for( i=0; i<njob; i++ ) skipthisbranch[i][0] = skipthisbranch[i][1] = 0;
531 Read( name, nlen, seq_g );
533 readData_pointer( infp, name, nlen, seq_g );
539 targetmap = calloc( njob, sizeof( int ) );
541 for( i=0; i<njob; i++ )
544 if( !strncmp( name[i]+1, "_focus_", 7 ) )
545 targetmap[i] = ntarget++;
547 targetmapr = calloc( ntarget, sizeof( int ) );
548 for( i=0; i<njob; i++ )
549 if( targetmap[i] != -1 ) targetmapr[targetmap[i]] = i;
554 targetmap = calloc( njob, sizeof( int ) );
555 targetmapr = calloc( njob, sizeof( int ) );
556 for( i=0; i<njob; i++ )
557 targetmap[i] = targetmapr[i] = i;
563 localhomtable = (LocalHom **)calloc( ntarget, sizeof( LocalHom *) );
564 for( i=0; i<ntarget; i++)
566 localhomtable[i] = (LocalHom *)calloc( ilim, sizeof( LocalHom ) );
567 for( j=0; j<ilim; j++)
569 localhomtable[i][j].start1 = -1;
570 localhomtable[i][j].end1 = -1;
571 localhomtable[i][j].start2 = -1;
572 localhomtable[i][j].end2 = -1;
573 localhomtable[i][j].overlapaa = -1.0;
574 localhomtable[i][j].opt = -1.0;
575 localhomtable[i][j].importance = -1.0;
576 localhomtable[i][j].next = NULL;
577 localhomtable[i][j].nokori = 0;
578 localhomtable[i][j].extended = -1;
579 localhomtable[i][j].last = localhomtable[i]+j;
580 localhomtable[i][j].korh = 'h';
582 if( !specifictarget ) ilim--;
584 fprintf( stderr, "Loading 'hat3' ... " );
586 prep = fopen( "hat3", "r" );
587 if( prep == NULL ) ErrorExit( "Make hat3." );
588 if( specifictarget ) readlocalhomtable2_target( prep, njob, localhomtable, kozoarivec, targetmap );
589 else readlocalhomtable2_half( prep, njob, localhomtable, kozoarivec );
591 // for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
592 // fprintf( stdout, "%d %d %d %d %d %d %d\n", i, j, localhomtable[i][j].opt, localhomtable[i][j].start1, localhomtable[i][j].end1, localhomtable[i][j].start2, localhomtable[i][j].end2 );
593 fprintf( stderr, "done.\n" );
596 fprintf( stderr, "Extending localhom ... " );
597 extendlocalhom( njob, localhomtable );
598 fprintf( stderr, "done.\n" );
601 for( i=0; i<njob; i++ ) if( kozoarivec[i] ) nkozo++;
605 // if( nlenmax > 30000 )
606 if( nlenmax > 50000 ) // version >= 6.823
611 fprintf( stderr, "\nnlenmax=%d, nagasugi!\n", nlenmax );
616 fprintf( stderr, "\nnevermemsave=1, nlenmax=%d, nagasugi!\n", nlenmax );
620 if( !constraint && !nevermemsave && alg != 'M' )
622 fprintf( stderr, "\nnlenmax=%d, Switching to the memsave mode\n", nlenmax );
628 if( specificityconsideration ) calcmaxdistclass();
630 for( i=0; i<njob; i++ )
636 for( i=0; i<njob; i++ )
638 identity *= ( nlen[i] == nlen[0] );
642 fprintf( stderr, "Input pre-aligned data\n" );
645 constants( njob, seq_g );
648 fprintf( stderr, "penalty = %d\n", penalty );
649 fprintf( stderr, "penalty_ex = %d\n", penalty_ex );
650 fprintf( stderr, "offset = %d\n", offset );
660 writePre( njob, name, nlen, seq_g, 1 );
672 c = seqcheck( seq_g );
675 fprintf( stderr, "Illegal character %c\n", c );
678 commongappick( njob, seq_g );
680 if( rnakozo && rnaprediction == 'm' )
682 singlerna = (RNApair ***)calloc( njob, sizeof( RNApair ** ) );
683 prep = fopen( "hat4", "r" );
684 if( prep == NULL ) ErrorExit( "Make hat4 using mccaskill." );
685 fprintf( stderr, "Loading 'hat4' ... " );
687 for( i=0; i<njob; i++ )
689 gappick0( nogap1seq[0], seq_g[i] );
690 nogaplen = strlen( nogap1seq[0] );
691 singlerna[i] = (RNApair **)calloc( nogaplen+1, sizeof( RNApair * ) );
692 for( j=0; j<nogaplen; j++ )
694 singlerna[i][j] = (RNApair *)calloc( 1, sizeof( RNApair ) );
695 singlerna[i][j][0].bestpos = -1;
696 singlerna[i][j][0].bestscore = -1.0;
698 singlerna[i][nogaplen] = NULL;
699 readmccaskill( prep, singlerna[i], nogaplen );
702 fprintf( stderr, "\ndone.\n" );
712 prep = fopen( "hat2", "r" );
713 if( !prep ) ErrorExit( "Make hat2." );
714 readhat2_pointer( prep, njob, name, eff );
717 fprintf( stderr, "eff = \n" );
718 for( i=0; i<njob-1; i++ )
720 for( j=i+1; j<njob; j++ )
722 fprintf( stderr, "%d-%d, %f\n", i, j, eff[i][j] );
724 fprintf( stderr, "\n" );
729 veryfastsupg_double_loadtree( njob, eff, topol, len, name );
731 fprintf( stderr, "eff = \n" );
732 for( i=0; i<njob-1; i++ )
734 for( j=i+1; j<njob; j++ )
736 fprintf( stderr, "%d-%d, %f\n", i, j, eff[i][j] );
738 fprintf( stderr, "\n" );
743 else if( intop ) // v6.528 deha if( intop ) dattanode intree ga mukou datta.
745 fprintf( stderr, "--topin has been disabled\n" );
747 // veryfastsupg_double_loadtop( njob, eff, topol, len );
749 else if( subalignment )
750 fixed_supg_double_treeout_constrained( njob, eff, topol, len, name, nsubalignments, subtable );
751 else if( treemethod == 'X' || treemethod == 'E' || treemethod == 'q' )
752 // veryfastsupg_double_outtree( njob, eff, topol, len, name );
753 fixed_musclesupg_double_treeout( njob, eff, topol, len, name );
754 else if( treemethod == 'n' )
755 nj( njob, eff, topol, len );
756 else if( treemethod == 's' )
757 spg( njob, eff, topol, len );
758 else if( treemethod == 'p' )
759 upg2( njob, eff, topol, len );
760 else ErrorExit( "Incorrect treemethod.\n" );
763 printf( "utree = %d\n", utree );
766 if( autosubalignment > 0.0 && subalignment == 0 )
768 // reporterr( "Computing skipthisbranch..\n" );
769 insubtable = AllocateIntVec( njob );
770 preservegaps = AllocateIntVec( njob );
771 subtable = calloc( 1, sizeof( char * ) );
772 subtable[0] = NULL; // for FreeIntMtx
773 for( i=0; i<njob; i++ ) insubtable[i] = 0;
774 for( i=0; i<njob; i++ ) preservegaps[i] = 0; // tsukawanaikamo
775 if( generatesubalignmentstable( njob, &subtable, &nsubalignments, &maxmem, topol, len, autosubalignment ) ) // subtable ha allocate sareru.
777 reporterr( "################################################################################################ \n" );
779 reporterr( "# WARNING: Iterative refinment was not done because you gave a large --fix value (%6.3f).\n", autosubalignment );
781 reporterr( "################################################################################################ \n" );
782 writePre( njob, name, nlen, seq_g, 1 );
784 FreeCharMtx( seq_g_bk );
786 FreeDoubleMtx( len );
787 FreeDoubleMtx( eff );
788 FreeIntMtx( skipthisbranch );
789 FreeIntMtx( subtable );
790 free( preservegaps );
795 // subtable = AllocateIntMtx( nsubalignments, maxmem+1 );
796 fprintf( stderr, "nsubalignments = %d, maxmem = %d\n", nsubalignments, maxmem );
797 subalnpt = AllocateCharCub( nsubalignments, maxmem, 0 );
799 for( i=0; i<nsubalignments; i++ )
801 reporterr( "subalignment %d\n", i );
802 for( j=0; subtable[i][j]!=-1; j++ )
804 reporterr( "%5d", subtable[i][j] );
810 for( i=0; i<nsubalignments; i++ ) for( j=0; j<insubtable[i]; j++ )
812 if( subtable[i][j] < 0 )
814 fprintf( stderr, "Not supported in the iterative refinmenment mode.\n" );
815 fprintf( stderr, "Please use a positive number to represent a sequence.\n" );
819 // reporterr( "done.\n" );
823 orderfp = fopen( "order", "w" );
826 fprintf( stderr, "Cannot open 'order'\n" );
829 for( i=0; (j=topol[njob-2][0][i])!=-1; i++ )
831 fprintf( orderfp, "%d\n", j );
833 for( i=0; (j=topol[njob-2][1][i])!=-1; i++ )
835 fprintf( orderfp, "%d\n", j );
841 fprintf( stderr, "\n" );
842 if( ( !utree && kobetsubunkatsu ) || constraint || !bunkatsu )
846 anchors[1] =strlen( seq_g[0] );
851 nseg = searchAnchors( njob, seq_g, segment );
853 fprintf( stderr, "### nseg = %d\n", nseg );
854 fprintf( stderr, "### seq_g[0] = %s\n", seq_g[0] );
855 fprintf( stderr, "### nlenmax = %d\n", nlenmax );
856 fprintf( stderr, "### len = %d\n", strlen( seq_g[0] ) );
861 for( i=0; i<nseg; i++ ) anchors[i+1] = segment[i].center;
862 anchors[nseg+1] = strlen( seq_g[0] );
866 for( i=0; i<nseg; i++ )
867 fprintf( stderr, "anchor[%d] = %d\n", i, anchors[i] );
872 //--------------- kokokara ----
873 if( subalignment || autosubalignment )
875 for( i=0; i<nsubalignments; i++ )
877 fprintf( stderr, "\nChecking subalignment %d:\n", i+1 );
878 alignmentlength = strlen( seq[subtable[i][0]] );
879 for( j=0; subtable[i][j]!=-1; j++ )
880 fprintf( stderr, " %d ", subtable[i][j]+1 );
881 // fprintf( stderr, " ##### %d-%d. %-30.30s\n", i, subtable[i][j]+1, name[subtable[i][j]]+1 );
882 fprintf( stderr, "\n" );
883 for( j=0; subtable[i][j]!=-1; j++ )
885 if( subtable[i][j] >= njob )
887 fprintf( stderr, "No such sequence, %d.\n", subtable[i][j]+1 );
890 if( alignmentlength != strlen( seq[subtable[i][j]] ) )
892 fprintf( stderr, "\n" );
893 fprintf( stderr, "###############################################################################\n" );
894 fprintf( stderr, "# ERROR!\n" );
895 fprintf( stderr, "# Subalignment %d must be aligned.\n", i+1 );
896 fprintf( stderr, "# Please check the alignment lengths of following sequences.\n" );
897 fprintf( stderr, "#\n" );
898 fprintf( stderr, "# %d. %-10.10s -> %d letters (including gaps)\n", subtable[i][0]+1, name[subtable[i][0]]+1, alignmentlength );
899 fprintf( stderr, "# %d. %-10.10s -> %d letters (including gaps)\n", subtable[i][j]+1, name[subtable[i][j]]+1, (int)strlen( seq[subtable[i][j]] ) );
900 fprintf( stderr, "#\n" );
901 fprintf( stderr, "# See http://mafft.cbrc.jp/alignment/software/merge.html for details.\n" );
902 if( subalignmentoffset )
904 fprintf( stderr, "#\n" );
905 fprintf( stderr, "# You specified seed alignment(s) consisting of %d sequences.\n", subalignmentoffset );
906 fprintf( stderr, "# In this case, the rule of numbering is:\n" );
907 fprintf( stderr, "# The aligned seed sequences are numbered as 1 .. %d\n", subalignmentoffset );
908 fprintf( stderr, "# The input sequences to be aligned are numbered as %d .. %d\n", subalignmentoffset+1, subalignmentoffset+njob );
910 fprintf( stderr, "###############################################################################\n" );
911 fprintf( stderr, "\n" );
914 insubtable[subtable[i][j]] = 1;
916 for( j=0; j<njob-1; j++ )
920 reporterr( "#### STEP%d\n", j );
921 for( k=0; topol[j][0][k]!=-1; k++ ) reporterr( "%3d ", topol[j][0][k] );
922 reporterr( "len=%f\n", len[j][0] );
923 for( k=0; topol[j][1][k]!=-1; k++ ) reporterr( "%3d ", topol[j][1][k] );
924 reporterr( "len=%f\n", len[j][1] );
927 if( includemember( topol[j][0], subtable[i] ) && !samemember( topol[j][0], subtable[i] ) )
929 skipthisbranch[j][0] = 1;
930 // reporterr( "SKIP 0 !!!!!!\n" );
932 if( includemember( topol[j][1], subtable[i] ) && !samemember( topol[j][1], subtable[i] ) )
934 skipthisbranch[j][1] = 1;
935 // reporterr( "SKIP 1 !!!!!!\n" );
939 for( j=0; j<njob-1; j++ )
941 if( samemember( topol[j][0], subtable[i] ) || samemember( topol[j][1], subtable[i] ) )
944 fprintf( stderr, " -> OK\n" );
948 if( !foundthebranch )
950 system( "cp infile.tree GuideTree" ); // tekitou
951 fprintf( stderr, "\n" );
952 fprintf( stderr, "###############################################################################\n" );
953 fprintf( stderr, "# ERROR!\n" );
954 fprintf( stderr, "# Subalignment %d does not seem to form a monophyletic cluster\n", i+1 );
955 fprintf( stderr, "# in the guide tree ('GuideTree' in this directory) internally computed.\n" );
956 fprintf( stderr, "# If you really want to use this subalignment, pelase give a tree with --treein \n" );
957 fprintf( stderr, "# http://mafft.cbrc.jp/alignment/software/treein.html\n" );
958 fprintf( stderr, "# http://mafft.cbrc.jp/alignment/software/merge.html\n" );
959 if( subalignmentoffset )
961 fprintf( stderr, "#\n" );
962 fprintf( stderr, "# You specified seed alignment(s) consisting of %d sequences.\n", subalignmentoffset );
963 fprintf( stderr, "# In this case, the rule of numbering is:\n" );
964 fprintf( stderr, "# The aligned seed sequences are numbered as 1 .. %d\n", subalignmentoffset );
965 fprintf( stderr, "# The input sequences to be aligned are numbered as %d .. %d\n", subalignmentoffset+1, subalignmentoffset+njob );
967 fprintf( stderr, "############################################################################### \n" );
968 fprintf( stderr, "\n" );
971 // commongappick( seq[subtable[i]], subalignment[i] ); // irukamo
974 for( i=0; i<njob-1; i++ )
976 fprintf( stderr, "STEP %d\n", i+1 );
977 fprintf( stderr, "group1 = " );
978 for( j=0; topol[i][0][j] != -1; j++ )
979 fprintf( stderr, "%d ", topol[i][0][j]+1 );
980 fprintf( stderr, "\n" );
981 fprintf( stderr, "SKIP -> %d\n\n", skipthisbranch[i][0] );
982 fprintf( stderr, "group2 = " );
983 for( j=0; topol[i][1][j] != -1; j++ )
984 fprintf( stderr, "%d ", topol[i][1][j]+1 );
985 fprintf( stderr, "\n" );
986 fprintf( stderr, "SKIP -> %d\n\n", skipthisbranch[i][1] );
990 for( i=0; i<njob; i++ )
992 if( insubtable[i] ) strcpy( bseq[i], seq[i] );
993 else gappick0( bseq[i], seq[i] );
996 for( i=0; i<nsubalignments; i++ )
998 for( j=0; subtable[i][j]!=-1; j++ ) subalnpt[i][j] = bseq[subtable[i][j]];
999 commongappick( j, subalnpt[i] );
1002 FreeIntMtx( subtable );
1004 for( i=0; i<nsubalignments; i++ ) free( subalnpt[i] );
1006 free( preservegaps );
1008 //--------------- kokomade ----
1013 for( i=0; i<njob; i++ ) res_g[i][0] = 0;
1015 for( iseg=0; iseg<nseg-1; iseg++ )
1017 int tmplen = anchors[iseg+1]-anchors[iseg];
1018 int pos = strlen( res_g[0] );
1019 for( j=0; j<njob; j++ )
1021 strncpy( seq[j], seq_g[j], tmplen );
1026 fprintf( stderr, "Segment %3d/%3d %4d-%4d\n", iseg+1, nseg-1, pos+1, pos+1+tmplen );
1028 fprintf( trap_g, "Segment %3d/%3d %4d-%4d\n", iseg+1, nseg-1, pos+1, pos+1+tmplen );
1031 returnvalue = TreeDependentIteration( njob, name, nlen, seq, bseq, topol, len, eff, skipthisbranch, alloclen, localhomtable, singlerna, nkozo, kozoarivec, ntarget, targetmap, targetmapr );
1033 for( i=0; i<njob; i++ )
1034 strcat( res_g[i], bseq[i] );
1036 FreeCharMtx( seq_g_bk );
1037 FreeIntCub( topol );
1038 FreeDoubleMtx( len );
1039 FreeDoubleMtx( eff );
1040 FreeIntMtx( skipthisbranch );
1044 if( specifictarget ) FreeLocalHomTable_part( localhomtable, ntarget, njob );
1045 else FreeLocalHomTable_half( localhomtable, njob );
1049 if( rnakozo && rnaprediction == 'm' )
1051 if( singlerna ) // nen no tame
1053 for( i=0; i<njob; i++ )
1055 for( j=0; singlerna[i][j]!=NULL; j++ )
1057 if( singlerna[i][j] ) free( singlerna[i][j] );
1059 if( singlerna[i] ) free( singlerna[i] );
1067 Write( stdout, njob, name, nlen, bseq );
1070 fprintf( stderr, "done\n" );
1071 fprintf( trap_g, "done\n" );
1077 writePre( njob, name, nlen, res_g, 1 );
1079 writeData( stdout, njob, name, nlen, res_g, 1 );
1083 if( spscoreout ) reporterr( "Unweighted sum-of-pairs score = %10.5f\n", sumofpairsscore( njob, res_g ) );
1090 signed int main( int argc, char *argv[] )
1097 gets( b ); njob = atoi( b );
1101 if( strstr( b, "ayhoff" ) ) scoremtx = 1;
1102 else if( strstr( b, "dna" ) || strstr( b, "DNA" ) ) scoremtx = -1;
1103 else if( strstr( b, "M-Y" ) || strstr( b, "iyata" ) ) scoremtx = 2;
1106 if( strstr( b, "constraint" ) ) cnst = 1;
1113 if( !strncmp( b, a, 1 ) )
1115 gets( b ); nlen[i] = atoi( b );
1116 if( nlen[i] > nlenmax ) nlenmax = nlen[i];
1120 if( nlenmax > N || njob > M )
1122 fprintf( stderr, "ERROR in main\n" );
1129 value = main1( nlen, argc, argv );