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

Go to the SVN repository for this file.

1 /* $Id: optionshandle_unit_test.cpp 99155 2023-02-21 14:20:29Z fongah2 $
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 * Author: Christiam Camacho
27 *
28 * File Description:
29 * Unit test module for the blast options handle class
30 *
31 * ===========================================================================
32 */
33 #include <ncbi_pch.hpp>
34 #include <corelib/test_boost.hpp>
35 
47 
48 #include "test_objmgr.hpp"
49 
50 #ifdef NCBI_OS_IRIX
51 #include <stdlib.h>
52 #else
53 #include <cstdlib>
54 #endif
55 
56 // template function to invoke mutator/accessor (setter/getter) member
57 // functions on classes derived from the class BC and verifies the assignment
58 // using BOOST_REQUIRE_EQUAL
59 template <class BC, class T>
61  void (BC::*mutator)(T),
62  T (BC::*accessor)(void) const,
63  T& expected_value)
64 {
65 # define CALL_MEMBER_FUNCTION(obj, membFnPtr) ((obj).*(membFnPtr))
66 
67  CALL_MEMBER_FUNCTION(obj, mutator)(expected_value);
68  T actual_value = CALL_MEMBER_FUNCTION(obj, accessor)();
69  BOOST_REQUIRE_EQUAL(expected_value, actual_value);
70 }
71 
72 using namespace std;
73 using namespace ncbi;
74 using namespace ncbi::blast;
75 
78  // Use a randomly chosen program to ensure all derived classes support
79  // these methods. Addition and subtraction of one ensures that the
80  // results is not zero (eBlastNotSet).
81  EProgram p = (EProgram) (1 + rand() % ((int)eBlastProgramMax - 1));
82  m_OptsHandle = CBlastOptionsFactory::Create(p);
83  }
84  ~UniversalOptiosHandleFixture() { delete m_OptsHandle;}
85 
87 };
88 
89 // Test the "universal" BLAST optins (apply to all programs)
90 // TLM - CBlastOptionsHandleTest
91 
92 BOOST_FIXTURE_TEST_CASE(Set_Get_MaskAtHash_Universal, UniversalOptiosHandleFixture) {
93  bool value = true;
94 
95  VerifyMutatorAccessor<CBlastOptionsHandle, bool>
96  (*m_OptsHandle,
99  value);
100 }
101 
102 BOOST_FIXTURE_TEST_CASE(Set_Get_GapXDropoff_Universal, UniversalOptiosHandleFixture) {
103  double value = 10.5;
104 
105  VerifyMutatorAccessor<CBlastOptionsHandle, double>
106  (*m_OptsHandle,
109  value);
110 }
111 
113  double value = 10.5;
114 
115  VerifyMutatorAccessor<CBlastOptionsHandle, double>
116  (*m_OptsHandle,
119  value);
120 }
121 
122 BOOST_FIXTURE_TEST_CASE(Set_Get_HitlistSize_Universal, UniversalOptiosHandleFixture) {
123  int value = 100;
124 
125  VerifyMutatorAccessor<CBlastOptionsHandle, int>
126  (*m_OptsHandle,
129  value);
130 }
131 
132 BOOST_FIXTURE_TEST_CASE(Set_Get_MaxNumHspPerSequence_Universal, UniversalOptiosHandleFixture) {
133  int value = 100;
134 
135  VerifyMutatorAccessor<CBlastOptionsHandle, int>
136  (*m_OptsHandle,
139  value);
140 }
141 
142 BOOST_FIXTURE_TEST_CASE(Set_Get_EvalueThreshold_Universal, UniversalOptiosHandleFixture) {
143  double value = -10.5;
144 
145  VerifyMutatorAccessor<CBlastOptionsHandle, double>
146  (*m_OptsHandle,
149  value);
150 }
151 
152 BOOST_FIXTURE_TEST_CASE(Set_Get_CutoffScore_Universal, UniversalOptiosHandleFixture) {
153  int value = -10;
154 
155  VerifyMutatorAccessor<CBlastOptionsHandle, int>
156  (*m_OptsHandle,
159  value);
160 }
161 
162 BOOST_FIXTURE_TEST_CASE(Set_Get_PercentIdentity_Universal, UniversalOptiosHandleFixture) {
163  double value = 1.5;
164 
165  VerifyMutatorAccessor<CBlastOptionsHandle, double>
166  (*m_OptsHandle,
169  value);
170 }
171 
173  bool value = false;
174 
175  VerifyMutatorAccessor<CBlastOptionsHandle, bool>
176  (*m_OptsHandle,
179  value);
180 }
181 
183  int value = 20;
184 
185  VerifyMutatorAccessor<CBlastOptionsHandle, int>
186  (*m_OptsHandle,
189  value);
190 }
191 
192 // Test creation of BlastOptionsHandle.
193 // TLM - CBlastOptionsCreateTaskTest
194 
195 BOOST_AUTO_TEST_CASE(BlastnTest) {
198  dynamic_cast<CBlastNucleotideOptionsHandle*> (handle);
199  BOOST_REQUIRE(opts != NULL);
200  BOOST_REQUIRE_EQUAL(2, opts->GetMatchReward());
201  delete handle;
202 }
203 
204 BOOST_AUTO_TEST_CASE(BlastnShortTest) {
205  CBlastOptionsHandle* handle = CBlastOptionsFactory::CreateTask("blastn-short");
207  dynamic_cast<CBlastNucleotideOptionsHandle*> (handle);
208  BOOST_REQUIRE(opts != NULL);
209  BOOST_REQUIRE_EQUAL(1, opts->GetMatchReward());
210  BOOST_REQUIRE_EQUAL(7, opts->GetWordSize());
211  delete handle;
212 }
213 
214 BOOST_AUTO_TEST_CASE(MegablastTest) {
217  dynamic_cast<CBlastNucleotideOptionsHandle*> (handle);
218  BOOST_REQUIRE(opts != NULL);
219  BOOST_REQUIRE_EQUAL(1, opts->GetMatchReward());
220  delete handle;
221 }
222 
223 BOOST_AUTO_TEST_CASE(DCMegablastTest) {
224  CBlastOptionsHandle* handle = CBlastOptionsFactory::CreateTask("dc-megablast");
226  dynamic_cast<CDiscNucleotideOptionsHandle*> (handle);
227  BOOST_REQUIRE(opts != NULL);
228  BOOST_REQUIRE_EQUAL(2, opts->GetMatchReward());
229  BOOST_REQUIRE_EQUAL(18, (int) opts->GetTemplateLength());
230  delete handle;
231 }
232 
233 BOOST_AUTO_TEST_CASE(CaseSensitiveTest) {
236  dynamic_cast<CBlastNucleotideOptionsHandle*> (handle);
237  BOOST_REQUIRE(opts != NULL);
238  delete handle;
239 }
240 
241 BOOST_AUTO_TEST_CASE(BadNameTest) {
242  CBlastOptionsHandle* handle = NULL;
243  BOOST_CHECK_THROW(handle = CBlastOptionsFactory::CreateTask("mega"),
244  CBlastException);
246  dynamic_cast<CBlastNucleotideOptionsHandle*> (handle);
247  BOOST_REQUIRE(opts == NULL);
248  delete handle;
249 }
250 
251 BOOST_AUTO_TEST_CASE(BlastpTest) {
254  dynamic_cast<CBlastAdvancedProteinOptionsHandle*> (handle);
255  BOOST_REQUIRE(opts != NULL);
256  BOOST_REQUIRE(!strcmp("BLOSUM62", opts->GetMatrixName()));
257  BOOST_REQUIRE_EQUAL(3, opts->GetWordSize());
258  delete handle;
259 }
260 
261 BOOST_AUTO_TEST_CASE(BlastpFastTest) {
262  CBlastOptionsHandle* handle = CBlastOptionsFactory::CreateTask("blastp-fast");
264  dynamic_cast<CBlastAdvancedProteinOptionsHandle*> (handle);
265  BOOST_REQUIRE(opts != NULL);
266  const CBlastOptions& kOpts = opts->GetOptions();
267  BOOST_REQUIRE(!strcmp("BLOSUM62", kOpts.GetMatrixName()));
268  BOOST_REQUIRE_EQUAL(5, kOpts.GetWordSize());
269  BOOST_REQUIRE_EQUAL(eCompressedAaLookupTable, kOpts.GetLookupTableType());
270  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP_FAST, kOpts.GetWordThreshold());
271  delete handle;
272 }
273 
274 BOOST_AUTO_TEST_CASE(BlastpLookupTableType) {
277  dynamic_cast<CBlastAdvancedProteinOptionsHandle*> (handle);
278  const CBlastOptions& kOpts = opts->GetOptions();
279  BOOST_REQUIRE_EQUAL(eAaLookupTable, kOpts.GetLookupTableType());
280  opts->SetWordSize(6);
281  BOOST_REQUIRE_EQUAL(eCompressedAaLookupTable, kOpts.GetLookupTableType());
282  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP_WD_SZ_6, kOpts.GetWordThreshold());
283  opts->SetWordSize(2);
284  BOOST_REQUIRE_EQUAL(eAaLookupTable, kOpts.GetLookupTableType());
285  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP, kOpts.GetWordThreshold());
286  opts->SetWordSize(5);
287  BOOST_REQUIRE_EQUAL(eCompressedAaLookupTable, kOpts.GetLookupTableType());
288  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP_FAST, kOpts.GetWordThreshold());
289  opts->SetWordSize(3);
290  BOOST_REQUIRE_EQUAL(eAaLookupTable, kOpts.GetLookupTableType());
291  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP, kOpts.GetWordThreshold());
292  opts->SetWordSize(7);
293  BOOST_REQUIRE_EQUAL(eCompressedAaLookupTable, kOpts.GetLookupTableType());
294  BOOST_REQUIRE_EQUAL(BLAST_WORD_THRESHOLD_BLASTP_WD_SZ_7, kOpts.GetWordThreshold());
295 }
296 
297 BOOST_AUTO_TEST_CASE(BlastpShortTest) {
298  CBlastOptionsHandle* handle = CBlastOptionsFactory::CreateTask("blastp-short");
300  dynamic_cast<CBlastAdvancedProteinOptionsHandle*> (handle);
301  BOOST_REQUIRE(opts != NULL);
302  BOOST_REQUIRE(!strcmp("PAM30", opts->GetMatrixName()));
303  BOOST_REQUIRE_EQUAL(2, opts->GetWordSize());
304  delete handle;
305 }
306 
307 BOOST_AUTO_TEST_CASE(BlastxTest) {
309  CBlastxOptionsHandle* opts =
310  dynamic_cast<CBlastxOptionsHandle*> (handle);
311  BOOST_REQUIRE(opts != NULL);
312  BOOST_REQUIRE(!strcmp("BLOSUM62", opts->GetMatrixName()));
313  BOOST_REQUIRE_EQUAL(3, opts->GetWordSize());
314  delete handle;
315 }
316 
317 BOOST_AUTO_TEST_CASE(TblastnTest) {
319  CTBlastnOptionsHandle* opts =
320  dynamic_cast<CTBlastnOptionsHandle*> (handle);
321  BOOST_REQUIRE(opts != NULL);
322  BOOST_REQUIRE(!strcmp("BLOSUM62", opts->GetMatrixName()));
323  BOOST_REQUIRE_EQUAL(3, opts->GetWordSize());
324  delete handle;
325 }
326 
327 BOOST_AUTO_TEST_CASE(TblastxTest) {
329  CTBlastxOptionsHandle* opts =
330  dynamic_cast<CTBlastxOptionsHandle*> (handle);
331  BOOST_REQUIRE(opts != NULL);
332  BOOST_REQUIRE(!strcmp("BLOSUM62", opts->GetMatrixName()));
333  BOOST_REQUIRE_EQUAL(3, opts->GetWordSize());
334  delete handle;
335 }
336 
337 BOOST_AUTO_TEST_CASE(KBlastpTest) {
340  dynamic_cast<CBlastpKmerOptionsHandle*> (handle);
341  BOOST_REQUIRE(opts != NULL);
342  BOOST_REQUIRE_EQUAL(1, opts->GetMinHits());
343  BOOST_REQUIRE_EQUAL(1000, opts->GetCandidateSeqs());
344  BOOST_REQUIRE(!strcmp("BLOSUM62", opts->GetMatrixName()));
345  delete handle;
346 }
347 
350  m_OptsHandle = new CBlastProteinOptionsHandle();
351  }
352  ~ProteinOptiosHandleFixture() { delete m_OptsHandle;}
353 
355 };
356 
357 
358 // Protein options.
359 // TLM - CBlastProtOptionsHandleTest
360 
361 BOOST_FIXTURE_TEST_CASE(Set_Get_WordThreshold_Protein, ProteinOptiosHandleFixture) {
362  double value = 15;
363 
364  VerifyMutatorAccessor<CBlastProteinOptionsHandle, double>
365  (*m_OptsHandle,
368  value);
369 }
370 
372  int value = 5;
373 
374  VerifyMutatorAccessor<CBlastProteinOptionsHandle, int>
375  (*m_OptsHandle,
378  value);
379 }
380 
382  int value = 50;
383 
384  VerifyMutatorAccessor<CBlastProteinOptionsHandle, int>
385  (*m_OptsHandle,
388  value);
389 }
390 
392  double value = 26.2;
393 
394  VerifyMutatorAccessor<CBlastProteinOptionsHandle, double>
395  (*m_OptsHandle,
398  value);
399 }
400 
401 BOOST_FIXTURE_TEST_CASE(Set_Get_GapXDropoffFinal_Protein, ProteinOptiosHandleFixture) {
402  double value = 26.2;
403 
404  VerifyMutatorAccessor<CBlastProteinOptionsHandle, double>
405  (*m_OptsHandle,
408  value);
409 }
410 
412  Int8 value = 1000000;
413 
414  VerifyMutatorAccessor<CBlastProteinOptionsHandle, Int8>
415  (*m_OptsHandle,
418  value);
419 }
420 
422  unsigned int value = 0x1<<16;
423 
424  VerifyMutatorAccessor<CBlastProteinOptionsHandle, unsigned int>
425  (*m_OptsHandle,
428  value);
429 }
430 
431 BOOST_FIXTURE_TEST_CASE(Set_Get_EffectiveSearchSpace_Protein, ProteinOptiosHandleFixture) {
432  Int8 value = 1000000;
433 
434  VerifyMutatorAccessor<CBlastProteinOptionsHandle, Int8>
435  (*m_OptsHandle,
438  value);
439 }
440 
441 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFiltering_Protein, ProteinOptiosHandleFixture) {
442  bool value = true;
443 
444  VerifyMutatorAccessor<CBlastProteinOptionsHandle, bool>
445  (*m_OptsHandle,
448  value);
449 }
450 
451 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFilteringWindow_Protein, ProteinOptiosHandleFixture) {
452  int value = 26;
453 
454  VerifyMutatorAccessor<CBlastProteinOptionsHandle, int>
455  (*m_OptsHandle,
458  value);
459 }
460 
461 BOOST_FIXTURE_TEST_CASE(Get_SegWindowWithSegOptionsUnallocated_Protein, ProteinOptiosHandleFixture) {
462 
463  m_OptsHandle->SetSegFiltering(false); // turn off SEG filtering.
464  // the following call should turn it on again.
465  int value = m_OptsHandle->GetSegFilteringWindow();
466  BOOST_REQUIRE(value < 0);
467 }
468 
469 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFilteringLocut_Protein, ProteinOptiosHandleFixture) {
470  double value = 1.7;
471 
472  VerifyMutatorAccessor<CBlastProteinOptionsHandle, double>
473  (*m_OptsHandle,
476  value);
477 }
478 
479 BOOST_FIXTURE_TEST_CASE(Get_SegLocutWithSegOptionsUnallocated_Protein, ProteinOptiosHandleFixture) {
480 
481  m_OptsHandle->SetSegFiltering(false); // turn off SEG filtering.
482  // the following call should turn it on again.
483  double value = m_OptsHandle->GetSegFilteringLocut();
484  BOOST_REQUIRE(value < 0);
485 }
486 
487 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFilteringHicut_Protein, ProteinOptiosHandleFixture) {
488  double value = 3.7;
489 
490  VerifyMutatorAccessor<CBlastProteinOptionsHandle, double>
491  (*m_OptsHandle,
494  value);
495 }
496 
497 BOOST_FIXTURE_TEST_CASE(Get_SegHicutWithSegOptionsUnallocated_Protein, ProteinOptiosHandleFixture) {
498 
499  m_OptsHandle->SetSegFiltering(false); // turn off SEG filtering.
500  // the following call should turn it on again.
501  double value = m_OptsHandle->GetSegFilteringHicut();
502  BOOST_REQUIRE(value < 0);
503 }
504 
506  const char* value = "dummy matrix";
507 
508  VerifyMutatorAccessor<CBlastProteinOptionsHandle, const char*>
509  (*m_OptsHandle,
512  value);
513 }
514 
515 BOOST_FIXTURE_TEST_CASE(Set_Get_GapOpeningCost_Protein, ProteinOptiosHandleFixture) {
516  int value = 150;
517 
518  VerifyMutatorAccessor<CBlastProteinOptionsHandle, int>
519  (*m_OptsHandle,
522  value);
523 }
524 
525 BOOST_FIXTURE_TEST_CASE(Set_Get_GapExtensionCost_Protein, ProteinOptiosHandleFixture) {
526  int value = 150;
527 
528  VerifyMutatorAccessor<CBlastProteinOptionsHandle, int>
529  (*m_OptsHandle,
532  value);
533 }
534 
537  m_OptsHandle = new CPSIBlastOptionsHandle();
538  }
539  ~PSIBlastOptiosHandleFixture() { delete m_OptsHandle;}
540 
542 };
543 
544 
545 // PSI-BLAST options
546 // TLM - CPSIBlastOptionsHandleTest
547 
548 BOOST_FIXTURE_TEST_CASE(Set_Get_WordThreshold_PSIBlast, PSIBlastOptiosHandleFixture) {
549  double value = 15;
550 
551  VerifyMutatorAccessor<CPSIBlastOptionsHandle, double>
552  (*m_OptsHandle,
555  value);
556 }
557 
558 BOOST_FIXTURE_TEST_CASE(Set_Get_InclusionThreshold_PSIBlast, PSIBlastOptiosHandleFixture) {
559  double value = 0.05;
560 
561  VerifyMutatorAccessor<CPSIBlastOptionsHandle, double>
562  (*m_OptsHandle,
565  value);
566 }
567 
568 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFiltering_PSIBlast, PSIBlastOptiosHandleFixture) {
569  bool value = true;
570 
571  VerifyMutatorAccessor<CPSIBlastOptionsHandle, bool>
572  (*m_OptsHandle,
575  value);
576 }
577 
578 BOOST_FIXTURE_TEST_CASE(Set_Get_SegFilteringWindow_PSIBlast, PSIBlastOptiosHandleFixture) {
579  int value = 26;
580 
581  VerifyMutatorAccessor<CPSIBlastOptionsHandle, int>
582  (*m_OptsHandle,
585  value);
586 }
587 
590  m_OptsHandle = new CBlastAdvancedProteinOptionsHandle();
591  }
592  ~AdvancedProteinOptionsHandleFixture() { delete m_OptsHandle;}
593 
595 };
596 
597 // Advanced Protein options
598 // TLM - CBlastAdvancedProtOptionsHandleTest
599 BOOST_FIXTURE_TEST_CASE(Set_Get_CompositionBasedStats_AdvancedProtein, AdvancedProteinOptionsHandleFixture) {
601 
604  (*m_OptsHandle,
607  value);
608 }
609 
610 BOOST_FIXTURE_TEST_CASE(Set_Get_SmithWatermanMode_AdvancedProtein, AdvancedProteinOptionsHandleFixture) {
611  bool value = true;
612 
613  VerifyMutatorAccessor<CBlastAdvancedProteinOptionsHandle, bool>
614  (*m_OptsHandle,
617  value);
618 }
619 
622  m_OptsHandle = new CBlastNucleotideOptionsHandle();
623  }
624  ~BlastNuclOptionsHandleFixture() { delete m_OptsHandle;}
625 
627 };
628 
629 // Nucleotide blast
630 // TLM - CBlastNuclOptionsHandleTest
631 
632 BOOST_FIXTURE_TEST_CASE(Set_Get_LookupTableType_BlastNucl, BlastNuclOptionsHandleFixture) {
634 
635  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, ELookupTableType>
636  (*m_OptsHandle,
639  value);
640 }
641 
643  int value = 23;
644 
645  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
646  (*m_OptsHandle,
649  value);
650 }
651 
652 BOOST_FIXTURE_TEST_CASE(Set_Get_StrandOption_BlastNucl, BlastNuclOptionsHandleFixture) {
654  m_OptsHandle->SetStrandOption(value);
655  objects::ENa_strand actual_value = m_OptsHandle->GetStrandOption();
656  BOOST_REQUIRE_EQUAL((int)value, (int)actual_value);
657 }
658 
660  int value = 50;
661 
662  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
663  (*m_OptsHandle,
666  value);
667 }
668 
670  double value = 40;
671 
672  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, double>
673  (*m_OptsHandle,
676  value);
677 }
678 
679 BOOST_FIXTURE_TEST_CASE(Set_Get_GapXDropoffFinal_BlastNucl, BlastNuclOptionsHandleFixture) {
680  double value = 100;
681 
682  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, double>
683  (*m_OptsHandle,
686  value);
687 }
688 
689 BOOST_FIXTURE_TEST_CASE(Set_Get_GapExtnAlgorithm_BlastNucl, BlastNuclOptionsHandleFixture) {
691  const int kGapOpen = 7;
692  const int kGapExtend = 3;
693 
694  m_OptsHandle->SetGapOpeningCost(kGapOpen);
695  m_OptsHandle->SetGapExtensionCost(kGapExtend);
696 
697  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, EBlastPrelimGapExt>
698  (*m_OptsHandle,
701  value);
702 
703  BOOST_REQUIRE_EQUAL(kGapOpen, m_OptsHandle->GetGapOpeningCost());
704  BOOST_REQUIRE_EQUAL(kGapExtend, m_OptsHandle->GetGapExtensionCost());
705 
707  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, EBlastPrelimGapExt>
708  (*m_OptsHandle,
711  value);
712 
713  BOOST_REQUIRE_EQUAL(kGapOpen, m_OptsHandle->GetGapOpeningCost());
714  BOOST_REQUIRE_EQUAL(kGapExtend, m_OptsHandle->GetGapExtensionCost());
715 
716 }
717 
718 BOOST_FIXTURE_TEST_CASE(Set_Get_GapTracebackAlgorithm_BlastNucl, BlastNuclOptionsHandleFixture) {
720  const int kGapOpen = 7;
721  const int kGapExtend = 3;
722 
723  m_OptsHandle->SetGapOpeningCost(kGapOpen);
724  m_OptsHandle->SetGapExtensionCost(kGapExtend);
725 
726  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, EBlastTbackExt>
727  (*m_OptsHandle,
730  value);
731 
732  BOOST_REQUIRE_EQUAL(kGapOpen, m_OptsHandle->GetGapOpeningCost());
733  BOOST_REQUIRE_EQUAL(kGapExtend, m_OptsHandle->GetGapExtensionCost());
734 
735 }
736 
738  int value = 2;
739 
740  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
741  (*m_OptsHandle,
744  value);
745 }
746 
747 BOOST_FIXTURE_TEST_CASE(Set_Get_MismatchPenalty_BlastNucl, BlastNuclOptionsHandleFixture) {
748  int value = -3;
749 
750  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
751  (*m_OptsHandle,
754  value);
755 }
756 
758  const char* value = "MYNAMATRIX";
759 
760  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, const char*>
761  (*m_OptsHandle,
764  value);
765 }
766 
767 BOOST_FIXTURE_TEST_CASE(Set_Get_GapOpeningCost_BlastNucl, BlastNuclOptionsHandleFixture) {
768  int value = 4;
769 
770  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
771  (*m_OptsHandle,
774  value);
775 }
776 
777 BOOST_FIXTURE_TEST_CASE(Set_Get_GapExtensionCost_BlastNucl, BlastNuclOptionsHandleFixture) {
778  int value = 1;
779 
780  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
781  (*m_OptsHandle,
784  value);
785 }
786 
787 BOOST_FIXTURE_TEST_CASE(Set_Get_EffectiveSearchSpace_BlastNucl, BlastNuclOptionsHandleFixture) {
788  Int8 value = 20000000;
789 
790  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, Int8>
791  (*m_OptsHandle,
794  value);
795 }
796 
797 BOOST_FIXTURE_TEST_CASE(Set_Get_DustFiltering_BlastNucl, BlastNuclOptionsHandleFixture) {
798  bool value = true;
799 
800  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, bool>
801  (*m_OptsHandle,
804  value);
805 }
806 
807 BOOST_FIXTURE_TEST_CASE(Set_Get_DustFilteringLevel_BlastNucl, BlastNuclOptionsHandleFixture) {
808  int value = 20;
809 
810  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
811  (*m_OptsHandle,
814  value);
815 }
816 
817 BOOST_FIXTURE_TEST_CASE(Get_DustLevelWithDustOptionsUnallocated_BlastNucl, BlastNuclOptionsHandleFixture) {
818 
819  m_OptsHandle->SetDustFiltering(false); // turn off dust filtering.
820  // the following call should turn it on again.
821  int value = m_OptsHandle->GetDustFilteringLevel();
822  BOOST_REQUIRE(value < 0);
823 }
824 
825 BOOST_FIXTURE_TEST_CASE(Set_Get_DustFilteringWindow_BlastNucl, BlastNuclOptionsHandleFixture) {
826  int value = 21;
827 
828  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
829  (*m_OptsHandle,
832  value);
833 }
834 
835 BOOST_FIXTURE_TEST_CASE(Get_DustWindowWithDustOptionsUnallocated_BlastNucl, BlastNuclOptionsHandleFixture) {
836 
837  m_OptsHandle->SetDustFiltering(false); // turn off dust filtering.
838  // the following call should turn it on again.
839  int value = m_OptsHandle->GetDustFilteringWindow();
840  BOOST_REQUIRE(value < 0);
841 }
842 
843 BOOST_FIXTURE_TEST_CASE(Set_Get_DustFilteringLinker_BlastNucl, BlastNuclOptionsHandleFixture) {
844  int value = 22;
845 
846  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, int>
847  (*m_OptsHandle,
850  value);
851 }
852 
853 BOOST_FIXTURE_TEST_CASE(Get_DustLinkerWithDustOptionsUnallocated_BlastNucl, BlastNuclOptionsHandleFixture) {
854 
855  m_OptsHandle->SetDustFiltering(false); // turn off dust filtering.
856  // the following call should turn it on again.
857  int value = m_OptsHandle->GetDustFilteringLinker();
858  BOOST_REQUIRE(value < 0);
859 }
860 
861 BOOST_FIXTURE_TEST_CASE(Set_Get_RepeatFiltering_BlastNucl, BlastNuclOptionsHandleFixture) {
862  bool value = true;
863 
864  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, bool>
865  (*m_OptsHandle,
868  value);
869 }
870 
871 BOOST_FIXTURE_TEST_CASE(Set_Get_RepeatFilteringDB_BlastNucl, BlastNuclOptionsHandleFixture) {
872  const char* db = "my_repeat_db";
873 
874  VerifyMutatorAccessor<CBlastNucleotideOptionsHandle, const char*>
875  (*m_OptsHandle,
878  db);
879 }
880 
883  m_OptsHandle = new CDiscNucleotideOptionsHandle();
884  }
885  ~DiscNucleotideOptionsHandleFixture() { delete m_OptsHandle;}
886 
888 };
889 
890 
891 // Discontiguous nucleotide blast
892 // TLM - CDiscNuclOptionsHandleTest
893 BOOST_FIXTURE_TEST_CASE(Set_Get_TemplateLength_DiscNucleotide, DiscNucleotideOptionsHandleFixture) {
894  unsigned char value = 18;
895 
896  VerifyMutatorAccessor<CDiscNucleotideOptionsHandle, unsigned char>
897  (*m_OptsHandle,
900  value);
901 }
902 
903 BOOST_FIXTURE_TEST_CASE(Set_Get_TemplateType_DiscNucleotide, DiscNucleotideOptionsHandleFixture) {
904  unsigned char value = 1;
905 
906  VerifyMutatorAccessor<CDiscNucleotideOptionsHandle, unsigned char>
907  (*m_OptsHandle,
910  value);
911 }
912 
914  int value = 12;
915 
916  VerifyMutatorAccessor<CDiscNucleotideOptionsHandle, int>
917  (*m_OptsHandle,
920  value);
921  value = 16;
922  try {
923  m_OptsHandle->SetWordSize(value);
924  } catch (const CBlastException& exptn) {
925  BOOST_REQUIRE(!strcmp("Word size must be 11 or 12 only", exptn.GetMsg().c_str()));
926  }
927 }
928 
929 BOOST_FIXTURE_TEST_CASE(Set_Get_QueryCoverageHspPercentage, BlastNuclOptionsHandleFixture) {
930 
931  int value = m_OptsHandle->GetQueryCovHspPerc();
932  //Test default
933  BOOST_REQUIRE(value == 0);
934  m_OptsHandle->SetQueryCovHspPerc(52);
935  value = m_OptsHandle->GetQueryCovHspPerc();
936  BOOST_REQUIRE(value == 52);
937 }
938 
939 
940 
941 
942 //BOOST_AUTO_TEST_SUITE_END()
943 
944 /*
945 * ===========================================================================
946 *
947 * $Log: optionshandle-cppunit.cpp,v $
948 * Revision 1.32 2008/07/18 14:16:43 camacho
949 * Minor fix to previous commit
950 *
951 * Revision 1.31 2008/07/18 14:05:21 camacho
952 * Irix fixes
953 *
954 * Revision 1.30 2007/10/23 16:00:57 madden
955 * Changes for removal of [SG]etUngappedExtension
956 *
957 * Revision 1.29 2007/07/25 12:41:39 madden
958 * Accomodates changes to blastn type defaults
959 *
960 * Revision 1.28 2007/07/10 13:52:40 madden
961 * tests of CBlastOptionsFactory::CreateTask (CBlastOptionsCreateTaskTest)
962 *
963 * Revision 1.27 2007/04/05 13:00:20 madden
964 * 2nd arg to SetFilterString
965 *
966 * Revision 1.26 2007/03/07 19:20:41 papadopo
967 * make lookup table threshold a double
968 *
969 * Revision 1.25 2007/02/14 20:18:01 papadopo
970 * remove SetFullByteScan and discontig. megablast with stride 4
971 *
972 * Revision 1.24 2007/02/08 17:13:49 papadopo
973 * change enum value
974 *
975 * Revision 1.23 2006/12/19 16:38:23 madden
976 * Fix if filtering option is NULL
977 *
978 * Revision 1.22 2006/12/13 13:52:35 madden
979 * Add CPSIBlastOptionsHandleTest
980 *
981 * Revision 1.21 2006/11/28 13:29:30 madden
982 * Ensure that eBlastNotSet is never chosen as a program
983 *
984 * Revision 1.20 2006/11/21 17:47:36 papadopo
985 * use enum for lookup table type
986 *
987 * Revision 1.19 2006/06/12 17:23:41 madden
988 * Remove [GS]etMatrixPath
989 *
990 * Revision 1.18 2006/06/05 13:34:05 madden
991 * Changes to remove [GS]etMatrixPath and use callback instead
992 *
993 * Revision 1.17 2006/01/23 19:57:52 camacho
994 * Allow new varieties of composition based statistics
995 *
996 * Revision 1.16 2005/12/22 14:17:00 papadopo
997 * remove variable wordsize test
998 *
999 * Revision 1.15 2005/08/01 12:55:28 madden
1000 * Check that SetGapTracebackAlgorithm and SetGapExtnAlgorithm do not change gap costs
1001 *
1002 * Revision 1.14 2005/05/24 19:16:22 camacho
1003 * Register advanced options handle tests with a unique name
1004 *
1005 * Revision 1.13 2005/05/24 18:48:25 madden
1006 * Add CBlastAdvancedProtOptionsHandleTest
1007 *
1008 * Revision 1.12 2005/03/04 17:20:45 bealer
1009 * - Command line option support.
1010 *
1011 * Revision 1.11 2005/03/02 22:39:10 camacho
1012 * Remove deprecated methods
1013 *
1014 * Revision 1.10 2005/02/24 13:48:58 madden
1015 * Add tests of getters and setters for structured filtering options
1016 *
1017 * Revision 1.9 2005/01/10 14:57:40 madden
1018 * Add Set_Get_FullByteScan for discontiguous megablast
1019 *
1020 * Revision 1.8 2005/01/10 14:04:30 madden
1021 * Removed calls to methods that no longer exist
1022 *
1023 * Revision 1.7 2004/12/28 13:37:48 madden
1024 * Use an int rather than a short for word size
1025 *
1026 * Revision 1.6 2004/08/30 16:54:29 dondosha
1027 * Added unit tests for nucleotide and discontiguous options handles setters and getters
1028 *
1029 * Revision 1.5 2004/07/06 19:40:11 camacho
1030 * Remove extra qualification of assertion_traits
1031 *
1032 * Revision 1.4 2004/03/10 15:54:06 madden
1033 * Changes for rps options handle
1034 *
1035 * Revision 1.3 2004/02/20 23:20:37 camacho
1036 * Remove undefs.h
1037 *
1038 * Revision 1.2 2003/12/12 16:16:33 camacho
1039 * Minor
1040 *
1041 * Revision 1.1 2003/11/26 18:47:13 camacho
1042 * Initial revision. Intended as example of CppUnit framework use
1043 *
1044 *
1045 * ===========================================================================
1046 */
Declares the CBlastAdvancedProteinOptionsHandle class.
Definitions used throughout BLAST.
Declares the CBlastNucleotideOptionsHandle class.
EBlastPrelimGapExt
The algorithm to be used for preliminary gapped extensions.
@ eDynProgScoreOnly
standard affine gapping
@ eGreedyScoreOnly
Greedy extension (megaBlast)
#define BLAST_WORD_THRESHOLD_BLASTP_WD_SZ_6
#define BLAST_WORD_THRESHOLD_BLASTP_FAST
#define BLAST_WORD_THRESHOLD_BLASTP_WD_SZ_7
#define BLAST_WORD_THRESHOLD_BLASTP
neighboring word score thresholds; a threshold of zero means that only query and subject words that m...
EBlastTbackExt
The algorithm to be used for final gapped extensions with traceback.
@ eDynProgTbck
standard affine gapping
ELookupTableType
Types of the lookup table.
@ eNaLookupTable
blastn lookup table
@ eAaLookupTable
standard protein (blastp) lookup table
@ eCompressedAaLookupTable
compressed alphabet (blastp) lookup table
Declares the CBlastOptionsHandle and CBlastOptionsFactory classes.
Declares the CBlastProteinOptionsHandle class.
EProgram
This enumeration is to evolve into a task/program specific list that specifies sets of default parame...
Definition: blast_types.hpp:56
@ eBlastProgramMax
Undefined program.
Definition: blast_types.hpp:75
Declares the CBlastpKmerOptionsHandle class.
Declares the CBlastxOptionsHandle class.
Handle to the Advanced BLASTP options.
Defines BLAST error codes (user errors included)
Handle to the nucleotide-nucleotide options to the BLAST algorithm.
Handle to the options to the BLAST algorithm.
Encapsulates ALL the BLAST algorithm's options.
Handle to the protein-protein options to the BLAST algorithm.
Handle to the KMER BLASTP options.
Handle to the translated nucleotide-protein options to the BLAST algorithm.
Handle to the nucleotide-nucleotide options to the discontiguous BLAST algorithm.
Handle to the protein-protein options to the BLAST algorithm.
Handle to the protein-translated nucleotide options to the BLAST algorithm.
Handle to the translated nucleotide-translated nucleotide options to the BLAST algorithm.
ECompoAdjustModes
An collection of constants that specify all permissible modes of composition adjustment.
@ eNoCompositionBasedStats
Don't use composition based statistics.
#define T(s)
Definition: common.h:230
Declares the CDiscNucleotideOptionsHandle class.
int GetDustFilteringLinker() const
Get linker parameter for dust.
void SetGapExtensionCost(int e)
Sets GapExtensionCost.
double GetXDropoff() const
Returns XDropoff.
void SetLookupTableType(ELookupTableType type)
Sets LookupTableType.
void SetEvalueThreshold(double eval)
Sets EvalueThreshold.
int GetGapExtensionCost() const
Returns GapExtensionCost.
Int8 GetEffectiveSearchSpace() const
Returns EffectiveSearchSpace.
EBlastPrelimGapExt GetGapExtnAlgorithm() const
Returns GapExtnAlgorithm.
void SetWordThreshold(double wt)
Sets WordThreshold.
void SetDustFilteringWindow(int window)
Set window parameter for dust.
double GetGapTrigger() const
Returns GapTrigger.
bool GetSegFiltering() const
Is SEG filtering enabled?
EBlastTbackExt GetGapTracebackAlgorithm() const
Returns GapTracebackAlgorithm.
bool GetDustFiltering() const
Is dust filtering enabled?
void SetDbLength(Int8 len)
Sets DbLength.
bool GetSmithWatermanMode() const
Returns this mode, specifying that smith waterman rather than the normal blast heuristic should be us...
void SetWordSize(int ws)
Sets WordSize.
int GetWordSize() const
Returns WordSize.
void SetMatchReward(int r)
Sets MatchReward.
unsigned char GetTemplateType() const
Returns TemplateType.
void SetDbSeqNum(unsigned int num)
Sets DbSeqNum.
void SetGapTrigger(double g)
Sets GapTrigger.
int GetCandidateSeqs() const
Gets the max number of candidate matches to process with BLAST.
void SetSmithWatermanMode(bool m=false)
Sets this mode, specifying that smith waterman rather than the normal blast heuristic should be used ...
double GetInclusionThreshold() const
Returns InclusionThreshold.
double GetGapXDropoffFinal() const
Returns GapXDropoffFinal.
Int8 GetDbLength() const
Returns DbLength.
int GetMatchReward() const
Returns MatchReward.
void SetGapExtnAlgorithm(EBlastPrelimGapExt algo)
Sets GapExtnAlgorithm.
void SetDustFilteringLinker(int linker)
Set linker parameter for dust.
int GetSegFilteringWindow() const
Get window parameter for seg.
int GetMinHits() const
Returns the number of hits to initiate calculation of Jaccard distance.
void SetEffectiveSearchSpace(Int8 eff)
Sets EffectiveSearchSpace.
void SetGapOpeningCost(int g)
Sets GapOpeningCost.
const char * GetMatrixName() const
Returns MatrixName.
void SetCompositionBasedStats(ECompoAdjustModes mode)
Sets this mode, which mostly specifies whether composition of db sequence is taken into account when ...
double GetXDropoff() const
Returns XDropoff.
unsigned int GetDbSeqNum() const
Returns DbSeqNum.
static CBlastOptionsHandle * Create(EProgram program, EAPILocality locality=CBlastOptions::eLocal)
Creates an options handle object configured with default options for the requested program,...
int GetDustFilteringLevel() const
Get level parameter for dust.
void SetGapTracebackAlgorithm(EBlastTbackExt algo)
Sets GapTracebackAlgorithm.
double GetWordThreshold() const
Returns WordThreshold.
bool GetGappedMode() const
Returns GappedMode.
double GetSegFilteringHicut() const
Get hicut parameter for seg.
void SetMismatchPenalty(int p)
Sets MismatchPenalty.
double GetPercentIdentity() const
Returns PercentIdentity.
void SetMatrixName(const char *matrix)
Sets MatrixName.
void SetRepeatFilteringDB(const char *db)
Enable repeat filtering.
void SetHitlistSize(int s)
Sets HitlistSize.
const char * GetMatrixName() const
Returns MatrixName.
int GetGapExtensionCost() const
Returns GapExtensionCost.
int GetWordSize() const
Returns WordSize.
ECompoAdjustModes GetCompositionBasedStats() const
Returns this mode, which mostly specifies whether composition of db sequence is taken into account wh...
const CBlastOptions & GetOptions() const
Return the object which this object is a handle for.
void SetXDropoff(double x)
Sets XDropoff.
void SetWindowSize(int ws)
Sets WindowSize.
int GetMaxNumHspPerSequence() const
Returns MaxNumHspPerSequence.
bool GetMaskAtHash() const
Returns whether masking should only be done for lookup table creation.
void SetMatrixName(const char *matrix)
Sets MatrixName.
void SetRepeatFiltering(bool val)
Enable repeat filtering.
bool GetRepeatFiltering() const
Is repeat filtering enabled?
double GetWordThreshold() const
Returns WordThreshold.
void SetWordSize(int ws)
Sets WordSize.
void SetTemplateType(unsigned char type)
Sets TemplateType.
void SetGapXDropoffFinal(double x)
Sets GapXDropoffFinal.
int GetCutoffScore() const
Returns CutoffScore.
int GetDustFilteringWindow() const
Get window parameter for dust.
void SetXDropoff(double x)
Sets XDropoff.
void SetCullingLimit(int s)
Sets Culling limit.
void SetGapExtensionCost(int e)
Sets GapExtensionCost.
int GetGapOpeningCost() const
Returns GapOpeningCost.
void SetGapXDropoff(double x)
Sets GapXDropoff.
void SetMaskAtHash(bool m=true)
Sets MaskAtHash.
double GetGapXDropoff() const
Returns GapXDropoff.
const char * GetRepeatFilteringDB() const
Get the repeat filtering database.
ELookupTableType GetLookupTableType() const
Returns LookupTableType.
unsigned char GetTemplateLength() const
Returns TemplateLength.
void SetWordSize(int ws)
Sets WordSize.
ELookupTableType GetLookupTableType() const
int GetGapOpeningCost() const
Returns GapOpeningCost.
void SetSegFilteringWindow(int window)
Set window parameter for seg.
void SetDustFiltering(bool val)
Enable dust filtering.
int GetWindowSize() const
Returns WindowSize.
int GetMismatchPenalty() const
Returns MismatchPenalty.
int GetHitlistSize() const
Returns HitlistSize.
void SetMaxNumHspPerSequence(int m)
Sets MaxNumHspPerSequence.
void SetGappedMode(bool m=true)
Sets GappedMode.
void SetSegFiltering(bool val)
Enable SEG filtering.
void SetTemplateLength(unsigned char length)
Sets TemplateLength.
void SetPercentIdentity(double p)
Sets PercentIdentity.
double GetSegFilteringLocut() const
Get locut parameter for seg.
void SetCutoffScore(int s)
Sets CutoffScore.
void SetDustFilteringLevel(int level)
Set level parameter for dust.
const char * GetMatrixName() const
void SetGapOpeningCost(int g)
Sets GapOpeningCost.
void SetSegFilteringLocut(double locut)
Set locut parameter for seg.
void SetInclusionThreshold(double incthr)
Sets InclusionThreshold.
int GetWordSize() const
static CBlastOptionsHandle * CreateTask(string task, EAPILocality locality=CBlastOptions::eLocal)
Creates an options handle object configured with default options for the requested task,...
void SetSegFilteringHicut(double hicut)
Set hicut parameter for seg.
double GetEvalueThreshold() const
Returns EvalueThreshold.
int GetCullingLimit() const
Returns Culling limit.
#define NULL
Definition: ncbistd.hpp:225
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
Magic spell ;-) needed for some weird compilers... very empiric.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int strcmp(const char *str1, const char *str2)
Definition: odbc_utils.hpp:160
void VerifyMutatorAccessor(BC &obj, void(BC::*mutator)(T), T(BC::*accessor)(void) const, T &expected_value)
BOOST_FIXTURE_TEST_CASE(Set_Get_MaskAtHash_Universal, UniversalOptiosHandleFixture)
#define CALL_MEMBER_FUNCTION(obj, membFnPtr)
BOOST_AUTO_TEST_CASE(BlastnTest)
Declares the CPSIBlastOptionsHandle class.
CBlastAdvancedProteinOptionsHandle * m_OptsHandle
CBlastNucleotideOptionsHandle * m_OptsHandle
CDiscNucleotideOptionsHandle * m_OptsHandle
CPSIBlastOptionsHandle * m_OptsHandle
CBlastProteinOptionsHandle * m_OptsHandle
Declares the CTBlastnOptionsHandle class.
Declares the CTBlastxOptionsHandle class.
Utility stuff for more convenient using of Boost.Test library.
#define BC
Definition: x509_crl.c:589
Modified on Wed Apr 17 13:10:14 2024 by modify_doxy.py rev. 669887