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

Go to the SVN repository for this file.

1 /* $Id: vectorscreen_unit_test.cpp 93625 2021-05-06 15:07:08Z ucko $
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: Jian Ye
27 *
28 * File Description:
29 * Unit test module to test CVecscreen
30 *
31 * ===========================================================================
32 */
33 #include <ncbi_pch.hpp>
34 #define NCBI_BOOST_NO_AUTO_TEST_MAIN
35 #include <corelib/test_boost.hpp>
36 #include <corelib/ncbiexpt.hpp>
37 #include <corelib/ncbiutil.hpp>
38 #include <corelib/ncbistre.hpp>
39 
41 #include <objmgr/scope.hpp>
42 #include <objmgr/util/sequence.hpp>
45 
48 
49 using namespace std;
50 using namespace ncbi;
51 using namespace ncbi::objects;
52 using namespace ncbi::align_format;
53 
54 BOOST_AUTO_TEST_SUITE(vectorscreen)
55 
56 struct CVecscreenTest : public CVecscreen {
57  CVecscreenTest(const CSeq_align_set& seqalign, TSeqPos master_length)
58  : CVecscreen(seqalign, master_length)
59  {}
60 
61  static void x_TestRangeList(CVecscreenTest& vec) {
62  //test the range list
63  BOOST_REQUIRE(vec.m_AlnInfoList.size() == 5);
64  TSeqPos i = 0;
65  TSeqPos from[] = {0, 11, 33, 34, 1008};
66  TSeqPos to[] = {10, 32, 33, 1007, 1056};
67  int type[] = {3, 1, 2, 4, 0};
68 
69  ITERATE(list<CVecscreen::AlnInfo*>, iter, vec.m_AlnInfoList){
70  BOOST_REQUIRE((*iter)->range.GetFrom() == from[i]);
71  BOOST_REQUIRE((*iter)->range.GetTo() == to[i]);
72  BOOST_REQUIRE((*iter)->type == type[i]);
73  i ++;
74  }
75  }
76 
77  static void x_TestSeqalign(CVecscreenTest& vec) {
78  //test the processed seqalign
79  BOOST_REQUIRE(vec.m_FinalSeqalign->Get().size() == 3);
80  int i = 0;
81  TSeqPos from[] = {1008, 11, 18};
82  TSeqPos to[] = {1056, 32, 33};
84  BOOST_REQUIRE((*iter)->GetSeqRange(0).GetFrom() == from[i]);
85  BOOST_REQUIRE((*iter)->GetSeqRange(0).GetTo() == to[i]);
86  i ++;
87  }
88  }
89 
90  static void VecscreenDisplay(void)
91  {
92  CNcbiIfstream is("data/seqalign.vectorscreen");
93  unique_ptr<CObjectIStream> in(CObjectIStream::Open(eSerial_AsnText, is));
95  *in >> *san;
96  const CSeq_annot::TData& data = san->GetData();
97  const CSeq_annot::TData::TAlign& align= data.GetAlign();
99  seqalign->Set() = align;
100  CVecscreenTest vec(*seqalign, 1057);
101  CSeq_align_set actual_aln_list;
103  *(vec.m_SeqalignSetRef));
104  vec.x_MergeSeqalign(actual_aln_list);
105 
106  //test the range list
107  x_TestRangeList(vec);
108 
109  //test the processed seqalign
110  x_TestSeqalign(vec);
111  }
112 };
113 
114 BOOST_AUTO_TEST_CASE(VecscreenDisplay)
115 {
117 }
118 
120 
121 /*
122 * ===========================================================================
123 
124 * ===========================================================================
125 */
126 
BOOST_AUTO_TEST_SUITE_END() static int s_GetSegmentFlags(const CBioseq &bioseq)
static void ExtractSeqalignSetFromDiscSegs(objects::CSeq_align_set &target, const objects::CSeq_align_set &source)
If a Seq-align-set contains Seq-aligns with discontinuous type segments, extract the underlying Seq-a...
Example:
void x_MergeSeqalign(objects::CSeq_align_set &seqalign)
merge overlapping seqalign
list< AlnInfo * > m_AlnInfoList
internal match list
CConstRef< objects::CSeq_align_set > m_SeqalignSetRef
the current seqalign
CRef< objects::CSeq_align_set > m_FinalSeqalign
the processed seqalign
char data[12]
Definition: iconv.c:80
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:195
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
Tdata & Set(void)
Assign a value to data member.
list< CRef< CSeq_align > > Tdata
list< CRef< CSeq_align > > TAlign
Definition: Seq_annot_.hpp:194
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:873
int i
Magic spell ;-) needed for some weird compilers... very empiric.
Defines NCBI C++ exception handling.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
The Object manager core.
BOOST_AUTO_TEST_SUITE(psiblast_iteration)
static void x_TestRangeList(CVecscreenTest &vec)
static void VecscreenDisplay(void)
static void x_TestSeqalign(CVecscreenTest &vec)
CVecscreenTest(const CSeq_align_set &seqalign, TSeqPos master_length)
Definition: type.c:6
Utility stuff for more convenient using of Boost.Test library.
BOOST_AUTO_TEST_CASE(VecscreenDisplay)
Modified on Fri Sep 20 14:57:00 2024 by modify_doxy.py rev. 669887