NCBI C++ ToolKit
blastoptions_unit_test.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: blastoptions_unit_test.cpp 71936 2016-04-07 13:13:00Z camacho $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Christiam Camacho
27  *
28  */
29 
30 /** @file blastoptions_unit_test.cpp
31  * Unit tests for the BLAST options
32  */
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/test_boost.hpp>
37 #include "blast_setup.hpp"
38 #include "blast_objmgr_priv.hpp"
40 #include "test_objmgr.hpp"
42 
43 #ifndef SKIP_DOXYGEN_PROCESSING
44 
48 
49 BOOST_AUTO_TEST_SUITE(blastoptions)
50 
51 BOOST_AUTO_TEST_CASE(TestTasksDefinitionsAndDocumentation)
52 {
54  ITERATE(set<string>, itr, tasks) {
55  string doc = CBlastOptionsFactory::GetDocumentation(*itr);
56  BOOST_CHECK(doc != "Unknown task");
57 
59  BOOST_CHECK_NO_THROW(opt.Reset(CBlastOptionsFactory::CreateTask(*itr)));
60  }
61 }
62 
63 BOOST_AUTO_TEST_CASE( RemoteOptionsTest )
64 {
66  BOOST_CHECK_NO_THROW(opts.SetMaskAtHash());
67  BOOST_CHECK_NO_THROW(opts.SetDustFiltering());
68  BOOST_CHECK_NO_THROW(opts.SetSegFiltering());
69  BOOST_CHECK_NO_THROW(opts.SetRepeatFiltering());
70  BOOST_CHECK_NO_THROW(opts.SetRepeatFilteringDB("repeat/repeat_9606"));
71  BOOST_CHECK_NO_THROW(opts.SetFilterString("m L", false)); /* NCBI_FAKE_WARNING */
72 }
73 
74 BOOST_AUTO_TEST_CASE( BogusProgramWithCreate )
75 {
77  BOOST_CHECK_THROW(CBlastOptionsFactory::Create(eBlastNotSet),
79 }
80 
81 BOOST_AUTO_TEST_CASE( UnifiedPOptionsTest )
82 {
83  CBlastOptions opts;
84 
85  BOOST_CHECK_EQUAL(opts.GetUnifiedP(), 0);
86  opts.SetUnifiedP(1);
87  BOOST_CHECK_EQUAL(opts.GetUnifiedP(), 1);
88  opts.SetUnifiedP();
89  BOOST_CHECK_EQUAL(opts.GetUnifiedP(), 0);
90 }
91 
92 BOOST_AUTO_TEST_CASE( GetSuggestedThresholdTest )
93 {
94  Int2 status=0;
95  double threshold;
96 
97  const int kThresholdSentinel = -33;
98 
99  threshold = kThresholdSentinel;
100  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastn, "BLOSUM62", &threshold);
101  BOOST_CHECK_EQUAL(0, (int) status);
102  BOOST_CHECK_EQUAL(kThresholdSentinel, (int) threshold);
103 
104  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastp, NULL, &threshold);
105  BOOST_CHECK_EQUAL(BLASTERR_INVALIDPARAM, (int) status);
106 
107  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastp, "BLOSUM62", &threshold);
108  BOOST_CHECK_EQUAL(0, (int) status);
109  BOOST_CHECK_EQUAL(11, (int) threshold);
110 
111  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastx, "BLOSUM62", &threshold);
112  BOOST_CHECK_EQUAL(0, (int) status);
113  BOOST_CHECK_EQUAL(12, (int) threshold);
114 
115  status = BLAST_GetSuggestedThreshold(eBlastTypeTblastn, "BLOSUM62", &threshold);
116  BOOST_CHECK_EQUAL(0, (int) status);
117  BOOST_CHECK_EQUAL(13, (int) threshold);
118 
119  status = BLAST_GetSuggestedThreshold(eBlastTypeTblastx, "BLOSUM62", &threshold);
120  BOOST_CHECK_EQUAL(0, (int) status);
121  BOOST_CHECK_EQUAL(13, (int) threshold);
122 
123  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastp, "PAM30", &threshold);
124  BOOST_CHECK_EQUAL(0, (int) status);
125  BOOST_CHECK_EQUAL(16, (int) threshold);
126 
127  status = BLAST_GetSuggestedThreshold(eBlastTypeBlastp, "PAM140", &threshold);
128  BOOST_CHECK_EQUAL(0, (int) status);
129  BOOST_CHECK_EQUAL(11, (int) threshold);
130 }
131 
132 BOOST_AUTO_TEST_CASE( GetSuggestedWindowSizeTest )
133 {
134  Int2 status=0;
135  Int4 window_size;
136 
137  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastn, "BLOSUM62", &window_size);
138  BOOST_CHECK_EQUAL(0, (int) status);
139 
140  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastp, NULL, &window_size);
141  BOOST_CHECK_EQUAL(BLASTERR_INVALIDPARAM, (int) status);
142 
143  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastp, "BLOSUM62", &window_size);
144  BOOST_CHECK_EQUAL(0, (int) status);
145  BOOST_CHECK_EQUAL(40, window_size);
146 
147  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastx, "BLOSUM62", &window_size);
148  BOOST_CHECK_EQUAL(0, (int) status);
149  BOOST_CHECK_EQUAL(40, window_size);
150 
151  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastp, "BLOSUM80", &window_size);
152  BOOST_CHECK_EQUAL(0, (int) status);
153  BOOST_CHECK_EQUAL(25, window_size);
154 
155  status = BLAST_GetSuggestedWindowSize(eBlastTypeBlastp, "PAM140", &window_size);
156  BOOST_CHECK_EQUAL(0, (int) status);
157  BOOST_CHECK_EQUAL(40, window_size);
158 }
159 
160 BOOST_AUTO_TEST_CASE( GetProteinGapExistenceExtendParamsTest )
161 {
162  Int2 status=0;
163  Int4 existence=0, extension=0;
164 
165  status = BLAST_GetProteinGapExistenceExtendParams(NULL, &existence, &extension);
166  BOOST_CHECK_EQUAL(-1, (int) status);
167 
168  status = BLAST_GetProteinGapExistenceExtendParams("BLOSUM62", &existence, &extension);
169  BOOST_CHECK_EQUAL(0, (int) status);
170  BOOST_CHECK_EQUAL(11, existence);
171  BOOST_CHECK_EQUAL(1, extension);
172 
173  status = BLAST_GetProteinGapExistenceExtendParams("BLOSUM80", &existence, &extension);
174  BOOST_CHECK_EQUAL(0, (int) status);
175  BOOST_CHECK_EQUAL(10, existence);
176  BOOST_CHECK_EQUAL(1, extension);
177 
178  status = BLAST_GetProteinGapExistenceExtendParams("PAM250", &existence, &extension);
179  BOOST_CHECK_EQUAL(0, (int) status);
180  BOOST_CHECK_EQUAL(14, existence);
181  BOOST_CHECK_EQUAL(2, extension);
182 }
183 
184 BOOST_AUTO_TEST_CASE( GetNucleotideGapExistenceExtendParamsTest )
185 {
186  Int2 status=0;
187  int existence=-1, extension=-1;
188  int reward=0, penalty=0;
189 
190  reward = 0;
191  penalty = 3;
192  status = BLAST_GetNucleotideGapExistenceExtendParams(reward, penalty, &existence, &extension);
193  BOOST_CHECK_EQUAL(-1, (int) status);
194 
195  /* megablast linear values. */
196  reward = 1;
197  penalty = -3;
198  existence = 0;
199  extension = 0;
200  status = BLAST_GetNucleotideGapExistenceExtendParams(reward, penalty, &existence, &extension);
201  BOOST_CHECK_EQUAL(0, (int) status);
202  BOOST_CHECK_EQUAL(0, existence);
203  BOOST_CHECK_EQUAL(0, extension);
204 
205  reward = 1;
206  penalty = -3;
207  existence = -1;
208  extension = -1;
209  status = BLAST_GetNucleotideGapExistenceExtendParams(reward, penalty, &existence, &extension);
210  BOOST_CHECK_EQUAL(0, (int) status);
211  BOOST_CHECK_EQUAL(2, existence);
212  BOOST_CHECK_EQUAL(2, extension);
213 
214  reward = 2;
215  penalty = -5;
216  existence = -1;
217  extension = -1;
218  status = BLAST_GetNucleotideGapExistenceExtendParams(reward, penalty, &existence, &extension);
219  BOOST_CHECK_EQUAL(0, (int) status);
220  BOOST_CHECK_EQUAL(4, existence);
221  BOOST_CHECK_EQUAL(4, extension);
222 
223  reward = 1;
224  penalty = -2;
225  existence = -1;
226  extension = -1;
227  status = BLAST_GetNucleotideGapExistenceExtendParams(reward, penalty, &existence, &extension);
228  BOOST_CHECK_EQUAL(0, (int) status);
229  BOOST_CHECK_EQUAL(2, existence);
230  BOOST_CHECK_EQUAL(2, extension);
231 }
232 
233 BOOST_AUTO_TEST_CASE( FilterSetUpOptionsDustTest )
234 {
235  SBlastFilterOptions* filter_options;
236 
237  Int2 status = SBlastFilterOptionsNew(&filter_options, eDust);
238  BOOST_CHECK_EQUAL(0, (int) status);
239  BOOST_CHECK(filter_options);
240  BOOST_CHECK(filter_options->dustOptions);
241  BOOST_CHECK(filter_options->segOptions == NULL);
242  filter_options = SBlastFilterOptionsFree(filter_options);
243  BOOST_REQUIRE(filter_options == NULL);
244 }
245 
246 BOOST_AUTO_TEST_CASE( FilterSetUpOptionsSegTest )
247 {
248  SBlastFilterOptions* filter_options;
249 
250  Int2 status = SBlastFilterOptionsNew(&filter_options, eSeg);
251  BOOST_CHECK_EQUAL(0, (int) status);
252  BOOST_CHECK(filter_options);
253  BOOST_CHECK(filter_options->dustOptions == NULL);
254  BOOST_CHECK(filter_options->segOptions);
255  filter_options = SBlastFilterOptionsFree(filter_options);
256  BOOST_REQUIRE(filter_options == NULL);
257 }
258 
259 BOOST_AUTO_TEST_CASE( FilterSetUpOptionsNULLInput )
260 {
262  BOOST_CHECK_EQUAL(1, (int) status);
263 }
264 
265 BOOST_AUTO_TEST_CASE( OptionsFreeNULLInput )
266 {
277 }
278 
279 // FIXME: good up to here
280 static void
281 s_FillSearchSpace(BlastQueryInfo *query_info, Int8 searchsp)
282 {
283  for (int i = query_info->first_context;
284  i <= query_info->last_context; i++) {
285  if (query_info->contexts[i].query_length)
286  query_info->contexts[i].eff_searchsp = searchsp;
287  }
288 }
289 
290 // A helper function to setup the initial word parameters.
293  BLAST_SequenceBlk* query_blk,
294  BlastQueryInfo* query_info,
295  BlastScoreBlk* sbp,
296  const BlastInitialWordOptions* word_options,
297  int subject_length,
298  const BlastHitSavingParameters* hit_params)
299 {
300  BlastInitialWordParameters* word_params = NULL;
301  LookupTableWrap* lookup_wrap = NULL;
302  LookupTableOptions* lookup_options = NULL;
303  BlastSeqLoc* blast_seq_loc = BlastSeqLocNew(NULL, 0, query_info->contexts[0].query_length-1);
304  QuerySetUpOptions* query_options = NULL;
305  BlastQuerySetUpOptionsNew(&query_options);
306 
307  LookupTableOptionsNew(program_number, &lookup_options);
308  LookupTableWrapInit(query_blk, lookup_options, query_options, blast_seq_loc,
309  sbp, &lookup_wrap, NULL, NULL);
310  BlastInitialWordParametersNew(program_number, word_options, hit_params,
311  lookup_wrap, sbp, query_info, subject_length, &word_params);
312 
313  blast_seq_loc = BlastSeqLocFree(blast_seq_loc);
314  BOOST_REQUIRE(blast_seq_loc == NULL);
315  lookup_wrap = LookupTableWrapFree(lookup_wrap);
316  BOOST_REQUIRE(lookup_wrap == NULL);
317  lookup_options = LookupTableOptionsFree(lookup_options);
318  BOOST_REQUIRE(lookup_options == NULL);
319  query_options = BlastQuerySetUpOptionsFree(query_options);
320  BOOST_REQUIRE(query_options == NULL);
321 
322  return word_params;
323 }
324 
325 BOOST_AUTO_TEST_CASE( testCalcLinkHSPCutoffs )
326 {
327  const EBlastProgramType kBlastProgram = eBlastTypeBlastp;
328  const Int4 kAvgSubjectLength = 335;
329  const Int4 kSpecificSubjectLength = 186;
330  const Int8 kDbLength = 703698559;
331  CSeq_id qid("gi|129295");
332  auto_ptr<SSeqLoc> qsl(
333  CTestObjMgr::Instance().CreateSSeqLoc(qid, eNa_strand_both));
334  CSeq_id sid("gi|129296");
335  auto_ptr<SSeqLoc> ssl(
336  CTestObjMgr::Instance().CreateSSeqLoc(sid, eNa_strand_both));
337 
338  CBl2Seq blaster(*qsl, *ssl, eBlastp);
339 
340  CBlastQueryInfo query_info;
341  CBLAST_SequenceBlk query_blk;
342  TSearchMessages blast_msg;
343 
344  const CBlastOptions& kOpts = blaster.GetOptionsHandle().GetOptions();
345  EBlastProgramType prog = kOpts.GetProgramType();
346  ENa_strand strand_opt = kOpts.GetStrandOption();
347 
348  SetupQueryInfo(const_cast<TSeqLocVector&>(blaster.GetQueries()),
349  prog, strand_opt, &query_info);
350  SetupQueries(const_cast<TSeqLocVector&>(blaster.GetQueries()),
351  query_info, &query_blk, prog, strand_opt, blast_msg);
352  ITERATE(TSearchMessages, m, blast_msg) {
353  BOOST_CHECK(m->empty());
354  }
355 
356  BlastScoringOptions* scoring_options;
357  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
358  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
359  "BLOSUM62", -1, -1);
360  scoring_options->gapped_calculation = FALSE;
361 
362  BlastScoreBlk* sbp;
363  Blast_Message* blast_message = NULL;
364  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
365  kBlastProgram, &sbp, 1.0, &blast_message,
367 
368  s_FillSearchSpace(query_info, 98483910471LL);
369 
370  BlastExtensionOptions* ext_options;
371  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
372  scoring_options->gapped_calculation);
373 
374  BlastHitSavingOptions* hit_options;
375  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
376  scoring_options->gapped_calculation);
377  BOOST_CHECK(hit_options->do_sum_stats);
378 
379  BlastHitSavingParameters* hit_params;
380  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, kAvgSubjectLength, 2, &hit_params);
381  BlastLinkHSPParameters* link_hsp_params = hit_params->link_hsp_params;
382 
383  BlastInitialWordOptions* word_options;
384  BlastInitialWordOptionsNew(kBlastProgram, &word_options);
385 
386  BlastInitialWordParameters* word_params = s_GetInitialWordParameters(kBlastProgram, query_blk,
387  query_info, sbp, word_options, kAvgSubjectLength, hit_params);
388 
389  CalculateLinkHSPCutoffs(kBlastProgram, query_info, sbp,
390  link_hsp_params, word_params,
391  kDbLength, kSpecificSubjectLength);
392 
393  BOOST_CHECK_EQUAL(36, link_hsp_params->cutoff_big_gap);
394  BOOST_CHECK_EQUAL(41, link_hsp_params->cutoff_small_gap);
395 
396  sbp = BlastScoreBlkFree(sbp);
397  BOOST_REQUIRE(sbp == NULL);
398  ext_options = BlastExtensionOptionsFree(ext_options);
399  BOOST_REQUIRE(ext_options == NULL);
400  scoring_options = BlastScoringOptionsFree(scoring_options);
401  BOOST_REQUIRE(scoring_options == NULL);
402  hit_params = BlastHitSavingParametersFree(hit_params);
403  BOOST_REQUIRE(hit_params == NULL);
404  hit_options = BlastHitSavingOptionsFree(hit_options);
405  BOOST_REQUIRE(hit_options == NULL);
406  word_params = BlastInitialWordParametersFree(word_params);
407  BOOST_REQUIRE(word_params == NULL);
408  word_options = BlastInitialWordOptionsFree(word_options);
409  BOOST_REQUIRE(word_options == NULL);
410  return;
411 }
412 
413 static BlastScoreBlk*
415 
416  BOOST_REQUIRE(query_info);
418 
419  sbp->kbp = sbp->kbp_std;
420 
421  Blast_KarlinBlk* kbp_bad = Blast_KarlinBlkNew();
422  kbp_bad->Lambda = -1.0;
423  kbp_bad->K = -1.0;
424  kbp_bad->logK = -1.0;
425  kbp_bad->H = -1.0;
426  sbp->kbp[0] = kbp_bad;
427  query_info->contexts[0].is_valid = FALSE;
428 
429  Blast_KarlinBlk* kbp_good = Blast_KarlinBlkNew();
430  kbp_good->Lambda = 1.1;
431  kbp_good->K = 1.1;
432  kbp_good->logK = 0.1;
433  kbp_good->H = 1.1;
434  sbp->kbp[1] = kbp_good;
435  query_info->contexts[1].is_valid = TRUE;
436 
437  return sbp;
438 }
439 
440 BOOST_AUTO_TEST_CASE( testBadKbpForLinkHSPCutoffs )
441 {
442  const EBlastProgramType kBlastProgram = eBlastTypeTblastx;
443  const Int4 kAvgSubjectLength = 335;
444  const Int4 kSpecificSubjectLength = 186;
445  const Int8 kDbLength = 703698559;
446  const bool kIsGapped = true;
447 
448 
449  CBlastQueryInfo query_info(BlastQueryInfoNew(kBlastProgram, 1));
450  query_info->first_context = 0;
451  query_info->last_context = 1;
452  sfree(query_info->contexts);
453  query_info->contexts = (BlastContextInfo*) calloc(2, sizeof(BlastContextInfo));
454  query_info->contexts[query_info->last_context].query_offset = 300;
455  query_info->contexts[query_info->last_context].query_length = 300;
456 
457  BlastScoreBlk* sbp = s_FillScoreBlkWithBadKbp(query_info);
458 
459  s_FillSearchSpace(query_info, 98483910471LL);
460 
461  BlastExtensionOptions* ext_options;
462  BlastExtensionOptionsNew(kBlastProgram, &ext_options, kIsGapped);
463 
464  BlastHitSavingOptions* hit_options;
465  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
466  kIsGapped);
467  BOOST_CHECK(hit_options->do_sum_stats);
468 
469  BlastHitSavingParameters* hit_params;
470  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, kAvgSubjectLength, 0, &hit_params);
471  BlastLinkHSPParameters* link_hsp_params = hit_params->link_hsp_params;
472 
473  BlastInitialWordParameters word_params;
474  word_params.cutoff_score_min = 30;
475 
476  CalculateLinkHSPCutoffs(kBlastProgram, query_info, sbp,
477  link_hsp_params, &word_params,
478  kDbLength, kSpecificSubjectLength);
479 
480  BOOST_CHECK_EQUAL(11, link_hsp_params->cutoff_big_gap);
481  BOOST_CHECK_EQUAL(0, link_hsp_params->cutoff_small_gap);
482 
483  sbp = BlastScoreBlkFree(sbp);
484  BOOST_REQUIRE(sbp == NULL);
485  ext_options = BlastExtensionOptionsFree(ext_options);
486  BOOST_REQUIRE(ext_options == NULL);
487  hit_params = BlastHitSavingParametersFree(hit_params);
488  BOOST_REQUIRE(hit_params == NULL);
489  hit_options = BlastHitSavingOptionsFree(hit_options);
490  BOOST_REQUIRE(hit_options == NULL);
491  return;
492 }
493 
494 BOOST_AUTO_TEST_CASE( testCalcLinkHSPCutoffsSmallDB )
495 {
496  const EBlastProgramType kBlastProgram = eBlastTypeBlastp;
497  const Int4 kAvgSubjectLength = 316;
498  const Int4 kSpecificSubjectLength = 21;
499  const Int8 kDbLength = 1358990;
500  CSeq_id qid("gi|129295");
501  auto_ptr<SSeqLoc> qsl(
502  CTestObjMgr::Instance().CreateSSeqLoc(qid, eNa_strand_both));
503  CSeq_id sid("gi|129296");
504  auto_ptr<SSeqLoc> ssl(
505  CTestObjMgr::Instance().CreateSSeqLoc(sid, eNa_strand_both));
506 
507  CBl2Seq blaster(*qsl, *ssl, eBlastp);
508 
509  CBlastQueryInfo query_info;
510  CBLAST_SequenceBlk query_blk;
511  TSearchMessages blast_msg;
512 
513  const CBlastOptions& kOpts = blaster.GetOptionsHandle().GetOptions();
514  EBlastProgramType prog = kOpts.GetProgramType();
515  ENa_strand strand_opt = kOpts.GetStrandOption();
516 
517  SetupQueryInfo(const_cast<TSeqLocVector&>(blaster.GetQueries()),
518  prog, strand_opt, &query_info);
519  SetupQueries(const_cast<TSeqLocVector&>(blaster.GetQueries()),
520  query_info, &query_blk, prog, strand_opt, blast_msg);
521  ITERATE(TSearchMessages, m, blast_msg) {
522  BOOST_CHECK(m->empty());
523  }
524 
525  BlastScoringOptions* scoring_options;
526  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
527  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
528  "BLOSUM62", -1, -1);
529  scoring_options->gapped_calculation = FALSE;
530 
531  BlastScoreBlk* sbp = NULL;
532  Blast_Message* blast_message = NULL;
533  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
534  kBlastProgram, &sbp, 1.0, &blast_message,
536 
537  s_FillSearchSpace(query_info, 218039195);
538 
539  BlastExtensionOptions* ext_options;
540  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
541  scoring_options->gapped_calculation);
542 
543  BlastHitSavingOptions* hit_options;
544  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
545  scoring_options->gapped_calculation);
546 
547  BlastHitSavingParameters* hit_params;
548  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, 0, 0, &hit_params);
549  BlastLinkHSPParameters* link_hsp_params = hit_params->link_hsp_params;
550 
551  BlastInitialWordOptions* word_options;
552  BlastInitialWordOptionsNew(kBlastProgram, &word_options);
553 
554  BlastInitialWordParameters* word_params = s_GetInitialWordParameters(kBlastProgram, query_blk,
555  query_info, sbp, word_options, kAvgSubjectLength, hit_params);
556 
557 
558  CalculateLinkHSPCutoffs(kBlastProgram, query_info, sbp,
559  link_hsp_params, word_params,
560  kDbLength, kSpecificSubjectLength);
561 
562  BOOST_CHECK_EQUAL(21, link_hsp_params->cutoff_big_gap);
563  BOOST_CHECK_EQUAL(0, link_hsp_params->cutoff_small_gap);
564 
565  sbp = BlastScoreBlkFree(sbp);
566  BOOST_REQUIRE(sbp == NULL);
567  ext_options = BlastExtensionOptionsFree(ext_options);
568  BOOST_REQUIRE(ext_options == NULL);
569  scoring_options = BlastScoringOptionsFree(scoring_options);
570  BOOST_REQUIRE(scoring_options == NULL);
571  hit_params = BlastHitSavingParametersFree(hit_params);
572  BOOST_REQUIRE(hit_params == NULL);
573  hit_options = BlastHitSavingOptionsFree(hit_options);
574  BOOST_REQUIRE(hit_options == NULL);
575  word_params = BlastInitialWordParametersFree(word_params);
576  BOOST_REQUIRE(word_params == NULL);
577  word_options = BlastInitialWordOptionsFree(word_options);
578  BOOST_REQUIRE(word_options == NULL);
579  return;
580 }
581 
582 BOOST_AUTO_TEST_CASE( testCalcLinkHSPResetGapProb )
583 {
584  const EBlastProgramType kBlastProgram = eBlastTypeBlastp;
585  const Int4 kAvgSubjectLength = 335;
586  const Int4 kSpecificSubjectLength = 186;
587  const Int8 kDbLength = 703698559;
588  CSeq_id qid("gi|129295");
589  auto_ptr<SSeqLoc> qsl(
590  CTestObjMgr::Instance().CreateSSeqLoc(qid, eNa_strand_both));
591  CSeq_id sid("gi|129296");
592  auto_ptr<SSeqLoc> ssl(
593  CTestObjMgr::Instance().CreateSSeqLoc(sid, eNa_strand_both));
594 
595  CBl2Seq blaster(*qsl, *ssl, eBlastp);
596 
597  CBlastQueryInfo query_info;
598  CBLAST_SequenceBlk query_blk;
599  TSearchMessages blast_msg;
600 
601  const CBlastOptions& kOpts = blaster.GetOptionsHandle().GetOptions();
602  EBlastProgramType prog = kOpts.GetProgramType();
603  ENa_strand strand_opt = kOpts.GetStrandOption();
604 
605  SetupQueryInfo(const_cast<TSeqLocVector&>(blaster.GetQueries()),
606  prog, strand_opt, &query_info);
607  SetupQueries(const_cast<TSeqLocVector&>(blaster.GetQueries()),
608  query_info, &query_blk, prog, strand_opt, blast_msg);
609  ITERATE(TSearchMessages, m, blast_msg) {
610  BOOST_CHECK(m->empty());
611  }
612 
613  BlastScoringOptions* scoring_options;
614  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
615  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
616  "BLOSUM62", -1, -1);
617  scoring_options->gapped_calculation = FALSE;
618 
619  BlastScoreBlk* sbp;
620  Blast_Message* blast_message = NULL;
621  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
622  kBlastProgram, &sbp, 1.0, &blast_message,
624 
625  s_FillSearchSpace(query_info, 98483910471LL);
626 
627  BlastExtensionOptions* ext_options;
628  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
629  scoring_options->gapped_calculation);
630 
631  BlastHitSavingOptions* hit_options;
632  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
633  scoring_options->gapped_calculation);
634  BOOST_CHECK(hit_options->do_sum_stats);
635 
636  BlastHitSavingParameters* hit_params;
637  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, kAvgSubjectLength, 2, &hit_params);
638  BlastLinkHSPParameters* link_hsp_params = hit_params->link_hsp_params;
639 
640  BlastInitialWordOptions* word_options;
641  BlastInitialWordOptionsNew(kBlastProgram, &word_options);
642 
643  BlastInitialWordParameters* word_params = s_GetInitialWordParameters(kBlastProgram, query_blk,
644  query_info, sbp, word_options, kAvgSubjectLength, hit_params);
645 
646 
647  /* Reset gap_prob to zero to see that it's properly put back to correct values. */
648  link_hsp_params->gap_prob = 0.0;
649  link_hsp_params->gap_decay_rate = 0.5;
650 
651  CalculateLinkHSPCutoffs(kBlastProgram, query_info, sbp,
652  link_hsp_params, word_params,
653  kDbLength, kSpecificSubjectLength);
654 
655  BOOST_CHECK_EQUAL(5, (int) (10*link_hsp_params->gap_prob));
656  BOOST_CHECK_EQUAL(36, link_hsp_params->cutoff_big_gap);
657  BOOST_CHECK_EQUAL(41, link_hsp_params->cutoff_small_gap);
658 
659  query_blk = BlastSequenceBlkFree(query_blk);
660  BOOST_REQUIRE(query_blk == NULL);
661  sbp = BlastScoreBlkFree(sbp);
662  BOOST_REQUIRE(sbp == NULL);
663  scoring_options = BlastScoringOptionsFree(scoring_options);
664  BOOST_REQUIRE(scoring_options == NULL);
665  ext_options = BlastExtensionOptionsFree(ext_options);
666  BOOST_REQUIRE(ext_options == NULL);
667  hit_params = BlastHitSavingParametersFree(hit_params);
668  BOOST_REQUIRE(hit_params == NULL);
669  hit_options = BlastHitSavingOptionsFree(hit_options);
670  BOOST_REQUIRE(hit_options == NULL);
671  word_params = BlastInitialWordParametersFree(word_params);
672  BOOST_REQUIRE(word_params == NULL);
673  word_options = BlastInitialWordOptionsFree(word_options);
674  BOOST_REQUIRE(word_options == NULL);
675  return;
676 }
677 
678 BOOST_AUTO_TEST_CASE( testLargeWordSize )
679 {
680  const EBlastProgramType kProgram = eBlastTypeBlastn;
681  const Boolean k_is_megablast = FALSE;
682  const int k_threshold = 0;
683  const int k_word_size = 100000; /* Word-size bigger than INT2_MAX. */
684 
685  CBlastInitialWordOptions word_options;
686  BlastInitialWordOptionsNew(kProgram, &word_options);
687  CLookupTableOptions lookup_options;
688  LookupTableOptionsNew(kProgram, &lookup_options);
689  BLAST_FillLookupTableOptions(lookup_options, kProgram,
690  k_is_megablast, k_threshold, k_word_size);
691 
692  BOOST_CHECK_EQUAL(k_word_size, (int) lookup_options->word_size);
693 }
694 
695 static void MakeSomeInvalidKBP(Blast_KarlinBlk** kbp_array,
696  Int4 num,
697  Int4 good_one,
698  BlastQueryInfo* query_info)
699 {
700  Int4 index;
701 
702  BOOST_REQUIRE(num > good_one);
703 
704  for (index=0; index<num; index++)
705  {
706  Blast_KarlinBlk* kbp = NULL;
707  Blast_KarlinBlkFree(kbp_array[index]);
708  if (index != good_one)
709  {
710  kbp = Blast_KarlinBlkNew();
711  kbp->Lambda = -1;
712  kbp->K = -1;
713  kbp->H = -1;
714  query_info->contexts[index].is_valid = FALSE;
715  }
716  else
717  {
718  kbp = Blast_KarlinBlkNew();
719  kbp->Lambda = 1.37;
720  kbp->K = 0.71;
721  kbp->logK = -0.34;
722  kbp->H = 1.3;
723  query_info->contexts[index].is_valid = TRUE;
724  }
725  kbp_array[index] = kbp;
726  }
727  return;
728 }
729 
730 
731 BOOST_AUTO_TEST_CASE( testExtParamNewSomeInvalidKbp )
732 {
733  const int k_num_contexts=6;
734  const EBlastProgramType kBlastProgram=eBlastTypeBlastn;
735 
736  BlastExtensionOptions* ext_options;
737  BlastExtensionOptionsNew(kBlastProgram, &ext_options, true);
738  ext_options->gap_x_dropoff = 20;
739  ext_options->gap_x_dropoff_final = 20;
740 /* FIXME
741  ext_options->gap_trigger = 20;
742 */
743 
745  BlastScoreBlk sb;
746  sb.kbp = (Blast_KarlinBlk**) calloc(k_num_contexts, sizeof(Blast_KarlinBlk*));
747  sb.kbp_gap = (Blast_KarlinBlk**) calloc(k_num_contexts, sizeof(Blast_KarlinBlk*));
748  MakeSomeInvalidKBP(sb.kbp, k_num_contexts, 4, query_info);
749  MakeSomeInvalidKBP(sb.kbp_gap, k_num_contexts, 4, query_info);
750  sb.scale_factor = 0.0;
751  sb.matrix_only_scoring = false;
752 
753  BlastExtensionParameters* ext_params;
754  BlastExtensionParametersNew(kBlastProgram, ext_options, &sb,
755  query_info, &ext_params);
756 
757 
758  BOOST_CHECK(ext_params->gap_x_dropoff > 0.0);
759  BOOST_CHECK(ext_params->gap_x_dropoff_final > 0.0);
760 /* FIXME
761  BOOST_CHECK(ext_params->gap_trigger > 0.0);
762 */
763 
764  for (int index=query_info->first_context; index<=query_info->last_context; index++)
765  {
766  sb.kbp[index] = Blast_KarlinBlkFree(sb.kbp[index]);
767  sb.kbp_gap[index] = Blast_KarlinBlkFree(sb.kbp_gap[index]);
768  }
769  sfree(sb.kbp);
770  sfree(sb.kbp_gap);
771  ext_params = BlastExtensionParametersFree(ext_params);
772  BOOST_REQUIRE(ext_params == NULL);
773  ext_options = BlastExtensionOptionsFree(ext_options);
774  BOOST_REQUIRE(ext_options == NULL);
775 }
776 
777 static void MakeSomeValidKBP(Blast_KarlinBlk** kbp_array, Int4 num,
778  BlastQueryInfo* query_info)
779 {
780  for (Int4 index=0; index<num; index++)
781  {
782  Blast_KarlinBlk* kbp = NULL;
783  Blast_KarlinBlkFree(kbp_array[index]);
784  kbp = Blast_KarlinBlkNew();
785  kbp->Lambda = 1.30;
786  kbp->K = 0.71;
787  kbp->logK = -0.34;
788  kbp->H = 1.3;
789  kbp_array[index] = kbp;
790  query_info->contexts[index].is_valid = TRUE;
791  }
792  return;
793 }
794 
795 BOOST_AUTO_TEST_CASE( testExtensionParamsNew )
796 {
797  const int k_num_contexts=6;
798  const EBlastProgramType kBlastProgram=eBlastTypeBlastn;
799 
800  BlastExtensionOptions* ext_options;
801  BlastExtensionOptionsNew(kBlastProgram, &ext_options, true);
802  ext_options->gap_x_dropoff = 20;
803  ext_options->gap_x_dropoff_final = 22;
804 
806  BlastScoreBlk sb;
807  sb.kbp = (Blast_KarlinBlk**) calloc(k_num_contexts, sizeof(Blast_KarlinBlk*));
808  sb.kbp_gap = (Blast_KarlinBlk**) calloc(k_num_contexts, sizeof(Blast_KarlinBlk*));
809  MakeSomeValidKBP(sb.kbp, k_num_contexts, query_info.Get());
810  MakeSomeValidKBP(sb.kbp_gap, k_num_contexts, query_info.Get());
811  sb.scale_factor = 0.0;
813 
814 
815  BlastExtensionParameters* ext_params;
816  BlastExtensionParametersNew(kBlastProgram, ext_options, &sb,
817  query_info, &ext_params);
818 
819 
820  BOOST_CHECK_EQUAL(10, ext_params->gap_x_dropoff);
821  BOOST_CHECK_EQUAL(11, ext_params->gap_x_dropoff_final);
822 
823  ext_params = BlastExtensionParametersFree(ext_params);
824  BOOST_REQUIRE(ext_params == NULL);
825 
826  // gap_x_dropoff_final less than gap_x_dropoff, gap_x_dropoff_final should be adjusted.
827  ext_options->gap_x_dropoff = 25;
828  ext_options->gap_x_dropoff_final = 22;
829  BlastExtensionParametersNew(kBlastProgram, ext_options, &sb,
830  query_info, &ext_params);
831 
832 
833  BOOST_CHECK_EQUAL(13, ext_params->gap_x_dropoff);
834  BOOST_CHECK_EQUAL(13, ext_params->gap_x_dropoff_final);
835 
836  for (int index=query_info->first_context; index<=query_info->last_context; index++)
837  {
838  sb.kbp[index] = Blast_KarlinBlkFree(sb.kbp[index]);
839  sb.kbp_gap[index] = Blast_KarlinBlkFree(sb.kbp_gap[index]);
840  }
841  sfree(sb.kbp);
842  sfree(sb.kbp_gap);
843  ext_params = BlastExtensionParametersFree(ext_params);
844  BOOST_REQUIRE(ext_params == NULL);
845  ext_options = BlastExtensionOptionsFree(ext_options);
846  BOOST_REQUIRE(ext_options == NULL);
847  }
848 
849 BOOST_AUTO_TEST_CASE( testHitSavingParamNewSomeInvalidKbp )
850 {
851  const EBlastProgramType kBlastProgram = eBlastTypeBlastn;
852  CSeq_id qid1("gi|555");
853  auto_ptr<SSeqLoc> qsl1(
854  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
855  CSeq_id qid2("gi|556");
856  auto_ptr<SSeqLoc> qsl2(
857  CTestObjMgr::Instance().CreateSSeqLoc(qid2, eNa_strand_both));
858  CSeq_id qid3("gi|557");
859  auto_ptr<SSeqLoc> qsl3(
860  CTestObjMgr::Instance().CreateSSeqLoc(qid3, eNa_strand_both));
861 
862  TSeqLocVector query_v;
863 
864  query_v.push_back(*qsl1);
865  query_v.push_back(*qsl2);
866  query_v.push_back(*qsl3);
867 
868  CBlastQueryInfo query_info;
869  CBLAST_SequenceBlk query_blk;
870  TSearchMessages blast_msg;
872 
873  const CBlastOptions& kOpts = opts->GetOptions();
874  EBlastProgramType prog = kOpts.GetProgramType();
875  ENa_strand strand_opt = kOpts.GetStrandOption();
876 
877  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
878  SetupQueries(query_v, query_info, &query_blk,
879  prog, strand_opt, blast_msg);
880  ITERATE(TSearchMessages, m, blast_msg) {
881  BOOST_CHECK(m->empty());
882  }
883 
884  BlastScoringOptions* scoring_options;
885  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
886  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
887  "BLOSUM62", -1, -1);
888 
889  BlastScoreBlk* sbp;
890  Blast_Message* blast_message = NULL;
891  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
892  kBlastProgram, &sbp, 1.0, &blast_message,
894 
895  // Here we remove the valid KarlinBlks and put in some that might result from completely masked queries.
896  MakeSomeInvalidKBP(sbp->kbp,
897  query_info->last_context+1,
898  query_info->last_context-1,
899  query_info.Get());
901  query_info->last_context+1,
902  query_info->last_context-1,
903  query_info.Get());
904 
905  s_FillSearchSpace(query_info, 10000000LL);
906 
907  BlastExtensionOptions* ext_options;
908  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
909  scoring_options->gapped_calculation);
910 
911  BlastHitSavingOptions* hit_options;
912  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
913  scoring_options->gapped_calculation);
914 
915  BlastHitSavingParameters* hit_params;
916  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, 0, 0, &hit_params);
917 
918  BOOST_CHECK_EQUAL(10, hit_params->cutoff_score_min);
919 
920  scoring_options = BlastScoringOptionsFree(scoring_options);
921  BOOST_REQUIRE(scoring_options == NULL);
922  hit_params = BlastHitSavingParametersFree(hit_params);
923  BOOST_REQUIRE(hit_params == NULL);
924  hit_options = BlastHitSavingOptionsFree(hit_options);
925  BOOST_REQUIRE(hit_options == NULL);
926  ext_options = BlastExtensionOptionsFree(ext_options);
927  BOOST_REQUIRE(ext_options == NULL);
928  sbp = BlastScoreBlkFree(sbp);
929  BOOST_REQUIRE(sbp == NULL);
930 }
931 
932 // This simulates values calculated by for the human genomic database.
933 // the cutoff_score is larger than the score corresponding to an expect
934 // value of 10, so it gets set to that value.
935 BOOST_AUTO_TEST_CASE( testHitSavingParamNewGappedTblastnLargeSubjectSequence )
936 {
937  const EBlastProgramType kBlastProgram = eBlastTypeTblastn;
938  CSeq_id qid1("gi|3091");
939  auto_ptr<SSeqLoc> qsl1(
940  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
941 
942  TSeqLocVector query_v;
943  query_v.push_back(*qsl1);
944 
945  CBlastQueryInfo query_info;
946  CBLAST_SequenceBlk query_blk;
947  TSearchMessages blast_msg;
949 
950  const CBlastOptions& kOpts = opts->GetOptions();
951  EBlastProgramType prog = kOpts.GetProgramType();
952  ENa_strand strand_opt = kOpts.GetStrandOption();
953 
954  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
955  SetupQueries(query_v, query_info, &query_blk,
956  prog, strand_opt, blast_msg);
957  ITERATE(TSearchMessages, m, blast_msg) {
958  BOOST_CHECK(m->empty());
959  }
960 
961 
962  BlastScoringOptions* scoring_options;
963  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
964  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
965  "BLOSUM62", -1, -1);
966 
967  BlastScoreBlk* sbp;
968  Blast_Message* blast_message = NULL;
969  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
970  kBlastProgram, &sbp, 1.0, &blast_message,
972 
973  s_FillSearchSpace(query_info, 481002014850LL);
974 
975  BlastExtensionOptions* ext_options;
976  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
977  scoring_options->gapped_calculation);
978 
979  BlastHitSavingOptions* hit_options;
980  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
981  scoring_options->gapped_calculation);
982 
983  const int k_avg_subject_length=128199245;
984  BlastHitSavingParameters* hit_params;
985  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, k_avg_subject_length, 2, &hit_params);
986 
987  BOOST_CHECK_EQUAL(66, hit_params->cutoff_score_min);
988  BOOST_CHECK_EQUAL(50, hit_params->prelim_evalue);
989 
990  scoring_options = BlastScoringOptionsFree(scoring_options);
991  BOOST_REQUIRE(scoring_options == NULL);
992  hit_params = BlastHitSavingParametersFree(hit_params);
993  BOOST_REQUIRE(hit_params == NULL);
994  hit_options = BlastHitSavingOptionsFree(hit_options);
995  BOOST_REQUIRE(hit_options == NULL);
996  ext_options = BlastExtensionOptionsFree(ext_options);
997  BOOST_REQUIRE(ext_options == NULL);
998  sbp = BlastScoreBlkFree(sbp);
999  BOOST_REQUIRE(sbp == NULL);
1000 }
1001 
1002 
1003 // This simulates values calculated by for the drosoph database.
1004 // the cutoff_score is between gap_trigger and the score corresponding
1005 // to an expect value of 10.
1006 BOOST_AUTO_TEST_CASE( testHitSavingParamNewGappedTblastnMidsizeSubjectSequence )
1007 {
1008  const EBlastProgramType kBlastProgram = eBlastTypeTblastn;
1009  CSeq_id qid1("gi|3091");
1010  auto_ptr<SSeqLoc> qsl1(
1011  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
1012 
1013  TSeqLocVector query_v;
1014  query_v.push_back(*qsl1);
1015 
1016  CBlastQueryInfo query_info;
1017  CBLAST_SequenceBlk query_blk;
1018  TSearchMessages blast_msg;
1020 
1021  const CBlastOptions& kOpts = opts->GetOptions();
1022  EBlastProgramType prog = kOpts.GetProgramType();
1023  ENa_strand strand_opt = kOpts.GetStrandOption();
1024 
1025  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
1026  SetupQueries(query_v, query_info, &query_blk,
1027  prog, strand_opt, blast_msg);
1028  ITERATE(TSearchMessages, m, blast_msg) {
1029  BOOST_CHECK(m->empty());
1030  }
1031 
1032  BlastScoringOptions* scoring_options;
1033  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
1034  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
1035  "BLOSUM62", -1, -1);
1036 
1037  BlastScoreBlk* sbp;
1038  Blast_Message* blast_message = NULL;
1039  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
1040  kBlastProgram, &sbp, 1.0, &blast_message,
1042 
1043  s_FillSearchSpace(query_info, 20007999590LL);
1044 
1045  BlastExtensionOptions* ext_options;
1046  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
1047  scoring_options->gapped_calculation);
1048 
1049  BlastHitSavingOptions* hit_options;
1050  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
1051  scoring_options->gapped_calculation);
1052 
1053  const int k_avg_subject_length=104833;
1054  BlastHitSavingParameters* hit_params;
1055  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, k_avg_subject_length, 2, &hit_params);
1056 
1057  BOOST_CHECK_EQUAL(40, hit_params->cutoff_score_min);
1058  BOOST_CHECK_EQUAL(50, hit_params->prelim_evalue);
1059 
1060  scoring_options = BlastScoringOptionsFree(scoring_options);
1061  BOOST_REQUIRE(scoring_options == NULL);
1062  hit_params = BlastHitSavingParametersFree(hit_params);
1063  BOOST_REQUIRE(hit_params == NULL);
1064  hit_options = BlastHitSavingOptionsFree(hit_options);
1065  BOOST_REQUIRE(hit_options == NULL);
1066  ext_options = BlastExtensionOptionsFree(ext_options);
1067  BOOST_REQUIRE(ext_options == NULL);
1068  sbp = BlastScoreBlkFree(sbp);
1069  BOOST_REQUIRE(sbp == NULL);
1070 }
1071 
1072 // This checks that for repeated calls to BlastHitSavingParametersUpdate the
1073 // proper value for cutoff_score is returned.
1074 BOOST_AUTO_TEST_CASE( testHitSavingParamUpdateMultipleCalls )
1075 {
1076  const EBlastProgramType kBlastProgram = eBlastTypeTblastn;
1077  CSeq_id qid1("gi|3091");
1078  auto_ptr<SSeqLoc> qsl1(
1079  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
1080 
1081  TSeqLocVector query_v;
1082  query_v.push_back(*qsl1);
1083 
1084  CBlastQueryInfo query_info;
1085  CBLAST_SequenceBlk query_blk;
1086  TSearchMessages blast_msg;
1088 
1089  const CBlastOptions& kOpts = opts->GetOptions();
1090  EBlastProgramType prog = kOpts.GetProgramType();
1091  ENa_strand strand_opt = kOpts.GetStrandOption();
1092 
1093  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
1094  SetupQueries(query_v, query_info, &query_blk,
1095  prog, strand_opt, blast_msg);
1096  ITERATE(TSearchMessages, m, blast_msg) {
1097  BOOST_CHECK(m->empty());
1098  }
1099 
1100  BlastScoringOptions* scoring_options;
1101  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
1102  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
1103  "BLOSUM62", -1, -1);
1104 
1105  BlastScoreBlk* sbp;
1106  Blast_Message* blast_message = NULL;
1107  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
1108  kBlastProgram, &sbp, 1.0, &blast_message,
1110 
1111  s_FillSearchSpace(query_info, 20007999590LL);
1112 
1113  BlastExtensionOptions* ext_options;
1114  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
1115  scoring_options->gapped_calculation);
1116 
1117  BlastHitSavingOptions* hit_options;
1118  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
1119  scoring_options->gapped_calculation);
1120 
1121  const int k_avg_subject_length=104833;
1122  BlastHitSavingParameters* hit_params;
1123  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, k_avg_subject_length, 2, &hit_params);
1124 
1125  BOOST_CHECK_EQUAL(40, hit_params->cutoff_score_min);
1126  BOOST_CHECK_EQUAL(40, hit_params->cutoffs[0].cutoff_score);
1127  BOOST_CHECK_EQUAL(40, hit_params->cutoffs[0].cutoff_score_max);
1128 
1129  s_FillSearchSpace(query_info, 2000799959LL);
1130 
1131  BlastHitSavingParametersUpdate(kBlastProgram, sbp, query_info, k_avg_subject_length, 2, hit_params);
1132  BOOST_CHECK_EQUAL(50, hit_params->prelim_evalue);
1133  BOOST_CHECK_EQUAL(40, hit_params->cutoff_score_min);
1134  BOOST_CHECK_EQUAL(40, hit_params->cutoffs[0].cutoff_score);
1135  BOOST_CHECK_EQUAL(40, hit_params->cutoffs[0].cutoff_score_max);
1136  //Check hit saving default
1137  BOOST_CHECK_EQUAL(0, hit_options->query_cov_hsp_perc);
1138  BOOST_CHECK_EQUAL(0, hit_options->max_hsps_per_subject);
1139  BOOST_CHECK_EQUAL(0, opts->GetQueryCovHspPerc());
1140  BOOST_CHECK_EQUAL(0, opts->GetMaxHspsPerSubject());
1141  opts->SetQueryCovHspPerc(55.2);
1142  opts->SetMaxHspsPerSubject(8);
1143  BOOST_CHECK_EQUAL(55.2, opts->GetQueryCovHspPerc());
1144  BOOST_CHECK_EQUAL(8, opts->GetMaxHspsPerSubject());
1145 
1146 
1147  scoring_options = BlastScoringOptionsFree(scoring_options);
1148  BOOST_REQUIRE(scoring_options == NULL);
1149  hit_params = BlastHitSavingParametersFree(hit_params);
1150  BOOST_REQUIRE(hit_params == NULL);
1151  hit_options = BlastHitSavingOptionsFree(hit_options);
1152  BOOST_REQUIRE(hit_options == NULL);
1153  ext_options = BlastExtensionOptionsFree(ext_options);
1154  BOOST_REQUIRE(ext_options == NULL);
1155  sbp = BlastScoreBlkFree(sbp);
1156  BOOST_REQUIRE(sbp == NULL);
1157 }
1158 
1159 // This simulates values calculated by for an EST database.
1160 // the cutoff_score is actually less than gap_trigger and gets
1161 // raised to that level.
1162 BOOST_AUTO_TEST_CASE( testHitSavingParamNewGappedTblastnSmallSubjectSequence )
1163 {
1164  const EBlastProgramType kBlastProgram = eBlastTypeTblastn;
1165  CSeq_id qid1("gi|17532675");
1166  auto_ptr<SSeqLoc> qsl1(
1167  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
1168 
1169  TSeqLocVector query_v;
1170  query_v.push_back(*qsl1);
1171 
1172  CBlastQueryInfo query_info;
1173  CBLAST_SequenceBlk query_blk;
1174  TSearchMessages blast_msg;
1176 
1177  const CBlastOptions& kOpts = opts->GetOptions();
1178  EBlastProgramType prog = kOpts.GetProgramType();
1179  ENa_strand strand_opt = kOpts.GetStrandOption();
1180 
1181  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
1182  SetupQueries(query_v, query_info, &query_blk,
1183  prog, strand_opt, blast_msg);
1184  ITERATE(TSearchMessages, m, blast_msg) {
1185  BOOST_CHECK(m->empty());
1186  }
1187 
1188  BlastScoringOptions* scoring_options;
1189  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
1190  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
1191  "BLOSUM62", -1, -1);
1192 
1193  BlastScoreBlk* sbp;
1194  Blast_Message* blast_message = NULL;
1195  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
1196  kBlastProgram, &sbp, 1.0, &blast_message,
1198 
1199  s_FillSearchSpace(query_info, 1480902925051LL);
1200 
1201  BlastExtensionOptions* ext_options;
1202  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
1203  scoring_options->gapped_calculation);
1204 
1205  BlastHitSavingOptions* hit_options;
1206  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
1207  scoring_options->gapped_calculation);
1208 
1209  const int k_avg_subject_length=523;
1210  BlastHitSavingParameters* hit_params;
1211  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, k_avg_subject_length, 2, &hit_params);
1212 
1213  BOOST_CHECK_EQUAL(19, hit_params->cutoff_score_min);
1214  BOOST_CHECK_EQUAL(19, hit_params->cutoffs[0].cutoff_score);
1215  BOOST_CHECK_EQUAL(19, hit_params->cutoffs[0].cutoff_score_max);
1216 
1217  scoring_options = BlastScoringOptionsFree(scoring_options);
1218  BOOST_REQUIRE(scoring_options == NULL);
1219  hit_params = BlastHitSavingParametersFree(hit_params);
1220  BOOST_REQUIRE(hit_params == NULL);
1221  hit_options = BlastHitSavingOptionsFree(hit_options);
1222  BOOST_REQUIRE(hit_options == NULL);
1223  ext_options = BlastExtensionOptionsFree(ext_options);
1224  BOOST_REQUIRE(ext_options == NULL);
1225  sbp = BlastScoreBlkFree(sbp);
1226  BOOST_REQUIRE(sbp == NULL);
1227 }
1228 
1229 
1230 BOOST_AUTO_TEST_CASE( testInitialWordParamNewSomeInvalidKbp )
1231 {
1232  const EBlastProgramType kBlastProgram = eBlastTypeBlastn;
1233  const Uint4 k_subject_length=10000;
1234  CSeq_id qid1("gi|555");
1235  auto_ptr<SSeqLoc> qsl1(
1236  CTestObjMgr::Instance().CreateSSeqLoc(qid1, eNa_strand_both));
1237  CSeq_id qid2("gi|556");
1238  auto_ptr<SSeqLoc> qsl2(
1239  CTestObjMgr::Instance().CreateSSeqLoc(qid2, eNa_strand_both));
1240  CSeq_id qid3("gi|557");
1241  auto_ptr<SSeqLoc> qsl3(
1242  CTestObjMgr::Instance().CreateSSeqLoc(qid3, eNa_strand_both));
1243 
1244  TSeqLocVector query_v;
1245 
1246  query_v.push_back(*qsl1);
1247  query_v.push_back(*qsl2);
1248  query_v.push_back(*qsl3);
1249 
1250  CBlastQueryInfo query_info;
1251  CBLAST_SequenceBlk query_blk;
1252  TSearchMessages blast_msg;
1254 
1255  const CBlastOptions& kOpts = opts->GetOptions();
1256  EBlastProgramType prog = kOpts.GetProgramType();
1257  ENa_strand strand_opt = kOpts.GetStrandOption();
1258 
1259  SetupQueryInfo(query_v, prog, strand_opt, &query_info);
1260  SetupQueries(query_v, query_info, &query_blk,
1261  prog, strand_opt, blast_msg);
1262  ITERATE(TSearchMessages, m, blast_msg) {
1263  BOOST_CHECK(m->empty());
1264  }
1265 
1266  BlastScoringOptions* scoring_options;
1267  BlastScoringOptionsNew(kBlastProgram, &scoring_options);
1268  BLAST_FillScoringOptions(scoring_options, kBlastProgram, FALSE, 0, 0,
1269  "BLOSUM62", -1, -1);
1270 
1271  BlastScoreBlk* sbp;
1272  Blast_Message* blast_message = NULL;
1273  BlastSetup_ScoreBlkInit(query_blk, query_info, scoring_options,
1274  kBlastProgram, &sbp, 1.0, &blast_message,
1276 
1277  // Here we remove the valid KarlinBlks and put in some that might result from completely masked queries.
1278  MakeSomeInvalidKBP(sbp->kbp, query_info->last_context+1,
1279  query_info->last_context-1, query_info.Get());
1280  MakeSomeInvalidKBP(sbp->kbp_gap, query_info->last_context+1,
1281  query_info->last_context-1, query_info.Get());
1282 
1283  s_FillSearchSpace(query_info, 1480902925051LL);
1284 
1285  BlastExtensionOptions* ext_options;
1286  BlastExtensionOptionsNew(kBlastProgram, &ext_options,
1287  scoring_options->gapped_calculation);
1288 
1289  BlastHitSavingOptions* hit_options;
1290  BlastHitSavingOptionsNew(kBlastProgram, &hit_options,
1291  scoring_options->gapped_calculation);
1292  BlastHitSavingParameters* hit_params;
1293  BlastHitSavingParametersNew(kBlastProgram, hit_options, sbp, query_info, 0, 0, &hit_params);
1294  hit_params->cutoff_score_min = 19;
1295 
1296  BlastInitialWordOptions* word_options;
1297  BlastInitialWordOptionsNew(kBlastProgram, &word_options);
1298  word_options->x_dropoff = 20;
1299 
1300  BlastInitialWordParameters* word_params = s_GetInitialWordParameters(kBlastProgram, query_blk,
1301  query_info, sbp, word_options, k_subject_length, hit_params);
1302 
1303  BOOST_CHECK_EQUAL(13, word_params->cutoff_score_min);
1304  BOOST_CHECK_EQUAL(11, word_params->x_dropoff_max);
1305 
1306  scoring_options = BlastScoringOptionsFree(scoring_options);
1307  BOOST_REQUIRE(scoring_options == NULL);
1308  hit_params = BlastHitSavingParametersFree(hit_params);
1309  BOOST_REQUIRE(hit_params == NULL);
1310  hit_options = BlastHitSavingOptionsFree(hit_options);
1311  BOOST_REQUIRE(hit_options == NULL);
1312  word_params = BlastInitialWordParametersFree(word_params);
1313  BOOST_REQUIRE(word_params == NULL);
1314  word_options = BlastInitialWordOptionsFree(word_options);
1315  BOOST_REQUIRE(word_options == NULL);
1316  ext_options = BlastExtensionOptionsFree(ext_options);
1317  BOOST_REQUIRE(ext_options == NULL);
1318  sbp = BlastScoreBlkFree(sbp);
1319  BOOST_REQUIRE(sbp == NULL);
1320 }
1321 
1322 BOOST_AUTO_TEST_CASE( testRemoteFilterString)
1323 {
1325 
1326  opts.SetProgram(eBlastn);
1327  opts.SetFilterString("F", true);/* NCBI_FAKE_WARNING */
1328  // cerr << "dust filter" << (int) blast4_opts->GetParamByName("DustFiltering")->GetValue().GetBoolean() << '\n';
1329  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("DustFiltering")->GetValue().GetBoolean());
1330  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("RepeatFiltering")->GetValue().GetBoolean());
1331  opts.SetFilterString("T", true);/* NCBI_FAKE_WARNING */
1332  BOOST_CHECK_EQUAL(true, opts.GetBlast4AlgoOpts()->GetParamByName("DustFiltering")->GetValue().GetBoolean());
1333  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("RepeatFiltering")->GetValue().GetBoolean());
1334 
1335  opts.SetProgram(eBlastp);
1336  opts.SetFilterString("F", true);/* NCBI_FAKE_WARNING */
1337  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1338  opts.SetFilterString("T", true);/* NCBI_FAKE_WARNING */
1339  BOOST_CHECK_EQUAL(true, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1340 
1341  opts.SetProgram(eBlastx);
1342  opts.SetFilterString("F", true);/* NCBI_FAKE_WARNING */
1343  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1344  opts.SetFilterString("T", true);/* NCBI_FAKE_WARNING */
1345  BOOST_CHECK_EQUAL(true, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1346 
1347  opts.SetProgram(eTblastn);
1348  opts.SetFilterString("F", true);/* NCBI_FAKE_WARNING */
1349  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1350  opts.SetFilterString("T", true);/* NCBI_FAKE_WARNING */
1351  BOOST_CHECK_EQUAL(true, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1352 
1353  opts.SetProgram(eTblastx);
1354  opts.SetFilterString("F", true);/* NCBI_FAKE_WARNING */
1355  BOOST_CHECK_EQUAL(false, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1356  opts.SetFilterString("T", true);/* NCBI_FAKE_WARNING */
1357  BOOST_CHECK_EQUAL(true, opts.GetBlast4AlgoOpts()->GetParamByName("SegFiltering")->GetValue().GetBoolean());
1358 }
1359 
1360 BOOST_AUTO_TEST_CASE( testNewFilteringDefaults )
1361 {
1363 
1365  BOOST_REQUIRE(opts.NotEmpty());
1366  char* filter_string = opts->GetFilterString(); /* NCBI_FAKE_WARNING */
1367  BOOST_CHECK_EQUAL(string("F"), string(filter_string));
1368  sfree(filter_string);
1369 
1371  BOOST_REQUIRE(opts.NotEmpty());
1372  filter_string = opts->GetFilterString(); /* NCBI_FAKE_WARNING */
1373  BOOST_CHECK_EQUAL(string("F"), string(filter_string));
1374  sfree(filter_string);
1375 }
1376 
1377 BOOST_AUTO_TEST_CASE( testOptionsDeepCopy )
1378 {
1379  CRef<CBlastOptionsHandle> optsHandle;
1380 
1381  optsHandle = CBlastOptionsFactory::Create(eBlastp);
1382  BOOST_REQUIRE(optsHandle.NotEmpty());
1383 
1384  optsHandle->SetFilterString("L;m;"); /* NCBI_FAKE_WARNING */
1385  optsHandle->SetDbLength(10000);
1386  optsHandle->SetOptions().SetPHIPattern("Y-S-[SA]-X-[LVIM]", false);
1387  optsHandle->SetOptions().SetQueryCovHspPerc(55.4);
1388  //optsHandle->GetOptions().DebugDumpText(NcbiCerr, "BLAST options - original", 1);
1389 
1390  CRef<CBlastOptions> optsClone = optsHandle->GetOptions().Clone();
1391  optsHandle.Reset();
1392  //optsClone->DebugDumpText(NcbiCerr, "BLAST options - clone", 1);
1393 
1394  BOOST_CHECK_EQUAL(optsClone->GetDbLength(), 10000);
1395  BOOST_CHECK_EQUAL(string(optsClone->GetFilterString()), string("L;m;")); /* NCBI_FAKE_WARNING */
1396  BOOST_CHECK_EQUAL(string(optsClone->GetPHIPattern()), string("Y-S-[SA]-X-[LVIM]"));
1397  BOOST_CHECK_EQUAL(optsClone->GetQueryCovHspPerc(), 55.4);
1398 
1399  // try setting and unsetting the best hit options (SB-339, issue #4)
1402  CRef<CBlastOptions> optsSnapshot = optsClone->Clone();
1403 
1405  optsClone->SetBestHitOverhang(kBestHit_OverhangDflt * 2);
1406  BOOST_CHECK_CLOSE(optsClone->GetBestHitScoreEdge(), kBestHit_ScoreEdgeDflt * 2, 0.00000001);
1407  BOOST_CHECK_CLOSE(optsClone->GetBestHitOverhang(), kBestHit_OverhangDflt * 2, 0.00000001);
1408 
1409  optsClone = optsSnapshot;
1410  BOOST_CHECK_CLOSE(optsClone->GetBestHitScoreEdge(), kBestHit_ScoreEdgeDflt, 0.00000001);
1411  BOOST_CHECK_CLOSE(optsClone->GetBestHitOverhang(), kBestHit_OverhangDflt, 0.00000001);
1412 }
1413 
1415 #endif /* SKIP_DOXYGEN_PROCESSING */
Int2 BlastHitSavingParametersNew(EBlastProgramType program_number, const BlastHitSavingOptions *options, const BlastScoreBlk *sbp, const BlastQueryInfo *query_info, Int4 avg_subject_length, Int4 compositionBasedStats, BlastHitSavingParameters **parameters)
Allocate memory and initialize the BlastHitSavingParameters structure.
void SetMaxHspsPerSubject(int m)
Sets MaxHspPerSubjectQueryPair.
#define kBestHit_ScoreEdgeDflt
Default value for score_edge.
const TSeqLocVector & GetQueries() const
Retrieve a vector of query sequences.
Definition: bl2seq.hpp:244
const CBlastOptions & GetOptions() const
Return the object which this object is a handle for.
Int8 GetDbLength() const
int GetUnifiedP() const
Int2 BLAST_GetNucleotideGapExistenceExtendParams(Int4 reward, Int4 penalty, Int4 *gap_existence, Int4 *gap_extension)
Extract the recommended gap existence and extension values.
Definition: blast_stat.c:3407
Nucl-Nucl (traditional blastn)
Definition: blast_types.hpp:58
BOOST_AUTO_TEST_SUITE_END() class CString2Args
Auxiliary class to convert a string into an argument count and vector.
Declares the CBl2Seq (BLAST 2 Sequences) class.
Scoring options block Used to produce the BlastScoreBlk structure This structure may be needed for lo...
signed int Int4
Alias for signed int.
Definition: ncbitype.h:120
LookupTableWrap * LookupTableWrapFree(LookupTableWrap *lookup)
Deallocate memory for the lookup table.
Definition: lookup_wrap.c:176
unsigned int Uint4
Alias for unsigned int.
Definition: ncbitype.h:121
Parameter block for linking HSPs with sum statistics.
void SetBestHitScoreEdge(double score_edge)
Runs the BLAST algorithm between 2 sequences.
Definition: bl2seq.hpp:57
All filtering options.
BlastInitialWordOptions * BlastInitialWordOptionsFree(BlastInitialWordOptions *options)
Deallocate memory for BlastInitialWordOptions.
low-complexity for proteins.
BOOST_AUTO_TEST_CASE(TestTasksDefinitionsAndDocumentation)
#define kBestHit_OverhangDflt
The "best hit" writer.
void SetSegFiltering(bool val=true)
double x_dropoff
X-dropoff value (in bits) for the ungapped extension.
BlastLinkHSPParameters * link_hsp_params
Parameters for linking HSPs with sum statistics; linking is not done if NULL.
double query_cov_hsp_perc
Min query coverage hsp percentage.
Defines BLAST error codes (user errors included)
To be used when running BLAST remotely.
Int4 gap_x_dropoff
X-dropoff value for gapped extension (raw)
double gap_x_dropoff
X-dropoff value for gapped extension (in bits)
Options used when evaluating and saving hits These include: a.
Structure used for scoring calculations.
Definition: blast_stat.h:177
Definition: testodbc.c:30
Blast_KarlinBlk ** kbp_gap
K-A parameters for gapped alignments.
Definition: blast_stat.h:208
BlastDatabaseOptions * BlastDatabaseOptionsFree(BlastDatabaseOptions *db_options)
Deallocate database options.
BlastContextInfo * contexts
Information per context.
BlastGappedCutoffs * cutoffs
per-context gapped cutoff information
signed NCBI_INT8_TYPE Int8
Signed 8 byte sized integer.
Definition: ncbitype.h:143
Wrapper class for BlastInitialWordOptions .
Definition: blast_aux.hpp:268
const NCBI_NS_NCBI::CEnumeratedTypeValues *ENUM_METHOD_NAME() ENa_strand(void)
Access to ENa_strand's attributes (values, names) as defined in spec.
Boolean matrix_only_scoring
Score ungapped/gapped alignment only using the matrix parameters and with raw scores.
Definition: blast_stat.h:189
#define NULL
Definition: ncbistd.hpp:225
void SetupQueryInfo(TSeqLocVector &queries, EBlastProgramType prog, objects::ENa_strand strand_opt, BlastQueryInfo **qinfo)
Allocates the query information structure and fills the context offsets, in case of multiple queries...
Int4 last_context
Index of the last element of the context array.
BlastSeqLoc * BlastSeqLocNew(BlastSeqLoc **head, Int4 from, Int4 to)
Create and initialize a new sequence interval.
Definition: blast_filter.c:610
Translated nucl-Translated nucl.
Definition: blast_types.hpp:62
void SetRepeatFiltering(bool val=true)
Turns on repeat filtering using the default repeat database, namely kDefaultRepeatFilterDb.
void SetUnifiedP(int u=0)
const char * GetPHIPattern() const
static void s_FillSearchSpace(BlastQueryInfo *query_info, Int8 searchsp)
Int2 BlastInitialWordParametersNew(EBlastProgramType program_number, const BlastInitialWordOptions *word_options, const BlastHitSavingParameters *hit_params, const LookupTableWrap *lookup_wrap, const BlastScoreBlk *sbp, BlastQueryInfo *query_info, Uint4 subject_length, BlastInitialWordParameters **parameters)
Allocate memory for BlastInitialWordParameters and set x_dropoff.
Blast_KarlinBlk * Blast_KarlinBlkFree(Blast_KarlinBlk *kbp)
Deallocates the KarlinBlk.
Definition: blast_stat.c:961
BlastExtensionParameters * BlastExtensionParametersFree(BlastExtensionParameters *parameters)
Deallocate memory for BlastExtensionParameters.
Implementation of a number of BlastHSPWriters to save hits from a BLAST search, and subsequently retu...
BlastSeqLoc * BlastSeqLocFree(BlastSeqLoc *loc)
Deallocate all BlastSeqLoc objects in a chain.
Definition: blast_filter.c:739
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:893
double prelim_evalue
evalue for preliminary search (may be higher for CBS).
int i
Int2 BLAST_FillLookupTableOptions(LookupTableOptions *options, EBlastProgramType program, Boolean is_megablast, double threshold, Int4 word_size)
Allocate memory for lookup table options and fill with default values.
Blast_KarlinBlk ** kbp_std
K-A parameters for ungapped alignments.
Definition: blast_stat.h:212
void SetProgram(EProgram p)
Sets the task this object is best suited for.
BlastScoreBlk * BlastScoreBlkNew(Uint1 alphabet, Int4 number_of_contexts)
Allocates and initializes BlastScoreBlk.
Definition: blast_stat.c:889
Options required for setting up the query sequence.
BlastHitSavingOptions * BlastHitSavingOptionsFree(BlastHitSavingOptions *options)
Deallocate memory for BlastHitSavingOptions.
BlastExtensionOptions * BlastExtensionOptionsFree(BlastExtensionOptions *options)
Deallocate memory for BlastExtensionOptions.
Int2 BlastExtensionParametersNew(EBlastProgramType blast_program, const BlastExtensionOptions *options, BlastScoreBlk *sbp, BlastQueryInfo *query_info, BlastExtensionParameters **parameters)
Calculate the raw values for the X-dropoff parameters.
Int8 eff_searchsp
Effective search space for this context.
Wrapper class for BLAST_SequenceBlk .
Definition: blast_aux.hpp:259
Int2 BlastHitSavingOptionsNew(EBlastProgramType program, BlastHitSavingOptions **options, Boolean gapped_calculation)
Allocate memory for BlastHitSavingOptions.
double GetQueryCovHspPerc() const
Returns QueryCovHspPerc.
Int2 BlastInitialWordOptionsNew(EBlastProgramType program, BlastInitialWordOptions **options)
Allocate memory for BlastInitialWordOptions and fill with default values.
BlastScoreBlk * BlastScoreBlkFree(BlastScoreBlk *sbp)
Deallocates BlastScoreBlk as well as all associated structures.
Definition: blast_stat.c:970
void SetQueryCovHspPerc(double p)
Int4 gap_x_dropoff_final
X-dropoff value for the final gapped extension (raw)
Int2 BlastSetup_ScoreBlkInit(BLAST_SequenceBlk *query_blk, const BlastQueryInfo *query_info, const BlastScoringOptions *scoring_options, EBlastProgramType program_number, BlastScoreBlk **sbpp, double scale_factor, Blast_Message **blast_message, GET_MATRIX_PATH get_path)
Initializes the score block structure.
Definition: blast_setup.c:400
BlastQueryInfo * Get() const
Definition: blast_aux.hpp:261
Translated nucl-Protein.
Definition: blast_types.hpp:60
BlastScoringOptions * BlastScoringOptionsFree(BlastScoringOptions *options)
Deallocate memory for BlastScoringOptions.
void SetPHIPattern(const char *pattern, bool is_dna)
auto_ptr –
Definition: ncbimisc.hpp:336
Int2 BLAST_GetSuggestedWindowSize(EBlastProgramType program_number, const char *matrixName, Int4 *window_size)
Get window sizes for two hit algorithm suggested by Stephen Altschul.
Int4 cutoff_score
Raw cutoff score corresponding to the e-value provided by the user if no sum stats, the lowest score to attempt linking on if sum stats are used.
void SetBestHitOverhang(double overhang)
Wrapper class for BlastQueryInfo .
Definition: blast_aux.hpp:261
Int2 BLAST_GetProteinGapExistenceExtendParams(const char *matrixName, Int4 *gap_existence, Int4 *gap_extension)
Extract the recommended gap existence and extension values.
Definition: blast_stat.c:3379
Blast_KarlinBlk * Blast_KarlinBlkNew(void)
Callocs a Blast_KarlinBlk.
Definition: blast_stat.c:2866
Used to hold a set of positions, mostly used for filtering.
Definition: blast_def.h:204
static set< string > GetTasks(ETaskSets choice=eAll)
Retrieve the set of supported tasks.
Int2 BlastScoringOptionsNew(EBlastProgramType program, BlastScoringOptions **options)
Allocate memory for BlastScoringOptions and fill with default values.
Utility stuff for more convenient using of Boost.Test library.
double GetQueryCovHspPerc() const
char * GetFilterString() const
Returns FilterString.
Int2 LookupTableWrapInit(BLAST_SequenceBlk *query, const LookupTableOptions *lookup_options, const QuerySetUpOptions *query_options, BlastSeqLoc *lookup_segments, BlastScoreBlk *sbp, LookupTableWrap **lookup_wrap_ptr, const BlastRPSInfo *rps_info, Blast_Message **error_msg)
Create the lookup table for all query words.
Definition: lookup_wrap.c:52
Int2 BlastQuerySetUpOptionsNew(QuerySetUpOptions **options)
Allocate memory for QuerySetUpOptions and fill with default values.
Int4 cutoff_score_min
smallest cutoff score across all contexts
BlastQueryInfo * BlastQueryInfoNew(EBlastProgramType program, int num_queries)
Allocate memory for query information structure.
vector< SSeqLoc > TSeqLocVector
Vector of sequence locations.
Definition: sseqloc.hpp:129
void SetDbLength(Int8 len)
Sets DbLength.
EBlastProgramType
Defines the engine's notion of the different applications of the BLAST algorithm. ...
Definition: blast_program.h:70
SSegOptions * segOptions
low-complexity filtering for proteins sequences (includes translated nucleotides).
void SetMaskAtHash(bool val=true)
const CBlastOptionsHandle & GetOptionsHandle() const
Retrieve the options handle.
Definition: bl2seq.hpp:285
int GetMaxHspsPerSubject() const
Returns MaxHspsPerSubjectQueryPair.
Int2 LookupTableOptionsNew(EBlastProgramType program, LookupTableOptions **options)
Allocate memory for lookup table options and fill with default values.
Definition: testodbc.c:30
Boolean gapped_calculation
gap-free search if FALSE
char * BlastFindMatrixPath(const char *matrix_name, Boolean is_prot)
Returns the path to a specified matrix.
Int2 BlastHitSavingParametersUpdate(EBlastProgramType program_number, const BlastScoreBlk *sbp, const BlastQueryInfo *query_info, Int4 avg_subject_length, Int4 compositionBasedStats, BlastHitSavingParameters *parameters)
Updates cutoff scores in hit saving parameters.
BlastHitSavingParameters * BlastHitSavingParametersFree(BlastHitSavingParameters *parameters)
Deallocate memory for BlastHitSavingOptions*.
Structure to hold the a message from the core of the BLAST engine.
Definition: blast_message.h:70
Structure to hold the Karlin-Altschul parameters.
Definition: blast_stat.h:66
static void MakeSomeValidKBP(Blast_KarlinBlk **kbp_array, Int4 num, BlastQueryInfo *query_info)
Int2 BLAST_FillScoringOptions(BlastScoringOptions *options, EBlastProgramType program, Boolean greedy_extension, Int4 penalty, Int4 reward, const char *matrix, Int4 gap_open, Int4 gap_extend)
Fill non-default values in the BlastScoringOptions structure.
#define BLASTAA_SEQ_CODE
== Seq_code_ncbistdaa
QuerySetUpOptions * BlastQuerySetUpOptionsFree(QuerySetUpOptions *options)
Deallocate memory for QuerySetUpOptions.
double gap_x_dropoff_final
X-dropoff value for the final gapped extension (in bits)
double logK
natural log of K value used in statistics
Definition: blast_stat.h:69
void SetRepeatFilteringDB(const char *db)
Sets the repeat filtering database to use.
static BlastInitialWordParameters * s_GetInitialWordParameters(EBlastProgramType program_number, BLAST_SequenceBlk *query_blk, BlastQueryInfo *query_info, BlastScoreBlk *sbp, const BlastInitialWordOptions *word_options, int subject_length, const BlastHitSavingParameters *hit_params)
low-complexity for nucleotides.
Int4 x_dropoff_max
largest X-drop cutoff across all contexts
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definition: blast_def.h:112
void SetupQueries(TSeqLocVector &queries, BlastQueryInfo *qinfo, BLAST_SequenceBlk **seqblk, EBlastProgramType prog, objects::ENa_strand strand_opt, TSearchMessages &messages)
Populates BLAST_SequenceBlk with sequence data for use in CORE BLAST.
SDustOptions * dustOptions
low-complexity filtering for nucleotides.
void SetDustFiltering(bool val=true)
Parameter block that contains a pointer to BlastHitSavingOptions and the values derived from it...
BOOST_AUTO_TEST_SUITE(psiblast_iteration)
BLAST_SequenceBlk * BlastSequenceBlkFree(BLAST_SequenceBlk *seq_blk)
Deallocate memory for a sequence block.
Definition: blast_util.c:250
static CBlastOptionsHandle * CreateTask(string task, EAPILocality locality=CBlastOptions::eLocal)
Creates an options handle object configured with default options for the requested task...
Int4 query_length
Length of this query, strand or frame.
EBlastProgramType GetProgramType() const
Returns the CORE BLAST notion of program type.
Wrapper structure for different types of BLAST lookup tables.
Definition: lookup_wrap.h:48
double scale_factor
multiplier for all cutoff and dropoff scores
Definition: blast_stat.h:201
objects::ENa_strand GetStrandOption() const
LookupTableOptions * LookupTableOptionsFree(LookupTableOptions *options)
Deallocates memory for LookupTableOptions*.
Boolean is_valid
Determine if this context is valid or not.
The context related information.
Int4 cutoff_small_gap
Cutoff sum score for linked HSPs with small gaps.
static CBlastOptionsHandle * Create(EProgram program, EAPILocality locality=CBlastOptions::eLocal)
Creates an options handle object configured with default options for the requested program...
void CalculateLinkHSPCutoffs(EBlastProgramType program, BlastQueryInfo *query_info, const BlastScoreBlk *sbp, BlastLinkHSPParameters *link_hsp_params, const BlastInitialWordParameters *word_params, Int8 db_length, Int4 subject_length)
Calculates cutoff scores and returns them.
Int2 BlastExtensionOptionsNew(EBlastProgramType program, BlastExtensionOptions **options, Boolean gapped)
Allocate memory for BlastExtensionOptions and fill with default values.
Int4 cutoff_big_gap
Cutoff sum score for linked HSPs with big gaps.
char * GetFilterString() const
Return the filtering string used.
Boolean do_sum_stats
Force sum statistics to be used to combine HSPs, TRUE by default for all ungapped searches and transl...
double gap_prob
Probability of decay for linking HSPs.
void SetQueryCovHspPerc(double p)
Sets QueryCovHspPerc.
Internal auxiliary setup classes/functions for C++ BLAST APIs.
Encapsulates ALL the BLAST algorithm's options.
static CTestObjMgr & Instance()
Definition: test_objmgr.cpp:71
Not yet set.
Definition: blast_types.hpp:57
Protein-Translated nucl.
Definition: blast_types.hpp:61
typedef for the messages for an entire BLAST search, which could be comprised of multiple query seque...
BlastInitialWordParameters * BlastInitialWordParametersFree(BlastInitialWordParameters *parameters)
Deallocate memory for BlastInitialWordParameters.
Definitions which are dependant on the NCBI C++ Object Manager.
static BlastScoreBlk * s_FillScoreBlkWithBadKbp(BlastQueryInfo *query_info)
Uint1 Boolean
bool replacment for C
Definition: ncbi_std.h:92
double K
K value used in statistics.
Definition: blast_stat.h:68
Options needed for initial word finding and processing.
Computed values used as parameters for gapped alignments.
Structure to hold a sequence.
Definition: blast_def.h:242
Wrapper class for LookupTableOptions .
Definition: blast_aux.hpp:264
Options needed to construct a lookup table Also needed: query sequence and query length.
TBlast4Opts * GetBlast4AlgoOpts()
Int4 query_offset
Offset of this query, strand or frame in the concatenated super-query.
Int4 first_context
Index of the first element of the context array.
Parameter block that contains a pointer to BlastInitialWordOptions and the values derived from it...
double GetBestHitScoreEdge() const
Blast_KarlinBlk ** kbp
Karlin-Altschul parameters.
Definition: blast_stat.h:207
Utilities initialize/setup BLAST.
Int4 cutoff_score_max
Raw cutoff score corresponding to the e-value provided by user, cutoff_score must be <= this...
USING_SCOPE(blast)
CRef< CBlastOptions > Clone() const
Explicit deep copy of the Blast options object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:699
The query related information.
static void MakeSomeInvalidKBP(Blast_KarlinBlk **kbp_array, Int4 num, Int4 good_one, BlastQueryInfo *query_info)
Int2 BLAST_GetSuggestedThreshold(EBlastProgramType program_number, const char *matrixName, double *threshold)
Get thresholds for word-finding suggested by Stephen Altschul.
BlastEffectiveLengthsOptions * BlastEffectiveLengthsOptionsFree(BlastEffectiveLengthsOptions *options)
Deallocate memory for BlastEffectiveLengthsOptions*.
double gap_decay_rate
Decay rate for linking HSPs and calculating cutoff scores.
Int4 cutoff_score_min
smallest cutoff score across all contexts
Protein-Protein.
Definition: blast_types.hpp:59
double H
H value used in statistics.
Definition: blast_stat.h:70
Int2 SBlastFilterOptionsNew(SBlastFilterOptions **filter_options, EFilterOptions type)
Allocates memory for SBlastFilterOptions and.
double GetBestHitOverhang() const
void SetFilterString(const char *f, bool clear=true)
Sets FilterString.
CBlastOptions & SetOptions()
Returns a reference to the internal options class which this object is a handle for.
SBlastFilterOptions * SBlastFilterOptionsFree(SBlastFilterOptions *filter_options)
Frees SBlastFilterOptions and all subservient structures.
#define BLASTERR_INVALIDPARAM
Invalid parameter: possible programmer error or pre-condition not met.
Options used for gapped extension These include: a.
void SetFilterString(const char *f, bool clear=true)
static string GetDocumentation(const string &task_name)
Return the documentation for the provided task.
double Lambda
Lambda value used in statistics.
Definition: blast_stat.h:67
signed short Int2
Alias for signed short.
Definition: ncbitype.h:118
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:746
PSIBlastOptions * PSIBlastOptionsFree(PSIBlastOptions *psi_options)
Deallocate PSI BLAST options.
Int4 word_size
Determines the size of the lookup table.
Modified on Mon May 02 17:43:58 2016 by modify_doxy.py rev. 426318