Пример #1
0
void Aligner::alignPartGreedy(){
	vector<pair<string,string>> multiread;
	vector<uNumber> path;
	string read,header;
	bool overlapFound(false);
	while(!readFile.eof()){
		readMutex.lock();
		{
			getReads(multiread,10000);
		}
		readMutex.unlock();
		for(uint i(0);i<multiread.size();++i){
			overlapFound=false;
			header=multiread[i].first;
			read=multiread[i].second;
			if(pathOption){
				path=alignReadGreedyPath(read,overlapFound,errorsMax,false);
			}else{
				path=alignReadGreedy(read,overlapFound,errorsMax,false);
			}
			if(path.size()!=0){
				// string lol(recoverPath(path,2*read.size()));
				// 	if(lol!=read){
				// 		lol=reverseComplements(lol);
				// 		if(lol!=read){
				// 			cin.get();
				// 		}
				// 	}
				pathMutex.lock();
				{
					pathFile<<header<<endl;
					printPath(path,&pathFile);
				}
				pathMutex.unlock();
			}else{
				if(!overlapFound){
					noOverlapMutex.lock();
					{
						noOverlapFile<<header<<endl<<read<<endl;
						//~ notMappedFile<<read<<endl;
					}
					noOverlapMutex.unlock();
				}else{
					notMappedMutex.lock();
					{
						notMappedFile<<header<<endl<<read<<endl;
						//~ notMappedFile<<read<<endl;
					}
					notMappedMutex.unlock();
				}
			}
		}
		if(iter++%10==0){
			cout<<"Read : "<<readNumber<<endl;
			cout<<"No Overlap : "<<noOverlapRead<<" Percent : "<<(100*float(noOverlapRead))/readNumber<<endl;
			cout<<"Got Overlap : "<<alignedRead+notAligned<<" Percent : "<<(100*float(alignedRead+notAligned))/readNumber<<endl;
			cout<<"Overlap and Aligned : "<<alignedRead<<" Percent : "<<(100*float(alignedRead))/(alignedRead+notAligned)<<endl;
			cout<<"Overlap but no aligne: "<<notAligned<<" Percent : "<<(100*float(notAligned))/(alignedRead+notAligned)<<endl;
			auto end=chrono::system_clock::now();auto waitedFor=end-startChrono;
			cout<<"Reads/seconds : "<<readNumber/(chrono::duration_cast<chrono::seconds>(waitedFor).count()+1)<<endl;
			// cout<<"Overlap per reads : "<<(overlaps)/(alignedRead+notAligned)<<endl;
			cout<<endl;
		}
	}
}
Пример #2
0
void Aligner::alignPartGreedy(){
	vector<pair<string,string>> multiread;
	vector<uNumber> path;
	string read,header,corrected;
	bool overlapFound(false);
	while(!readFile.eof()){
		readMutex.lock();
		{
			getReads(multiread,10000);
		}
		readMutex.unlock();
		for(uint i(0);i<multiread.size();++i){
			overlapFound=false;
			header=multiread[i].first;
			read=multiread[i].second;
			if(pathOption){
				path=alignReadGreedyPath(read,overlapFound,errorsMax,false);
			}else{
				path=alignReadGreedy(read,overlapFound,errorsMax,false);
			}
			if(path.size()!=0){
				if(correctionMode){
				//if(true){
					corrected=(recoverPath(path,read.size()));
					// pathFile<<header<<'\n';
					// pathFile<<corrected<<'\n';
					header+='\n'+corrected+'\n';
					pathMutex.lock();
					{
						fwrite((header).c_str(), sizeof(char), header.size(), pathFilef);
					}
					pathMutex.unlock();
			}else{
					// pathFile<<header<<'\n';
					header+='\n'+printPath(path);;
					pathMutex.lock();
					{
						fwrite((header).c_str(), sizeof(char), header.size(), pathFilef);
					}
					pathMutex.unlock();
				}
			}else{
				if(false){
					noOverlapMutex.lock();
					{
						noOverlapFile<<header<<'\n'<<read<<'\n';
					}
					noOverlapMutex.unlock();
				}else{
					header+='\n'+read+'\n';
					notMappedMutex.lock();
					{
						// notMappedFile<<header<<'\n'<<read<<'\n';

						fwrite(header.c_str(), sizeof(char), header.size(), notMappedFilef);
						// notMappedFile<<readNumber<<'\n';
						// cout<<header<<'\n'<<read<<'\n';
					}
					notMappedMutex.unlock();
				}
			}
		}
		// if(iter++%10==0){
		// 	cout<<"Read : "<<readNumber<<endl;
		// 	cout<<"No Overlap : "<<noOverlapRead<<" Percent : "<<(100*float(noOverlapRead))/readNumber<<endl;
		// 	cout<<"Got Overlap : "<<alignedRead+notAligned<<" Percent : "<<(100*float(alignedRead+notAligned))/readNumber<<endl;
		// 	cout<<"Overlap and Aligned : "<<alignedRead<<" Percent : "<<(100*float(alignedRead))/(alignedRead+notAligned)<<endl;
		// 	cout<<"Overlap but no aligne: "<<notAligned<<" Percent : "<<(100*float(notAligned))/(alignedRead+notAligned)<<endl;
		// 	auto end=chrono::system_clock::now();auto waitedFor=end-startChrono;
		// 	cout<<"Reads/seconds : "<<readNumber/(chrono::duration_cast<chrono::seconds>(waitedFor).count()+1)<<endl;
		// 	// cout<<"Overlap per reads : "<<(overlaps)/(alignedRead+notAligned)<<endl;
		// 	cout<<endl;
		// }
	}
}