Example #1
0
Int2
BlastExtensionOptionsNew(EBlastProgramType program, BlastExtensionOptions* *options, Boolean gapped)

{
	*options = (BlastExtensionOptions*) 
           calloc(1, sizeof(BlastExtensionOptions));

	if (*options == NULL)
		return BLASTERR_MEMORY;

	if (program != eBlastTypeBlastn &&
        program != eBlastTypePhiBlastn) /* protein-protein options. */
	{
		(*options)->gap_x_dropoff = BLAST_GAP_X_DROPOFF_PROT;
		(*options)->gap_x_dropoff_final = 
                   BLAST_GAP_X_DROPOFF_FINAL_PROT;
    } else {
        (*options)->gap_x_dropoff = BLAST_GAP_X_DROPOFF_NUCL;
        (*options)->gap_x_dropoff_final = BLAST_GAP_X_DROPOFF_FINAL_NUCL;
    }

    (*options)->ePrelimGapExt = eDynProgScoreOnly;
    (*options)->eTbackExt = eDynProgTbck;
    (*options)->compositionBasedStats = eNoCompositionBasedStats;

    /** @todo how to determine this for PSI-BLAST bootstrap run (i.e. when
     * program is blastp? */
    if (gapped && (Blast_QueryIsPssm(program) && ! Blast_SubjectIsTranslated(program))) {
        (*options)->compositionBasedStats = eCompositionBasedStats;
    }

    (*options)->program_number = program;

	return 0;
}
Example #2
0
BlastHSPStream* 
BlastHSPStreamNew(EBlastProgramType program, 
                  const BlastExtensionOptions* extn_opts,
                  Boolean sort_on_read,
                  Int4 num_queries,
                  BlastHSPWriter *writer)
{
    BlastHSPStream* hsp_stream = 
       (BlastHSPStream*) malloc(sizeof(BlastHSPStream));

    hsp_stream->program = program;

    hsp_stream->num_hsplists = 0;
    hsp_stream->num_hsplists_alloc = 100;
    hsp_stream->sorted_hsplists = (BlastHSPList **)malloc(
                                           hsp_stream->num_hsplists_alloc *
                                           sizeof(BlastHSPList *));
    hsp_stream->results = Blast_HSPResultsNew(num_queries);

    hsp_stream->results_sorted = FALSE;

    /* This is needed to meet a pre-condition of the composition-based
     * statistics code */
    if ((Blast_QueryIsProtein(program) || Blast_QueryIsPssm(program)) &&
        extn_opts->compositionBasedStats != 0) {
        hsp_stream->sort_by_score = 
            (SSortByScoreStruct*)calloc(1, sizeof(SSortByScoreStruct));
        hsp_stream->sort_by_score->sort_on_read = sort_on_read;
        hsp_stream->sort_by_score->first_query_index = 0;
    } else {
        hsp_stream->sort_by_score = NULL;
    }
    hsp_stream->x_lock = NULL;
    hsp_stream->writer = writer;
    hsp_stream->writer_initialized = FALSE;
    hsp_stream->writer_finalized = FALSE;
    hsp_stream->pre_pipe = NULL;
    hsp_stream->tback_pipe = NULL;

    return hsp_stream;
}
Example #3
0
/**  Checks that the extension and scoring options are consistent with each other
 * @param program_number identifies the program [in]
 * @param ext_options the extension options [in]
 * @param score_options the scoring options [in]
 * @param blast_msg returns a message on errors. [in|out]
 * @return zero on success, an error code otherwise. 
 */
static Int2 s_BlastExtensionScoringOptionsValidate(EBlastProgramType program_number,
                           const BlastExtensionOptions* ext_options,
                           const BlastScoringOptions* score_options, 
                           Blast_Message* *blast_msg)
{
    if (ext_options == NULL || score_options == NULL)
        return BLASTERR_INVALIDPARAM;

    if (program_number == eBlastTypeBlastn)
    {
        if (score_options->gap_open == 0 && score_options->gap_extend == 0)
        {
	    if (ext_options->ePrelimGapExt != eGreedyScoreOnly && 
                ext_options->eTbackExt != eGreedyTbck)
	    {
			Blast_MessageWrite(blast_msg, eBlastSevWarning, kBlastMessageNoContext,
                            "Greedy extension must be used if gap existence and extension options are zero");
			return BLASTERR_OPTION_VALUE_INVALID;
	    }
	}
    }

    if (ext_options->compositionBasedStats != eNoCompositionBasedStats)
    {
            if (!Blast_QueryIsPssm(program_number) && program_number != eBlastTypeTblastn && 
                 program_number != eBlastTypeBlastp) {
			Blast_MessageWrite(blast_msg, eBlastSevWarning, kBlastMessageNoContext,
                            "Compositional adjustments are only supported with blastp or tblastn");
			return BLASTERR_OPTION_VALUE_INVALID;
            }
            if (!score_options->gapped_calculation) {
			Blast_MessageWrite(blast_msg, eBlastSevWarning, kBlastMessageNoContext,
                            "Compositional adjustments are only supported for gapped searches");
			return BLASTERR_OPTION_VALUE_INVALID;
            }
            
    }

    return 0;
}
Example #4
0
Int2
BLAST_FillExtensionOptions(BlastExtensionOptions* options, 
   EBlastProgramType program, Int4 greedy, double x_dropoff, 
   double x_dropoff_final)
{
   if (!options)
      return BLASTERR_INVALIDPARAM;

   if (program == eBlastTypeBlastn || program == eBlastTypePhiBlastn) {
      if (greedy) {
         options->gap_x_dropoff = BLAST_GAP_X_DROPOFF_GREEDY;
         options->gap_x_dropoff_final = BLAST_GAP_X_DROPOFF_FINAL_NUCL;
         options->ePrelimGapExt = eGreedyScoreOnly;
         options->eTbackExt = eGreedyTbck;
      } else {
         options->gap_x_dropoff = BLAST_GAP_X_DROPOFF_NUCL;
         options->gap_x_dropoff_final = BLAST_GAP_X_DROPOFF_FINAL_NUCL;
         options->ePrelimGapExt = eDynProgScoreOnly;
         options->eTbackExt = eDynProgTbck;
      }
   }

   if (Blast_QueryIsPssm(program) && ! Blast_SubjectIsTranslated(program)) {
       options->compositionBasedStats = eCompositionBasedStats;
   }

   if (x_dropoff)
      options->gap_x_dropoff = x_dropoff;
   if (x_dropoff_final) {
      options->gap_x_dropoff_final = x_dropoff_final;
   } else {
      /* Final X-dropoff can't be smaller than preliminary X-dropoff */
      options->gap_x_dropoff_final = 
         MAX(options->gap_x_dropoff_final, x_dropoff);
   }

   return 0;

}