void CBlastScopeSource::AddDataLoaders(CRef<objects::CScope> scope) { const int blastdb_loader_priority = kBlastDbLoaderPriority + (s_CountBlastDbDataLoaders() - 1); // Note that these priorities are needed so that the CScope::AddXXX methods // don't need a specific priority (the default will be fine). if (!m_BlastDbLoaderName.empty()) { _TRACE("Adding " << m_BlastDbLoaderName << " at priority " << blastdb_loader_priority); scope->AddDataLoader(m_BlastDbLoaderName, blastdb_loader_priority); } if (!m_GbLoaderName.empty()) { _TRACE("Adding " << m_GbLoaderName << " at priority " << (int)CBlastScopeSource::kGenbankLoaderPriority); scope->AddDataLoader(m_GbLoaderName, kGenbankLoaderPriority); } }
void InitializeSubject(CRef<blast::CBlastDatabaseArgs> db_args, CRef<blast::CBlastOptionsHandle> opts_hndl, bool is_remote_search, CRef<blast::CLocalDbAdapter>& db_adapter, CRef<objects::CScope>& scope) { db_adapter.Reset(); _ASSERT(db_args.NotEmpty()); CRef<CSearchDatabase> search_db = db_args->GetSearchDatabase(); // Initialize the scope... if (is_remote_search) { const bool is_protein = Blast_SubjectIsProtein(opts_hndl->GetOptions().GetProgramType()) ? true : false; SDataLoaderConfig config(is_protein); if (search_db.NotEmpty() && search_db->GetDatabaseName() != "n/a") { config.m_BlastDbName = search_db->GetDatabaseName(); } CBlastScopeSource scope_src(config); // configure scope to fetch sequences remotely for formatting if (scope.NotEmpty()) { scope_src.AddDataLoaders(scope); } else { scope = scope_src.NewScope(); } } else { if (scope.Empty()) { scope.Reset(new CScope(*CObjectManager::GetInstance())); } } _ASSERT(scope.NotEmpty()); // ... and then the subjects CRef<IQueryFactory> subjects; if ( (subjects = db_args->GetSubjects(scope)) ) { _ASSERT(search_db.Empty()); db_adapter.Reset(new CLocalDbAdapter(subjects, opts_hndl)); } else { _ASSERT(search_db.NotEmpty()); try { // Try to open the BLAST database even for remote searches, as if // it is available locally, it will be better to fetch the // sequence data for formatting from this (local) source CRef<CSeqDB> seqdb = search_db->GetSeqDb(); db_adapter.Reset(new CLocalDbAdapter(*search_db)); scope->AddDataLoader(RegisterOMDataLoader(seqdb)); } catch (const CSeqDBException&) { // The BLAST database couldn't be found, report this for local // searches, but for remote searches go on. if (is_remote_search ) { db_adapter.Reset(new CLocalDbAdapter(*search_db)); } else { throw; } } } /// Set the BLASTDB data loader as the default data loader (if applicable) if (search_db.NotEmpty()) { string dbloader_name = s_FindBlastDbDataLoaderName(search_db->GetDatabaseName(), search_db->IsProtein()); if ( !dbloader_name.empty() ) { // FIXME: will this work with multiple BLAST DBs? scope->AddDataLoader(dbloader_name, CBlastDatabaseArgs::kSubjectsDataLoaderPriority); _TRACE("Setting " << dbloader_name << " priority to " << (int)CBlastDatabaseArgs::kSubjectsDataLoaderPriority << " for subjects"); } } }