コード例 #1
0
ファイル: prlHashReads.c プロジェクト: Buttonwood/SOAPdenovo2
static void thread_mark ( KmerSet * set, unsigned char thrdID )
{
	int i, in_num, out_num, cvgSingle;
	int l_cvg, r_cvg;
	kmer_t * rs;
	long long counter = 0;
	set->iter_ptr = 0;

	while ( set->iter_ptr < set->size )
	{
		if ( !is_kmer_entity_null ( set->flags, set->iter_ptr ) )
		{
			in_num = out_num = l_cvg = r_cvg = 0;
			rs = set->array + set->iter_ptr;

			for ( i = 0; i < 4; i++ )
			{
				cvgSingle = get_kmer_left_cov ( *rs, i );

				if ( cvgSingle > 0 )
				{
					in_num++;
					l_cvg += cvgSingle;
				}

				cvgSingle = get_kmer_right_cov ( *rs, i );

				if ( cvgSingle > 0 )
				{
					out_num++;
					r_cvg += cvgSingle;
				}
			}

			if ( rs->single )
			{
				kmerFreq[thrdID][1]++;
				counter++;
			}
			else
			{
				kmerFreq[thrdID][ ( l_cvg > r_cvg ? l_cvg : r_cvg )]++;
			}

			if ( in_num == 1 && out_num == 1 )
			{
				rs->linear = 1;
				tips[thrdID]++;
			}
		}

		set->iter_ptr++;
	}

	//printf("%lld single nodes, %lld linear\n",counter,tips[thrdID]);
}
コード例 #2
0
ファイル: prlHashReads.c プロジェクト: Buttonwood/SOAPdenovo2
static void thread_delow ( KmerSet * set, unsigned char thrdID )
{
	int i, in_num, out_num, cvgSingle;
	int l_cvg, r_cvg;
	kmer_t * rs;
	set->iter_ptr = 0;

	while ( set->iter_ptr < set->size )
	{
		if ( !is_kmer_entity_null ( set->flags, set->iter_ptr ) )
		{
			in_num = out_num = l_cvg = r_cvg = 0;
			rs = set->array + set->iter_ptr;

			for ( i = 0; i < 4; i++ )
			{
				cvgSingle = get_kmer_left_cov ( *rs, i );

				if ( cvgSingle > 0 && cvgSingle <= deLowKmer )
				{
					set_kmer_left_cov ( *rs, i, 0 );
				}

				cvgSingle = get_kmer_right_cov ( *rs, i );

				if ( cvgSingle > 0 && cvgSingle <= deLowKmer )
				{
					set_kmer_right_cov ( *rs, i, 0 );
				}
			}

			if ( rs->l_links == 0 && rs->r_links == 0 )
			{
				rs->deleted = 1;
				tips[thrdID]++;
			}
		}

		set->iter_ptr++;
	}

	//printf("%lld single nodes, %lld linear\n",counter,tips[thrdID]);
}
コード例 #3
0
ファイル: node2edge.c プロジェクト: Bioinfo-Tools/PANGEA-plus
static void stringBeads ( KMER_PT * firstBead, char nextch, int * node_c )
{
	boolean smaller, found;
	Kmer tempKmer, bal_word;
	Kmer word = firstBead->kmer;
	ubyte8 hash_ban;
	kmer_t * outgoing_node;
	int nodeCounter = 1, setPicker;
	char ch;
	unsigned char flag;
	KMER_PT * temp_pt, *prev_pt = firstBead;
	word = prev_pt->kmer;
	nodeCounter = 1;
	word = nextKmer ( word, nextch );
	bal_word = reverseComplement ( word, overlaplen );

	if ( KmerLarger ( word, bal_word ) )
	{
		tempKmer = bal_word;
		bal_word = word;
		word = tempKmer;
		smaller = 0;
	}
	else
		{ smaller = 1; }

	hash_ban = hash_kmer ( word );
	setPicker = hash_ban % thrd_num;
	found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node );

	while ( found && ( outgoing_node->linear ) )   // for every node in this line
	{
		nodeCounter++;
		temp_pt = ( KMER_PT * ) stackPush ( nodeStack );
		temp_pt->node = outgoing_node;
		temp_pt->isSmaller = smaller;

		if ( smaller )
			{ temp_pt->kmer = word; }
		else
			{ temp_pt->kmer = bal_word; }

		prev_pt = temp_pt;

		if ( smaller )
		{
			for ( ch = 0; ch < 4; ch++ )
			{
				flag = get_kmer_right_cov ( *outgoing_node, ch );

				if ( flag )
					{ break; }
			}

			word = nextKmer ( prev_pt->kmer, ch );
			bal_word = reverseComplement ( word, overlaplen );

			if ( KmerLarger ( word, bal_word ) )
			{
				tempKmer = bal_word;
				bal_word = word;
				word = tempKmer;
				smaller = 0;
			}
			else
				{ smaller = 1; }

			hash_ban = hash_kmer ( word );
			setPicker = hash_ban % thrd_num;
			found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node );
		}
		else
		{
			for ( ch = 0; ch < 4; ch++ )
			{
				flag = get_kmer_left_cov ( *outgoing_node, ch );

				if ( flag )
					{ break; }
			}

			word = nextKmer ( prev_pt->kmer, int_comp ( ch ) );
			bal_word = reverseComplement ( word, overlaplen );

			if ( KmerLarger ( word, bal_word ) )
			{
				tempKmer = bal_word;
				bal_word = word;
				word = tempKmer;
				smaller = 0;
			}
			else
				{ smaller = 1; }

			hash_ban = hash_kmer ( word );
			setPicker = hash_ban % thrd_num;
			found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node );
		}
	}

	if ( outgoing_node ) //this is always true
	{
		nodeCounter++;
		temp_pt = ( KMER_PT * ) stackPush ( nodeStack );
		temp_pt->node = outgoing_node;
		temp_pt->isSmaller = smaller;

		if ( smaller )
			{ temp_pt->kmer = word; }
		else
			{ temp_pt->kmer = bal_word; }
	}

	*node_c = nodeCounter;
}
コード例 #4
0
ファイル: node2edge.c プロジェクト: Bioinfo-Tools/PANGEA-plus
//search linear structure starting with the root of a tree
static int startEdgeFromNode ( kmer_t * node1, FILE * fp )
{
	int node_c, palindrome;
	unsigned char flag;
	KMER_PT * ite_pt, *temp_pt;
	Kmer word1, bal_word1;
	char ch1;

	if ( node1->linear || node1->deleted )
		{ return 0; }

	// ignore floating loop
	word1 = node1->seq;
	bal_word1 = reverseComplement ( word1, overlaplen );

	// linear structure
	for ( ch1 = 0; ch1 < 4; ch1++ )     // for every node on outgoing list
	{
		flag = get_kmer_right_cov ( *node1, ch1 );

		if ( !flag )
			{ continue; }

		emptyStack ( nodeStack );
		temp_pt = ( KMER_PT * ) stackPush ( nodeStack );
		temp_pt->node = node1;
		temp_pt->isSmaller = 1;
		temp_pt->kmer = word1;
		stringBeads ( temp_pt, ch1, &node_c );

		//printf("%d nodes\n",node_c);
		if ( node_c < 2 )
			{ printf ( "%d nodes in this line!!!!!!!!!!!\n", node_c ); }
		else
		{
			//make a reverse complement node list
			stackBackup ( nodeStack );
			emptyStack ( bal_nodeStack );

			while ( ( ite_pt = ( KMER_PT * ) stackPop ( nodeStack ) ) != NULL )
			{
				temp_pt = ( KMER_PT * ) stackPush ( bal_nodeStack );
				temp_pt->kmer = reverseComplement ( ite_pt->kmer, overlaplen );
			}

			stackRecover ( nodeStack );
			palindrome = check_iden_kmerList ( nodeStack, bal_nodeStack );
			stackRecover ( nodeStack );

			if ( palindrome )
			{
				merge_linearV2 ( 0, nodeStack, node_c, fp );
			}
			else
				{ merge_linearV2 ( 1, nodeStack, node_c, fp ); }
		}
	} //every possible outgoing edges

	for ( ch1 = 0; ch1 < 4; ch1++ )     // for every node on incoming list
	{
		flag = get_kmer_left_cov ( *node1, ch1 );

		if ( !flag )
			{ continue; }

		emptyStack ( nodeStack );
		temp_pt = ( KMER_PT * ) stackPush ( nodeStack );
		temp_pt->node = node1;
		temp_pt->isSmaller = 0;
		temp_pt->kmer = bal_word1;
		stringBeads ( temp_pt, int_comp ( ch1 ), &node_c );

		if ( node_c < 2 )
			{ printf ( "%d nodes in this line!!!!!!!!!!!\n", node_c ); }
		else
		{
			//make a reverse complement node list
			stackBackup ( nodeStack );
			emptyStack ( bal_nodeStack );

			while ( ( ite_pt = ( KMER_PT * ) stackPop ( nodeStack ) ) != NULL )
			{
				temp_pt = ( KMER_PT * ) stackPush ( bal_nodeStack );
				temp_pt->kmer = reverseComplement ( ite_pt->kmer, overlaplen );
			}

			stackRecover ( nodeStack );
			palindrome = check_iden_kmerList ( nodeStack, bal_nodeStack );
			stackRecover ( nodeStack );

			if ( palindrome )
			{
				merge_linearV2 ( 0, nodeStack, node_c, fp );
				//printf("edge is palindrome with length %d\n",temp_edge.length);
			}
			else
				{ merge_linearV2 ( 1, nodeStack, node_c, fp ); }
		}
	} //every possible incoming edges

	return 0;
}