⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blast_options.c

📁 ncbi源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	if (options == NULL)		return NULL;	sfree(options->matrix);   sfree(options->matrix_path);	sfree(options);	return NULL;}Int2 BlastScoringOptionsNew(Uint1 program_number, BlastScoringOptions* *options){   *options = (BlastScoringOptions*) calloc(1, sizeof(BlastScoringOptions));   if (*options == NULL)      return 1;      if (program_number != blast_type_blastn) {	/* protein-protein options. */      (*options)->shift_pen = INT2_MAX;      (*options)->is_ooframe = FALSE;      (*options)->gap_open = BLAST_GAP_OPEN_PROT;      (*options)->gap_extend = BLAST_GAP_EXTN_PROT;   } else {	/* nucleotide-nucleotide options. */      (*options)->penalty = BLAST_PENALTY;      (*options)->reward = BLAST_REWARD;   }   (*options)->decline_align = INT2_MAX;   (*options)->gapped_calculation = TRUE;      return 0;}Int2 BLAST_FillScoringOptions(BlastScoringOptions* options,    Uint1 program_number, Boolean greedy_extension, Int4 penalty, Int4 reward,    const char *matrix, Int4 gap_open, Int4 gap_extend){   if (!options)      return 1;   if (program_number != blast_type_blastn) {	/* protein-protein options. */      if (matrix) {         unsigned int i;         options->matrix = strdup(matrix);         /* Make it all upper case */         for (i=0; i<strlen(options->matrix); ++i)            options->matrix[i] = toupper(options->matrix[i]);      } else {         options->matrix = strdup("BLOSUM62");      }   } else {	/* nucleotide-nucleotide options. */      if (penalty)         options->penalty = penalty;      if (reward)         options->reward = reward;      if (greedy_extension) {         options->gap_open = BLAST_GAP_OPEN_MEGABLAST;         options->gap_extend = BLAST_GAP_EXTN_MEGABLAST;      }	else {         options->gap_open = BLAST_GAP_OPEN_NUCL;         options->gap_extend = BLAST_GAP_EXTN_NUCL;      }   }   if (gap_open)      options->gap_open = gap_open;   if (gap_extend)      options->gap_extend = gap_extend;   return 0;}Int2 BlastScoringOptionsValidate(Uint1 program_number,    const BlastScoringOptions* options, Blast_Message* *blast_msg){	if (options == NULL)		return 1;   if (program_number == blast_type_tblastx &&               options->gapped_calculation)   {		Int4 code=2;		Int4 subcode=1;      Blast_MessageWrite(blast_msg, BLAST_SEV_ERROR, code, subcode,          "Gapped search is not allowed for tblastx");		return (Int2) code;   }	if (program_number == blast_type_blastn)	{		if (options->penalty >= 0)		{			Int4 code=2;			Int4 subcode=1;			Blast_MessageWrite(blast_msg, BLAST_SEV_WARNING, code, subcode,                             "BLASTN penalty must be negative");			return (Int2) code;		}                if (options->gap_open > 0 && options->gap_extend == 0)                 {                        Int4 code=2;                        Int4 subcode=1;                        Blast_MessageWrite(blast_msg, BLAST_SEV_WARNING,                            code, subcode,                            "BLASTN gap extension penalty cannot be 0");                        return (Int2) code;                }	}	else	{		Int2 status=0;		if ((status=Blast_KarlinkGapBlkFill(NULL, options->gap_open,                      options->gap_extend, options->decline_align,                      options->matrix)) != 0)		{			if (status == 1)			{				char* buffer;				Int4 code=2;				Int4 subcode=1;				buffer = BLAST_PrintMatrixMessage(options->matrix);             Blast_MessageWrite(blast_msg, BLAST_SEV_ERROR,                               code, subcode, buffer);				sfree(buffer);				return (Int2) code;							}			else if (status == 2)			{				char* buffer;				Int4 code=2;				Int4 subcode=1;				buffer = BLAST_PrintAllowedValues(options->matrix,                         options->gap_open, options->gap_extend,                         options->decline_align);             Blast_MessageWrite(blast_msg, BLAST_SEV_ERROR, code, subcode,                                buffer);				sfree(buffer);				return (Int2) code;			}		}			}	if (program_number != blast_type_blastx &&        program_number != blast_type_tblastn && options->is_ooframe)	{      Int4 code=2;      Int4 subcode=1;      Blast_MessageWrite(blast_msg, BLAST_SEV_WARNING, code, subcode,          "Out-of-frame only permitted for blastx and tblastn");      return (Int2) code;	}	return 0;}Int2 BlastScoringOptionsDup(BlastScoringOptions* *new_opt, const BlastScoringOptions* old_opt){    if (old_opt == NULL || new_opt == NULL)       return -1;    *new_opt = (BlastScoringOptions*) BlastMemDup(old_opt, sizeof(BlastScoringOptions));    if (*new_opt == NULL)       return -1;    if (old_opt->matrix)       (*new_opt)->matrix = strdup(old_opt->matrix);    if (old_opt->matrix_path)       (*new_opt)->matrix_path = strdup(old_opt->matrix_path);    return 0;}BlastScoringParameters*BlastScoringParametersFree(BlastScoringParameters* parameters){	sfree(parameters);	return NULL;}Int2BlastScoringParametersNew(const BlastScoringOptions* score_options,                           BlastScoreBlk* sbp,                           BlastScoringParameters* *parameters){   BlastScoringParameters *params;   double scale_factor;   if (score_options == NULL)      return 1;   *parameters = params = (BlastScoringParameters*)                         calloc(1, sizeof(BlastScoringParameters));   if (params == NULL)      return 2;   params->options = (BlastScoringOptions *)score_options;   scale_factor = sbp->scale_factor;   params->scale_factor = scale_factor;   params->reward = score_options->reward;   params->penalty = score_options->penalty;   params->gap_open = score_options->gap_open * (Int4)scale_factor;   params->gap_extend = score_options->gap_extend * (Int4)scale_factor;   params->decline_align = score_options->decline_align * (Int4)scale_factor;   params->shift_pen = score_options->shift_pen * (Int4)scale_factor;   return 0;}BlastEffectiveLengthsOptions*BlastEffectiveLengthsOptionsFree(BlastEffectiveLengthsOptions* options){	sfree(options);	return NULL;}Int2 BlastEffectiveLengthsOptionsNew(BlastEffectiveLengthsOptions* *options){   *options = (BlastEffectiveLengthsOptions*)      calloc(1, sizeof(BlastEffectiveLengthsOptions));   if (*options == NULL)      return 1;      return 0;}BlastEffectiveLengthsParameters*BlastEffectiveLengthsParametersFree(BlastEffectiveLengthsParameters* parameters){	sfree(parameters);	return NULL;}Int2 BlastEffectiveLengthsParametersNew(const BlastEffectiveLengthsOptions* options,                                Int8 db_length, Int4 num_seqs,                               BlastEffectiveLengthsParameters* *parameters){   *parameters = (BlastEffectiveLengthsParameters*)       calloc(1, sizeof(BlastEffectiveLengthsParameters));   (*parameters)->options = (BlastEffectiveLengthsOptions*) options;   (*parameters)->real_db_length = db_length;   (*parameters)->real_num_seqs = num_seqs;   return 0;}Int2 BLAST_FillEffectiveLengthsOptions(BlastEffectiveLengthsOptions* options,    Int4 dbseq_num, Int8 db_length, Int8 searchsp_eff){   if (!options)      return 1;   if (searchsp_eff) {	      /* dbnum_seq and dblen are used to calculate effective search space, so          if it is already set don't bother with those. */      options->searchsp_eff = searchsp_eff;      return 0;   }   options->dbseq_num = dbseq_num;   options->db_length = db_length;   return 0;}LookupTableOptions*LookupTableOptionsFree(LookupTableOptions* options){      sfree(options->phi_pattern);   	sfree(options);	return NULL;}Int2 LookupTableOptionsNew(Uint1 program_number, LookupTableOptions* *options){   *options = (LookupTableOptions*) calloc(1, sizeof(LookupTableOptions));      if (*options == NULL)      return 1;      if (program_number != blast_type_blastn) {      (*options)->word_size = BLAST_WORDSIZE_PROT;      (*options)->alphabet_size = BLASTAA_SIZE;      (*options)->lut_type = AA_LOOKUP_TABLE;            if (program_number == blast_type_blastp ||          program_number == blast_type_rpsblast)         (*options)->threshold = BLAST_WORD_THRESHOLD_BLASTP;      else if (program_number == blast_type_blastx)         (*options)->threshold = BLAST_WORD_THRESHOLD_BLASTX;      else if (program_number == blast_type_tblastn ||               program_number == blast_type_rpstblastn)         (*options)->threshold = BLAST_WORD_THRESHOLD_TBLASTN;      else if (program_number == blast_type_tblastx)         (*options)->threshold = BLAST_WORD_THRESHOLD_TBLASTX;         } else {      (*options)->alphabet_size = BLASTNA_SIZE;   }   return 0;}Int4 CalculateBestStride(Int4 word_size, Boolean var_words, Int4 lut_type){   Int4 lut_width;   Int4 extra = 1;   Uint1 remainder;   Int4 stride;   if (lut_type == MB_LOOKUP_TABLE)      lut_width = 12;   else if (word_size >= 8)      lut_width = 8;   else      lut_width = 4;   remainder = word_size % COMPRESSION_RATIO;   if (var_words && (remainder == 0) )      extra = COMPRESSION_RATIO;   stride = word_size - lut_width + extra;   remainder = stride % 4;   if (stride > 8 || (stride > 4 && remainder == 1) )       stride -= remainder;   return stride;}Int2 BLAST_FillLookupTableOptions(LookupTableOptions* options,    Uint1 program_number, Boolean is_megablast, Int4 threshold,   Int2 word_size, Boolean ag_blast, Boolean variable_wordsize,   Boolean use_pssm){   if (!options)      return 1;   if (program_number == blast_type_blastn) {      if (is_megablast)	{         options->word_size = BLAST_WORDSIZE_MEGABLAST;         options->lut_type = MB_LOOKUP_TABLE;         options->max_positions = INT4_MAX;      }	else {         options->lut_type = NA_LOOKUP_TABLE;         options->word_size = BLAST_WORDSIZE_NUCL;      }   } else {      options->lut_type = AA_LOOKUP_TABLE;   }   /* if the supplied threshold is -1, disable neighboring words */   if (threshold == -1)      options->threshold = 0;   /* if the supplied threshold is > 0, use it */   if (threshold > 0)      options->threshold = threshold;   /* otherwise, use the default */   if (use_pssm)      options->use_pssm = use_pssm;   if (program_number == blast_type_rpsblast ||       program_number == blast_type_rpstblastn)      options->lut_type = RPS_LOOKUP_TABLE;   if (word_size)      options->word_size = word_size;   if (program_number == blast_type_blastn) {      if (!ag_blast) {         options->scan_step = COMPRESSION_RATIO;      } else {         options->scan_step = CalculateBestStride(options->word_size, variable_wordsize,                                                  options->lut_type);      }   }   return 0;}/** Validate options for the discontiguous word megablast * Word size must be 11 or 12; template length 16, 18 or 21;  * template type 0, 1 or 2. * @param word_size Word size option [in] * @param template_length Discontiguous template length [in] * @param template_type Discontiguous template type [in] * @return TRUE if options combination valid. */static Boolean DiscWordOptionsValidate(Int2 word_size, Uint1 template_length,                        Uint1 template_type){   if (template_length == 0)      return TRUE;   if (word_size != 11 && word_size != 12)      return FALSE;   if (template_length != 16 && template_length != 18 &&        template_length != 21)      return FALSE;   if (template_type > 2)      return FALSE;   return TRUE;}Int2 LookupTableOptionsValidate(Uint1 program_number,    const LookupTableOptions* options, Blast_Message* *blast_msg){   Int4 code=2;   Int4 subcode=1;	if (options == NULL)		return 1;        if (program_number == blast_type_rpsblast ||            program_number == blast_type_rpstblastn)                return 0;	if (program_number != blast_type_blastn && options->threshold <= 0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -