void CVecscreenRun::x_RunBlast() { //_ASSERT(m_Queries.NotEmpty()); //_ASSERT(m_Queries->Size() != 0); // Load blast queries CRef<IQueryFactory> query_factory(new CObjMgr_QueryFactory(*m_Queries)); // BLAST optiosn needed for vecscreen. CRef<CBlastOptionsHandle> opts(CBlastOptionsFactory::CreateTask("vecscreen")); // Sets Vecscreen database. const CSearchDatabase target_db(m_DB, CSearchDatabase::eBlastDbIsNucleotide); // Constructor for blast run. CLocalBlast blaster(query_factory, opts, target_db); // BLAST run. m_RawBlastResults = blaster.Run(); _ASSERT(m_RawBlastResults->size() == 1); CRef<CBlastAncillaryData> ancillary_data((*m_RawBlastResults)[0].GetAncillaryData()); // The vecscreen stuff follows. m_Vecscreen = new CVecscreen(*((*m_RawBlastResults)[0].GetSeqAlign()), GetLength(*m_SeqLoc, m_Scope)); // This actually does the vecscreen work. m_Seqalign_set = m_Vecscreen->ProcessSeqAlign(); CConstRef<CSeq_id> id(m_SeqLoc->GetId()); CRef<CSearchResults> results(new CSearchResults(id, m_Seqalign_set, TQueryMessages(), ancillary_data)); m_RawBlastResults->clear(); m_RawBlastResults->push_back(results); }
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; }