Beispiel #1
0
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);
}
Beispiel #2
0
int heapblaster(int count, int locking) {
    info_t info[THREADS] = {};
    if (count < 1)
        count = 1;
    if (count >= THREADS)
        count = THREADS;
    printf("heapblaster: starting %d threads... (%s)\n",
           count, locking ? "locking" : "not locking");
    for (int n = 0; n < count; n++) {
        info[n].lock = locking;
        info[n].n = n;
        if (count == 1) {
            blaster(info + n);
            return 0;
        } else {
            pthread_create(&info[n].t, NULL, blaster, info + n);
        }
    }
    for (;;)
        sleep(1000);
    return 0;
}
void SeqSwapper::findBestPairings(const vector<int>& normal, const vector<int>& pending, vector< pair<int, int> >& pairs)
{
	if ((normal.size() == 0) || (pending.size() == 0))
	{
		return;
	}
	//blast normal against pending
	CdBlaster blaster(m_ac);
	blaster.setQueryRows(&normal);
	blaster.setSubjectRows(&pending);
	blaster.setScoreType(CSeq_align::eScore_PercentIdentity);
	blaster.blast();
	//for each normal, find the hightest-scoring (in identity), unused and above the threshold pending
	set<int> usedPendingIndice;
	for (int n = 0; n < normal.size(); n++)
	{
		int maxId = 0;
		int maxIdIndex = -1;
		for (int p = 0; p < pending.size(); p++)
		{
			if (usedPendingIndice.find(p) == usedPendingIndice.end())//this pending has not been used
			{
				int pid = (int)blaster.getPairwiseScore(n, p);
				if ((pid > maxId) && (pid >= m_replacingThreshold))
				{
					maxId = pid;
					maxIdIndex = p;
				}
			}
		}
		if ( maxIdIndex >= 0)
		{
			usedPendingIndice.insert(maxIdIndex);
			pairs.push_back(pair<int, int>(normal[n], pending[maxIdIndex]));
		}
	}
}
Beispiel #4
0
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;
}