NCBI C++ ToolKit
Ali.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*
2 * $Id: Ali.hpp 36314 2007-12-18 15:42:22Z chetvern $
3 *
4 * =========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannt warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * =========================================================================
27 *
28 * Author: Boris Kiryutin
29 *
30 * =========================================================================
31 */
32 
33 
34 #ifndef PROSPLIGN_ALI_HPP
35 #define PROSPLIGN_ALI_HPP
36 
37 #include <vector>
38 
40 BEGIN_SCOPE(prosplign)
41 using namespace objects;
42 
44  eMP, //match/mismatch
45  eVP,//vertical gap/frameshift (i.e. in nuc, prot is presented)
46  eHP,//horisontal gap/frameshift (i.e. in prot, nuc is presented)
47  eSP//intron
48 };
49 
50 class CAliPiece {
51 public:
53  int m_len;
54  inline void Init(EAliPieceType t, int len = 0) {
55  m_type = t;
56  m_len = len;
57  }
58 };
59 
60 class CAli {
61 public:
62  vector<CAliPiece> m_ps;
63 
64  CAli();
65  CAli(const vector<pair<int, int> >& igi, bool lgap, bool rgap, const CAli& frali);//adds introns/end gaps
66 };
67 
69 {
70 public:
73  int m_CurLen;
74 
75  CAliCreator(CAli& ali);
76  ~CAliCreator(void);
77  inline void Fini(void)
78  {
79  Clear();
80  reverse(m_ali.m_ps.begin(), m_ali.m_ps.end());
81  }
82  inline void Add(EAliPieceType type, int len)
83  {
84  if(m_CurType != type) {
85  Clear();
86  m_CurType = type;
87  }
88  m_CurLen+=len;
89  }
90 private:
91  inline void Clear(void)
92  {
93  if(m_CurLen) {
94  CAliPiece pc;
95  pc.Init(m_CurType);
96  pc.m_len = m_CurLen;
97  m_ali.m_ps.push_back(pc);
98  }
99  m_CurLen = 0;
100  }
101 };
102 
103 END_SCOPE(prosplign)
105 
106 #endif //PROSPLIGN_ALI_HPP
EAliPieceType
Definition: Ali.hpp:43
@ eMP
Definition: Ali.hpp:44
@ eHP
Definition: Ali.hpp:46
@ eVP
Definition: Ali.hpp:45
@ eSP
Definition: Ali.hpp:47
void Clear(void)
Definition: Ali.hpp:91
CAli & m_ali
Definition: Ali.hpp:71
EAliPieceType m_CurType
Definition: Ali.hpp:72
void Add(EAliPieceType type, int len)
Definition: Ali.hpp:82
int m_CurLen
Definition: Ali.hpp:73
void Fini(void)
Definition: Ali.hpp:77
void Init(EAliPieceType t, int len=0)
Definition: Ali.hpp:54
int m_len
Definition: Ali.hpp:53
EAliPieceType m_type
Definition: Ali.hpp:52
Definition: Ali.hpp:60
vector< CAliPiece > m_ps
Definition: Ali.hpp:62
static int type
Definition: getdata.c:31
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
int len
EIPRangeType t
Definition: ncbi_localip.c:101
Definition: type.c:6
Modified on Fri Sep 20 14:58:09 2024 by modify_doxy.py rev. 669887