int CVecScreenApp::Run(void) { int status = BLAST_EXIT_SUCCESS; try { // Allow the fasta reader to complain on invalid sequence input SetDiagPostLevel(eDiag_Warning); const bool kIsProtein(false); /*** Process the command line arguments ***/ const CArgs& args = GetArgs(); const string kDbName(args[kArgDb].AsString()); CRef<CBlastOptionsHandle> opts_hndl(CBlastOptionsFactory::Create(eVecScreen)); /*** Initialize the scope ***/ SDataLoaderConfig dlconfig(kDbName, kIsProtein); dlconfig.OptimizeForWholeLargeSequenceRetrieval(); CBlastInputSourceConfig iconfig(dlconfig); iconfig.SetQueryLocalIdMode(); CRef<CScope> scope = CBlastScopeSource(dlconfig).NewScope(); /*** Initialize the input stream ***/ CBlastFastaInputSource fasta(args[kArgQuery].AsInputFile(), iconfig); CBlastInput input(&fasta, 1); /*** Get the formatting options ***/ const CVecscreenRun::CFormatter::TOutputFormat kFmt = args[kArgOutputFormat].AsInteger(); const bool kHtmlOutput = !args["text_output"].AsBoolean(); /*** Process the input ***/ while ( !input.End() ) { CRef<CBlastQueryVector> query_batch(input.GetNextSeqBatch(*scope)); _ASSERT(query_batch->Size() == 1); CRef<IQueryFactory> queries(new CObjMgr_QueryFactory(*query_batch)); CVecscreenRun vs(CRef<CSeq_loc>(const_cast<CSeq_loc*>(&*query_batch->GetQuerySeqLoc(0))), query_batch->GetScope(0), kDbName); CVecscreenRun::CFormatter vs_format(vs, *scope, kFmt, kHtmlOutput); vs_format.FormatResults(args[kArgOutput].AsOutputFile(), opts_hndl); } } CATCH_ALL(status) return status; }
int CBlastDemoApplication::Run(void) { // Get arguments const CArgs& args = GetArgs(); EProgram program = ProgramNameToEnum(args["program"].AsString()); bool db_is_aa = (program == eBlastp || program == eBlastx || program == eRPSBlast || program == eRPSTblastn); CRef<CBlastOptionsHandle> opts(CBlastOptionsFactory::Create(program, CBlastOptions::eRemote)); ProcessCommandLineArgs(opts); opts->Validate(); // Can throw CBlastException::eInvalidOptions for invalid option. // This will dump the options to stderr. // opts->GetOptions().DebugDumpText(cerr, "opts", 1); CRef<CObjectManager> objmgr = CObjectManager::GetInstance(); if (!objmgr) { throw std::runtime_error("Could not initialize object manager"); } const bool is_protein = !!Blast_QueryIsProtein(opts->GetOptions().GetProgramType()); SDataLoaderConfig dlconfig(is_protein); CBlastInputSourceConfig iconfig(dlconfig, objects::eNa_strand_other, false, args["parse"].AsBoolean()); CBlastFastaInputSource fasta_input(args["in"].AsInputFile(), iconfig); CScope scope(*objmgr); CBlastInput blast_input(&fasta_input); TSeqLocVector query_loc = blast_input.GetAllSeqLocs(scope); CRef<IQueryFactory> query_factory(new CObjMgr_QueryFactory(query_loc)); const CSearchDatabase target_db(args["db"].AsString(), db_is_aa ? CSearchDatabase::eBlastDbIsProtein : CSearchDatabase::eBlastDbIsNucleotide); CRemoteBlast blaster(query_factory, opts, target_db); // This will dump a lot of stuff to stderr. // blaster.SetVerbose(); bool status = blaster.SubmitSync(); if (status == false) throw std::runtime_error("No results returned by SubmitSync"); cerr << "RID: " << blaster.GetRID() << '\n'; CSearchResultSet results = *blaster.GetResultSet(); CNcbiOstream& out = args["out"].AsOutputFile(); for (unsigned int i = 0; i < results.GetNumResults(); i++) { CConstRef<CSeq_align_set> sas = results[i].GetSeqAlign(); out << MSerial_AsnText << *sas; } return 0; }