예제 #1
0
static void output_1contig ( int id, EDGE * edge, FILE * fp, boolean tip )
{
	int i;
	Kmer kmer;
	char ch;
	fprintf ( fp, ">%d length %d cvg_%.1f_tip_%d\n", id, edge->length + overlaplen, ( double ) edge->cvg / 10, tip );
	//fprintf(fp,">%d\n",id);
	kmer = vt_array[edge->from_vt].kmer;

	for ( i = overlaplen - 1; i >= 0; i-- )
	{
		ch = kmer & 3;
		kmer >>= 2;
		kmerSeq[i] = ch;
	}

	for ( i = 0; i < overlaplen; i++ )
		{ fprintf ( fp, "%c", int2base ( ( int ) kmerSeq[i] ) ); }

	for ( i = 0; i < edge->length; i++ )
	{
		fprintf ( fp, "%c", int2base ( ( int ) getCharInTightString ( edge->seq, i ) ) );

		if ( ( i + overlaplen + 1 ) % 100 == 0 )
			{ fprintf ( fp, "\n" ); }
	}

	fprintf ( fp, "\n" );
}
예제 #2
0
int EdgeEqual ( unsigned int prev, unsigned int next )
{
	int i = 0;
	int length = edge_array[prev].length;
	char ch1, ch2;
	int equal = 0;

	for ( i = 0; i < length; ++i )
	{
		ch1 = int2base ( ( int ) getCharInTightString ( edge_array[prev].seq, i ) );
		ch2 = int2base ( ( int ) getCharInTightString ( edge_array[next].seq, i ) );

		if ( ( equal = BaseEqual ( ch1, ch2 ) ) )
		{
			return equal;
		}
	}

	return 0;
};
예제 #3
0
void copySeq (char *targetS, char *sourceS, int pos, int length)
{
	char ch;
	int i, index;

	index = pos;

	for (i = 0; i < length; i++)
	{
		ch = getCharInTightString (sourceS, i);
		writeChar2tightString (ch, targetS, index++);
	}
}
예제 #4
0
/*
void print_kmer(FILE *fp,Kmer kmer,char c)
{
    fprintf(fp,"%llx %llx %llx %llx",kmer.high1,kmer.low1,kmer.high2,kmer.low2);
    fprintf(fp,"%c",c);

}*/
void printTightString (char *tightSeq, int len)
{
	int i;

	for (i = 0; i < len; i++)
	{
		printf ("%c", int2base ((int) getCharInTightString (tightSeq, i)));
		if ((i + 1) % 100 == 0)
		{
			printf ("\n");
		}
	}
	printf ("\n");
}
예제 #5
0
static void printEdgeSeq (FILE * fp, char *tightSeq, int len)
{
	int i;

	for (i = 0; i < len; i++)
	{
		fprintf (fp, "%c", int2base ((int) getCharInTightString (tightSeq, i)));

		if ((i + overlaplen + 1) % 100 == 0)
		{
			fprintf (fp, "\n");
		}
	}

	fprintf (fp, "\n");
}
예제 #6
0
void output_1contig (int id, EDGE * edge, FILE * fp, boolean tip) 
{
	int i;
	Kmer kmer;

	fprintf (fp, ">%d length %d cvg_%.1f_tip_%d\n", id, edge->length + overlaplen, (double) edge->cvg / 10, tip);	

	kmer = vt_array[edge->from_vt].kmer;
	printKmerSeq ( fp, kmer );

	for (i = 0; i < edge->length; i++)
	{
		fprintf (fp, "%c", int2base ((int) getCharInTightString (edge->seq, i)));
		if ((i + overlaplen + 1) % 100 == 0)		
		{
			fprintf (fp, "\n");
		}
	}
	fprintf (fp, "\n");
}
예제 #7
0
static int cmp_seq ( const void * a, const void * b )
{
	EDGE * A, *B;
	A = ( EDGE * ) a;
	B = ( EDGE * ) b;

	if ( KmerLarger ( vt_array[A->from_vt].kmer, vt_array[B->from_vt].kmer ) )
	{
		return 1;
	}
	else if ( KmerSmaller ( vt_array[A->from_vt].kmer , vt_array[B->from_vt].kmer ) )
	{
		return -1;
	}
	else
	{
		if ( A->seq[0] > B->seq[0] )
		{
			return 1;
		}
		else if ( A->seq[0] == B->seq[0] )
		{
			int i = 0;

			for ( i = 1; i < A->length && i < B->length; i++ )
			{
				if ( getCharInTightString ( A->seq, i ) > getCharInTightString ( B->seq, i ) )
					{ return 1; }
				else if ( getCharInTightString ( A->seq, i ) < getCharInTightString ( B->seq, i ) )
					{ return -1; }
			}

			if ( i == A->length && i < B->length )
				{ return -1; }
			else if ( i < A->length && i ==  B->length )
				{ return 1; }
			else
			{
				printKmerSeq ( stderr , vt_array[A->from_vt].kmer );
				fprintf ( stderr , "\n" );
				printKmerSeq ( stderr , vt_array[B->from_vt].kmer );
				fprintf ( stderr , "\n" );

				for ( i = 0; i < A->length; i++ )
				{
					printf( "%c", int2base ( ( int ) getCharInTightString ( A->seq, i ) ) );
				}

				printf( "\n" );

				for ( i = 0; i < B->length; i++ )
				{
					printf( "%c", int2base ( ( int ) getCharInTightString ( B->seq, i ) ) );
				}

				printf( "\n" );
				printf( "cmp_seq:\terr\n" );
				exit ( 0 );
				return 0;
			}
		}
		else
		{
			return -1;
		}
	}
};