#define DEBUG 0
char *alignmentfile;
+int keeplength;
static void fillorichar( int nseq, int *oripos, char **a, char **s )
{
char *pta, *pts;
for( i=0; i<nseq; i++ )
{
+
pta = a[i];
pts = s[oripos[i]];
while( *pta )
if( *pta++ == 0 )
{
fprintf( stderr, "ERROR!!\n" );
- fprintf( stderr, "alignment is inconsistent with the original sequences\n" );
+ fprintf( stderr, "alignment is inconsistent with the original sequences (1)\n" );
exit( 1 );
}
}
if( *pts != 0 )
{
fprintf( stderr, "ERROR!!\n" );
- fprintf( stderr, "alignment is inconsistent with the original sequences\n" );
+ fprintf( stderr, "alignment is inconsistent with the original sequences (2)\n" );
exit( 1 );
}
}
{
int c;
+ keeplength = 0;
+
while( --argc > 0 && (*++argv)[0] == '-' )
{
while ( (c = *++argv[0]) )
alignmentfile = *++argv;
--argc;
goto nextoption;
+ case 'Z': // add2ndharfarg wo tsukau tame.
+ break;
+ case 'p': // add2ndharfarg wo tsukau tame.
+ break;
+ case 'Y':
+ keeplength = 1;
+ break;
default:
fprintf( stderr, "illegal option %c\n", c );
argc = 0;
{
FILE *infp;
FILE *alfp;
+ FILE *dlfp;
char **name;
char **aname;
char **oname;
char **aseq;
int *nlen;
int *oripos;
- char *npt, *npt2;
+ char *npt, *npt0, *npt2, *pt, *pt2;
int i, o, prelen;
int nlenmin;
int njobs, njoba;
+// int **dlist;
+// int *ndel;
+ char *gett;
arguments( argc, argv );
fprintf( stderr, "No alignment is given.\n" );
exit( 1 );
}
+
+ if( keeplength )
+ {
+ dlfp = fopen( "_deletelist", "r" );
+ if( !dlfp )
+ {
+ fprintf( stderr, "Cannot open _deletefile\n" );
+ exit( 1 );
+ }
+ }
dorp = NOTSPECIFIED;
getnumlen_casepreserve( infp, &nlenmin );
nlen = AllocateIntVec( njob );
oripos = AllocateIntVec( njob );
readData_pointer_casepreserve( infp, name, nlen, seq );
+ fclose( infp );
dorp = NOTSPECIFIED;
getnumlen( alfp );
aname = AllocateCharMtx( njob, B+1 );
oname = AllocateCharMtx( njob, B+1 );
readData_pointer( alfp, aname, nlen, aseq );
+ fclose( alfp );
for( i=0; i<njob; i++ ) gappick_samestring( seq[i] );
+// reporterr( "seq[njob-1] = %s\n", seq[njob-1] );
+
+ if( keeplength )
+ {
+ gett = calloc( 1000, sizeof( char ) );
+// ndel = (int *)calloc( njob, sizeof( int ) );
+// for( i=0; i<njob; i++ ) ndel[i] = 0;
+// dlist = (int **)calloc( njob+1, sizeof( int * ) );
+// for( i=0; i<njob; i++ ) dlist[i] = NULL;
+// dlist[njob] = NULL;
+
+ while( 1 )
+ {
+ fgets( gett, 999, dlfp );
+ if( feof( dlfp ) ) break;
+ sscanf( gett, "%d %d", &i, &o );
+// reporterr( "%d, %d\n", i, o );
+// dlist[i] = realloc( dlist[i], sizeof( int ) * (ndel[i]+2) );
+// dlist[i][ndel[i]] = o;
+// ndel[i]++;
+
+ seq[i][o] = '-';
+
+ }
+ fclose( dlfp );
+ }
+
+ for( i=0; i<njob; i++ )
+ {
+ gappick_samestring( seq[i] );
+ }
+
if( njoba != njobs )
{
fprintf( stderr, "ERROR!!\n" );
fprintf( stderr, "npt2 = %s\n", npt2 );
o = oripos[i] = atoi( npt2 );
- npt = strstr( npt2, "_oripos_" );
+ npt = strstr( npt2, "_oe_" );
if( npt == NULL )
{
fprintf( stderr, "Format error!\n" );
exit( 1 );
}
- npt += 8;
+ npt += 4;
strcat( oname[i], npt+1 );
#endif
- npt = strstr( aname[i], "_oripos_" );
- if( npt == NULL )
+ npt0 = strstr( aname[i], "_os_" );
+ if( npt0 == NULL )
{
fprintf( stderr, "Format error!\n" );
exit( 1 );
}
- npt2 = npt - 2;
- while( isdigit( *npt2-- ) );
- npt2 += 2;
- npt += 8;
+ npt2 = npt0 + 4;
o = oripos[i] = atoi( npt2 );
-// fprintf( stderr, "npt2 = :%s:\n", npt2 );
-// fprintf( stderr, "npt = :%s:\n", npt );
-// fprintf( stderr, "aname[i] = :%s:\n", aname[i] );
-// fprintf( stderr, "npt2-aname[i] = :%d:\n", npt2-aname[i] );
- prelen = npt2-aname[i];
+ npt = strstr( aname[i], "_oe_" );
+ if( npt == NULL )
+ {
+ fprintf( stderr, "Format error!\n" );
+ exit( 1 );
+ }
+ npt += 4;
+
+ pt2 = npt;
+ pt = npt2 - 4;
+ while( *pt ) *pt++ = *pt2++; // okashii
+
+ prelen = npt0-aname[i];
strncpy( oname[i], aname[i], prelen ); oname[i][prelen] = 0;
- strcat( oname[i], npt+1 );
+ strcat( oname[i], npt0 );
+
+#if 0
+ pt = strstr( aname[i], "_numo_e" );
+ if( pt ) pt += 8;
+ else pt = aname[i] + 1;
+
+ if( strstr( pt, "_seed_" ) ) pt += 6;
+
+ fprintf( stderr, "pt = :%s:\n", pt );
+
+#endif
+// fprintf( stderr, "npt0 = :%s:\n", npt0 );
+//
+// reporterr( "oname[i] = %s\n", oname[i] );
+// reporterr( "aname[i] = %s\n", aname[i] );
+// reporterr( " name[i] = %s\n", name[i] );
+
+// fprintf( stderr, "aname[i] = :%s:\n", aname[i] );
+// fprintf( stderr, "pt = :%s:\n", pt );
+// fprintf( stderr, "oname[i] = :%s:\n", oname[i] );
+// fprintf( stderr, "name[o] = :%s:\n", name[o] );
- if( strncmp( npt, name[o], 10 ) )
+ if( strncmp( npt0, name[o]+1, 10 ) )
{
fprintf( stderr, "ERROR!!\n" );
fprintf( stderr, "In input file,\n" );
fprintf( stderr, "name[%d] = %s\n", o, name[o] );
fprintf( stderr, "but in alignment file,\n" );
+ fprintf( stderr, "oname[%d] = %s\n", i, oname[i] );
+ fprintf( stderr, "npt0 = %s\n", npt0 );
+ fprintf( stderr, "prelen = %d\n", prelen );
fprintf( stderr, "name[%d] = %s\n", i, aname[i] );
exit( 1 );
}
FreeCharMtx( aseq );
FreeCharMtx( name );
FreeCharMtx( aname );
+ FreeCharMtx( oname );
free( nlen );
+ free( oripos );
return( 0 );
}