Example #1
0
pid_t		op_pipe(t_ast *tree, int pfd_old[2])
{
	int			pfd[2];
	pid_t		pid;

	pid = 0;
	if (pipe(pfd) != -1)
	{
		if (tree->left)
		{
			if (tree->left->tk->prio == 1)
				ft_redir_pipe(tree, pfd_old, pfd);
			else
				pid = execute(tree->left->tk->value, pfd_old, pfd, 1);
			if (pfd_old)
				close_pfd(pfd_old);
			if (tree->right && tree->right->tk->prio > 0)
				resolve_tree(tree->right, pfd);
			else
				op_pipe2(tree, pfd, &pid);
		}
		else
			error("42sh: parse error near `|'\n");
	}
	return (pid);
}
Example #2
0
void		op_pipe3(t_ast *tree, t_token *token, int pfd[2], int *pid)
{
	if (token)
		fill_tree(token, &tree->right);
	if (tree->right && tree->right->tk->prio > 0)
		resolve_tree(tree->right, pfd);
	else
		op_pipe2(tree, pfd, pid);
}
Example #3
0
int classify_seq(kseq_t *trunk, int trunkNum,  bwt& bt, cly_r *results, int offset)
{
		
	int read_len;
	
	char *useRead;

	char *qual;

	int match_len;
	int  matchNum;	
	//int spacedLen;
	int counterIntervals;
	int hit_counter;
	//fprintf(stderr,"dddddd");	
	for (int i=0; i<trunkNum; ++i) {
		read_len = trunk[i].seq.l;
		useRead = trunk[i].seq.s;
		qual = trunk[i].qual.s;
		map<uint32_t, uint32_t> hit_times; 
		transIntoBytes(useRead, read_len);
		//cout<<useRead<<endl;i
		counterIntervals = splitBytes(byteFormat, read_len, _kmer);
		//cout<<counterIntervals<<endl;
		int spacedLen = 20;
		hit_counter = 0;
		//int ind = 4;
		while (spacedLen) {
			//spacedLen = spacedLeng[ind];
			for (int j=0; j<counterIntervals;++j) {
				int start = intervals[(j<<1)];
				int p_len = intervals[(j<<1) + 1];
				//cout<<p_len<<"\t"<<start<<endl;
				do {                                    
					matchNum = bt.exactMatch(byteFormat + start,   p_len, match_len, assignedTID);
					//cout<<match_len<<"\t"<<mismatch<<endl;	
						
					//cout<<match_len<<"\t"<<p_len<<"\t"<<spacedLen<<endl;
					//if (matchNum) {
						//++hit_counter;
						
						while (matchNum) {
							++hit_counter;
							hit_times[assignedTID[--matchNum]] += match_len;
							//cout<<assignedTID[matchNum]<<"\t";
						}
					
					//}
					//cout<<endl;
					if (match_len < spacedLen) p_len -= spacedLen;
					else p_len -= (match_len/spacedLen)*spacedLen;
				} while (p_len > _kmer);
			}	
			if (hit_counter)
				break;
			else 
				//--ind;
				spacedLen -= 5;
		
		}	
			//cout<<endl;
		cly_r *results_bulk = results + (i << 1) + offset;
		int buff_pos = 0;
		
		results_bulk->read_Name = trunk[i].name.s;

		//hit_times[1286170] = 29;
		map<uint32_t, uint32_t>::iterator it = hit_times.begin();
		while (buff_pos < 2026 && it != hit_times.end() ) {
			//buff_pos += sprintf(results_bulk->algn_r + buff_pos, "%u:%u ", it->first, it->second );
			++it;
		}
		results_bulk->algn_r[buff_pos] = '\0';
		//cout<<endl;
		uint32_t lab = resolve_tree(hit_times);

		if (lab) {
			results_bulk->tid = lab;
			results_bulk->isClassified = 'C';
		} else {
			results_bulk->tid = 0;
			results_bulk->isClassified = 'U';
		}	
	}
	//fprintf(stderr,"seconds %f\n",(float)tk/CLOCKS_PER_SEC);

	return NORMAL_EXIT;
}
Example #4
0
int classify_seq_2(kseq_t *trunk, int trunkNum,  bwt& bt, cly_r *results)
{
		
	int read_len;
	
	char *useRead;

	char *qual;

	int match_len;
	int  matchNum;	
	int counterIntervals;
	for (int i=0; i<trunkNum; ++i) {
		read_len = trunk[i].seq.l;
		useRead = trunk[i].seq.s;
		qual = trunk[i].qual.s;
		map<uint32_t, uint32_t> hit_times; 
		transIntoBytes(useRead, read_len);
		//cout<<useRead<<endl;i
		counterIntervals = splitBytes(byteFormat, read_len, _kmer);
		//cout<<counterIntervals<<endl;
		for (int j=0; j<counterIntervals;++j) {
			int start = intervals[(j<<1)];
			int p_len = intervals[(j<<1) + 1];
			//cout<<p_len<<"\t"<<start<<endl;
			do {
				matchNum = bt.exactMatch(byteFormat + start,   p_len, match_len, assignedTID);
				//cout<<match_len<<"\t"<<mismatch<<endl;	
				if (matchNum) {
					while (matchNum) hit_times[assignedTID[--matchNum]] += match_len;
					p_len -= (match_len - _kmer);
				} else 
					p_len -= _interval;
				//cout<<match_len<<"\t"<<p_len<<"\t"<<spacedLen<<endl;
			} while (p_len > _kmer);
		
		}	
			//cout<<endl;
		cly_r *results_bulk = results + i;
		int buff_pos = 0;
		
		results_bulk->read_Name = trunk[i].name.s;


		map<uint32_t, uint32_t>::iterator it = hit_times.begin();
		while (it != hit_times.end()) {
			buff_pos += sprintf(results_bulk->algn_r + buff_pos, "%u:%u ", it->first, it->second );
			++it;
		}
		results_bulk->algn_r[buff_pos] = '\0';
		//cout<<endl;
		uint32_t lab = resolve_tree(hit_times);

		if (lab) {
			results_bulk->tid = lab;
			results_bulk->isClassified = 'C';
		} else {
			results_bulk->tid = 0;
			results_bulk->isClassified = 'U';
		}	
	}
	//fprintf(stderr,"seconds %f\n",(float)tk/CLOCKS_PER_SEC);

	return NORMAL_EXIT;
}