.pal");
197if(string::npos != found)
198rps_database[i]= rps_database[i].substr(0, found);
202static bool s_SortDbSize(const pair<string, Int8> & a, const pair<string, Int8> & b)
204return(a.second > b.second);
207static void s_MapDbToThread(vector<string> & db, unsigned int num_of_threads)
209unsigned int db_size = static_cast<unsigned int>(db.size());
210vector <pair <string, Int8> > p;
212for(unsigned int i=0; i < db_size; i++)
215CSeqDB::FindVolumePaths(db[i], CSeqDB::eProtein, path, NULL, true);
216_ASSERT(path.size() == 1);
217CFile f(path[0]+".loo");
218Int8 length = f.GetLength();
219_ASSERT(length > 0 );
220//Scale down, just in case
221p.push_back(make_pair(db[i], length/1000));
224sort(p.begin(), p.end(),s_SortDbSize);
226db.resize(num_of_threads);
227vector<Int8> acc_size(num_of_threads, 0);
229for(unsigned char i=0; i < num_of_threads; i++)
232acc_size[i] = p[i].second;
235for(unsigned int i= num_of_threads; i < db_size; i++)
237unsigned int min_index = 0;
238for(unsigned int j=1; j<num_of_threads; j++)
240if(acc_size[j] < acc_size[min_index])
244acc_size[min_index] += p[i].second;
245db[min_index] = db[min_index] + delimiter + p[i].first;
250CRef<CSearchResultSet> s_RunLocalRpsSearch(const string & db,
251CBlastQueryVector & query_vector,
252CRef<CBlastOptionsHandle> opt_handle)
254CSearchDatabase search_db(db, CSearchDatabase::eBlastDbIsProtein);
255CRef<CLocalDbAdapter> db_adapter(new CLocalDbAdapter(search_db));
256CRef<IQueryFactory> queries(new CObjMgr_QueryFactory(query_vector));
258CLocalBlast lcl_blast(queries, opt_handle, db_adapter);
259CRef<CSearchResultSet> results = lcl_blast.Run();
265class CRPSThread : public CThread
268CRPSThread(CRef<CBlastQueryVector> query_vector,
270CRef<CBlastOptions> options);
275CRef<CSearchResultSet> RunTandemSearches(void);
277CRPSThread(const CRPSThread &);
278CRPSThread & operator=(const CRPSThread &);
281CRef<CBlastOptionsHandle> m_opt_handle;
282CRef<CBlastQueryVector> m_query_vector;
287CRPSThread::CRPSThread(CRef<CBlastQueryVector> query_vector,
289CRef<CBlastOptions> options):
290m_query_vector(query_vector)
293m_opt_handle.Reset(new CBlastRPSOptionsHandle(options));
295s_ConvertConcatStringToVectorOfString(db, m_db);
298void* CRPSThread::Main(void)
300CRef<CSearchResultSet> * result = new (CRef<CSearchResultSet>);
303*result = s_RunLocalRpsSearch(m_db[0],
309*result = RunTandemSearches();
315CRef<CSearchResultSet> CRPSThread::RunTandemSearches(void)
317unsigned int num_of_db = static_cast<unsigned int>(m_db.size());
318vector<CRef<CSearchResultSet> > results;
320for(unsigned int i=0; i < num_of_db; i++)
322results.push_back(s_RunLocalRpsSearch(m_db[i],
327return s_CombineSearchSets(results, num_of_db);
330/* CThreadedRpsBlast */
331CLocalRPSBlast::CLocalRPSBlast(CRef<CBlastQueryVector> query_vector,
333CRef<CBlastOptionsHandle> options,
334unsigned int num_of_threads):
335m_num_of_threads(num_of_threads),
337m_opt_handle(options),
338m_query_vector(query_vector),
341CSeqDB::FindVolumePaths(db, CSeqDB::eProtein, m_rps_databases, NULL, true, true);
342m_num_of_dbs = static_cast<unsigned int>(m_rps_databases.size());
343if( 1 == m_num_of_dbs)
345m_num_of_threads = kDisableThreadedSearch;
349void CLocalRPSBlast::x_AdjustDbSize(void)
351if(m_opt_handle->GetOptions().GetEffectiveSearchSpace()!= 0)
354if(m_opt_handle->GetOptions().GetDbLength()!= 0)
357CSeqDB db(m_db_name, CSeqDB::eProtein);
359Uint8 db_size = db.GetTotalLengthStats();
360int num_seq = db.GetNumSeqsStats();
363db_size = db.GetTotalLength();
366num_seq = db.GetNumSeqs();
368m_opt_handle->SetOptions().SetDbLength(db_size);
369m_opt_handle->SetOptions().SetDbSeqNum(num_seq);
374CRef<CSearchResultSet> CLocalRPSBlast::Run(void)
376if(1 != m_num_of_dbs)
381if(kDisableThreadedSearch == m_num_of_threads)
383if(1 == m_num_of_dbs)
385return s_RunLocalRpsSearch(m_db_name, *m_query_vector, m_opt_handle);
389s_ModifyVolumePaths(m_rps_databases);
391vector<CRef<CSearchResultSet> > results;
392for(unsigned int i=0; i < m_num_of_dbs; i++)
394results.push_back(s_RunLocalRpsSearch(m_rps_databases[i],
399return s_CombineSearchSets(results, m_num_of_dbs);
405return RunThreadedSearch();
409CRef<CSearchResultSet> CLocalRPSBlast::RunThreadedSearch(void)
412s_ModifyVolumePaths(m_rps_databases);
414if((kAutoThreadedSearch == m_num_of_threads) ||
415(m_num_of_threads > m_rps_databases.size()))
417//Default num of thread : a thread for each db
418m_num_of_threads = static_cast<unsigned int>(m_rps_databases.size());
420else if(m_num_of_threads < m_rps_databases.size())
422// Combine databases, modified the size of rps_database
423s_MapDbToThread(m_rps_databases, m_num_of_threads);
426vector<CRef<CSearchResultSet> * > thread_results(m_num_of_threads, NULL);
427vector <CRPSThread* > thread(m_num_of_threads, NULL);
428vector<CRef<CSearchResultSet> > results;
430for(unsigned int t=0; t < m_num_of_threads; t++)
432// CThread destructor is protected, all threads destory themselves when terminated
433thread[t] = (new CRPSThread(m_query_vector, m_rps_databases[t], m_opt_handle->SetOptions().Clone()));
437for(unsigned int t=0; t < m_num_of_threads; t++)
439thread[t]->Join(reinterpret_cast<void**> (&thread_results[t]));
442for(unsigned int t=0; t < m_num_of_threads; t++)
444results.push_back(*(thread_results[t]));
447CRef<CBlastRPSInfo> rpsInfo = CSetupFactory::CreateRpsStructures(m_db_name,
448CRef<CBlastOptions> (&(m_opt_handle->SetOptions())));
449return s_CombineSearchSets(results, m_num_of_threads);
Declares the CBlastRPSOptionsHandle class.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
Main class to perform a BLAST search on the local machine.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines NCBI C++ exception handling.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Multi-threading â mutexes; rw-locks; semaphore.
Multi-threading â classes, functions, and features.
Defines: CTimeFormat - storage class for time format.
NOTE: This file contains work in progress and the APIs are likely to change, please do not rely on th...
static const char delimiter[]
Declares the CLocalRPSBlast class.
Defines BLAST database access classes.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4