1 //
2 //  hhviterbimatrix.h
3 //
4 //  Created by Martin Steinegger on 19.11.12.
5 //  Copyright (c) 2012 -. All rights reserved.
6 //
7 
8 #ifndef HHVITERBIMATRIX_h
9 #define HHVITERBIMATRIX_h
10 
11 #include "hhutil.h"
12 #include "simd.h"
13 #include "hhhmmsimd.h"
14 
15 /* a=target variable, b=bit number to act upon 0-n */
16 #define BIT_SET(a,b) ((a) |= (1<<(b)))
17 #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
18 #define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
19 #define BIT_CHECK(a,b) ((a) & (1<<(b)))
20 
21 /* x=target variable, y=mask */
22 #define BITMASK_SET(x,y) ((x) |= (y))
23 #define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
24 #define BITMASK_FLIP(x,y) ((x) ^= (y))
25 #define BITMASK_CHECK(x,y) ((x) & (y))
26 
27 
28 
29 class ViterbiMatrix {
30 public:
31 
32     // Constructor (only set pointers to NULL)
33     ViterbiMatrix();
34     ~ViterbiMatrix();
35     const static char STOP=0;
36     const static char MM=2;
37     const static char GD=3;
38     const static char IM=4;
39     const static char DG=5;
40     const static char MI=6;
41     const static bool GD_MM=true;
42     const static bool GD_OTHER=false;
43     const static bool IM_MM=true;
44     const static bool IM_OTHER=false;
45     const static bool DG_MM=true;
46     const static bool DG_OTHER=false;
47     const static bool MI_MM=true;
48     const static bool MI_OTHER=false;
49 
50 
51     unsigned char * getRow(int row);
52     void AllocateBacktraceMatrix(int Nq, int Nt);
53     void DeleteBacktraceMatrix();
54 
55     bool getCellOff(int row,int col,int elem);
56     bool getMatIns(int row,int col,int elem);
57     bool getGapDel(int row,int col,int elem);
58     bool getInsMat(int row,int col,int elem);
59     bool getDelGap(int row,int col,int elem);
60     int  getMatMat(int row,int col,int elem);
61 
62     void setCellOff(int row,int col,int elem,bool value);
63     void setMatIns(int row,int col,int elem,bool value);
64     void setDelGap(int row,int col,int elem,bool value);
65     void setInsMat(int row,int col,int elem,bool value);
66     void setGapDel(int row,int col,int elem,bool value);
67     void setMatMat(int row,int col,int elem,unsigned char value);
68 
69     bool hasCellOff();
70     void setCellOff(bool value);
71 
72     void printCellOff(int row_size,int col_size,int elem);
73 
74 private:
75     //CO	MI	DG	IM	GD	MM
76     //1     1	1	1	1	1	1	1
77     unsigned char ** bCO_MI_DG_IM_GD_MM_vec;
78     // flag to indecated if cellOff is activ or not
79     bool cellOff;
80 
81     int max_query_length;
82     int max_template_length;
83 
84 };
85 
86 #include "hhviterbimatrix-inl.h"
87 
88 
89 #endif
90