void
SplitQuery_SetEffectiveSearchSpace(CRef<CBlastOptions> options,
                                   CRef<IQueryFactory> full_query_fact,
                                   CRef<SInternalData> full_data)
{
    _ASSERT(full_data);
    _ASSERT(full_data->m_SeqSrc);

    // If the effective search options have been set, we don't need to
    // recompute those...
    if (options->GetEffectiveSearchSpace() != 0) {
        return;
    }

    const BlastSeqSrc* seqsrc = full_data->m_SeqSrc->GetPointer();
    Int8 total_length = BlastSeqSrcGetTotLenStats(seqsrc);
    if (total_length <= 0)
        total_length = BlastSeqSrcGetTotLen(seqsrc);
    Int4 num_seqs = BlastSeqSrcGetNumSeqsStats(seqsrc);
    if (num_seqs <= 0)
        num_seqs = BlastSeqSrcGetNumSeqs(seqsrc);

    CEffectiveSearchSpaceCalculator calc(full_query_fact, *options, 
                                         num_seqs, total_length, 
                                         full_data->m_ScoreBlk->GetPointer());
    BlastQueryInfo* qinfo = full_data->m_QueryInfo;
    _ASSERT(qinfo);

    vector<Int8> eff_searchsp;
    for (size_t index = 0; index <= (size_t)qinfo->last_context; index++) {
        eff_searchsp.push_back(calc.GetEffSearchSpaceForContext(index));
    }
    options->SetEffectiveSearchSpace(eff_searchsp);
}
Esempio n. 2
0
Int2
Blast_DatabaseSearch(SeqLoc* query_seqloc,
                     Blast_PsiCheckpointLoc * psi_checkpoint,
                     char* db_name,
                     SeqLoc* masking_locs,
                     const SBlastOptions* options,
                     BlastTabularFormatData* tf_data,
                     SBlastSeqalignArray* *seqalign_arr,
                     SeqLoc** filter_out,
                     Blast_SummaryReturn* extra_returns)
{
    BlastSeqSrc *seq_src = NULL;
    Boolean db_is_prot;
    Int2 status = 0;
    BlastHSPResults* results = NULL;
    ReadDBFILE* rdfp = NULL;

    if (!options || !query_seqloc || !db_name || !extra_returns)
        return -1;

    db_is_prot = 
        (options->program == eBlastTypeBlastp   ||
         options->program == eBlastTypeBlastx   ||
         options->program == eBlastTypeRpsBlast ||
         options->program == eBlastTypeRpsTblastn);

    rdfp = readdb_new(db_name, db_is_prot);

    seq_src = ReaddbBlastSeqSrcAttach(rdfp);

    if (seq_src == NULL) {
        SBlastMessageWrite(&extra_returns->error, SEV_WARNING,
                           "Initialization of subject sequences source failed",
                           NULL, options->believe_query);
    } else if (BlastSeqSrcGetNumSeqs(seq_src) == 0) {
        SBlastMessageWrite(&extra_returns->error, SEV_WARNING,
                           "Database is empty", NULL, options->believe_query);
    } else {
        char* error_str = BlastSeqSrcGetInitError(seq_src);
        if (error_str)
            SBlastMessageWrite(&extra_returns->error, SEV_WARNING, error_str, NULL, options->believe_query); 
    }

    /* If there was an error initializing the sequence source, return without 
       doing the search. */
    if (extra_returns->error)
        return -1;

    status =
        Blast_RunSearch(query_seqloc, psi_checkpoint, seq_src,
                        masking_locs, options, tf_data, &results,
                        filter_out, extra_returns);

    /* The ReadDBFILE structure will not be destroyed here, because the 
       initialising function used readdb_attach */
    BlastSeqSrcFree(seq_src);

    if (!status && !tf_data) {
        status = 
            BLAST_ResultsToSeqAlign(options->program, &results, 
                                    query_seqloc, rdfp, NULL, 
                                    options->score_options->gapped_calculation,
                                    options->score_options->is_ooframe, 
                                    seqalign_arr);
    }

    readdb_destruct(rdfp);

    if (status)
        return status;

    return status;
}