Esempio n. 1
0
int main()
{
	int i, j;
	char **seq;
	static char name[M][B];
	static int nlen[M];
	double **mtx;
	FILE *fp;
	int res;

	scoremtx = NOTSPECIFIED;

#if 0
	PreRead( stdin, &njob, &nlenmax );
#else
	getnumlen( stdin );
#endif
	rewind( stdin );

	seq = AllocateCharMtx( njob, nlenmax+1 );
	mtx = AllocateDoubleMtx( njob, njob );

#if 0
	FRead( stdin, name, nlen, seq );
#else
	readData( stdin, name, nlen, seq );
#endif

	for( i=0; i<njob-1; i++ ) 
	{
		fprintf( stderr, "%4d/%4d\r", i+1, njob );
		for( j=i+1; j<njob; j++ ) 
			mtx[i][j] = (double)substitution_score( seq[i], seq[j] );
	}
	
#if TEST
	for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ ) 
		fprintf( stdout, "i=%d, j=%d, mtx[][] = %f\n", i, j, mtx[i][j] );
#endif

	fp = fopen( "hat2", "w" );
	WriteHat2( fp, njob, name, mtx );
	fclose( fp );
	exit( 0 );
/*
	res = system( ALNDIR "/spgsdl < hat2"  );
	if( res ) exit( 1 );
	else exit( 0 );
*/
}
Esempio n. 2
0
int main( int argc, char *argv[] )
{
	static int  nlen[M];	
	static char **name, **seq;
	int i, j, alloclen, c;
	double **mtx;
	double *self;
	double tmpdouble;
	FILE *fp;

	arguments( argc, argv );

	getnumlen( stdin );
	rewind( stdin );

	if( njob < 2 )
	{
		fprintf( stderr, "At least 2 sequences should be input!\n"
						 "Only %d sequence found.\n", njob ); 
		exit( 1 );
	}

	name = AllocateCharMtx( njob, B+1 );
	seq = AllocateCharMtx( njob, nlenmax*9+1 );
	mtx = AllocateDoubleMtx( njob, njob );
	self = AllocateDoubleVec( njob );
	alloclen = nlenmax*9;

	readData_pointer( stdin, name, nlen, seq );
	constants( njob, seq );




	c = seqcheck( seq );
	if( c )
	{
		fprintf( stderr, "Illeagal character %c\n", c );
		exit( 1 );
	}

	for( i=0; i<njob; i++ ) 
	{
		self[i] = (double)substitution_nid( seq[i], seq[i] );
//		fprintf( stdout, "self[%d] = %f\n", i, self[i] );
	}

	for( i=0; i<njob-1; i++ ) 
		for( j=i+1; j<njob; j++ ) 
		{
			tmpdouble = (double)substitution_score( seq[i], seq[j] );
//			fprintf( stdout, "tmpdouble = %f\n", tmpdouble );
			mtx[i][j] = ( 1.0 - tmpdouble / MIN( self[i], self[j] ) );
			if( mtx[i][j] < 0.95 )
				mtx[i][j] = - log( 1.0 - mtx[i][j] );
			else
				mtx[i][j] = 3.0;
		}
	
#if TEST
	for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ ) 
		fprintf( stdout, "i=%d, j=%d, mtx[][] = %f\n", i, j, mtx[i][j] );
#endif

	fp = fopen( "hat2", "w" );
	WriteHat2_pointer( fp, njob, name, mtx );
	fclose( fp );
	exit( 0 );

	return( 0 );
}