1 #ifndef AFFINEALIGNOBJ_H 2 #define AFFINEALIGNOBJ_H 24 enum TracebackType {SS = 0, DM = 1, DA = 2, DB = 3, TM = 4, TA = 5, TB = 6, LM = 7, LA = 8, LB = 9};
33 std::vector<char>
EnumToChar(std::vector<TracebackType> v);
81 allocateMemory_(ROW_SIZE, COL_SIZE);
88 std::memset(s_data, 0, (ROW_SIZE -1) * (COL_SIZE-1) *
sizeof(
double));
89 std::memset(M, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
90 std::memset(A, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
91 std::memset(B, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
93 std::memset(Path, 0, ROW_SIZE * COL_SIZE *
sizeof(
bool));
94 std::memset(simPath, 0, ROW_SIZE * COL_SIZE *
sizeof(
bool));
97 signalA_len = ROW_SIZE-1;
98 signalB_len = COL_SIZE-1;
104 signalA_capacity = ROW_SIZE-1;
105 signalB_capacity = COL_SIZE-1;
109 void reset(
int ROW_SIZE,
int COL_SIZE)
111 if (ROW_SIZE -1 > signalA_capacity || COL_SIZE -1 > signalB_capacity)
113 std::cout <<
"Error: cannot reset an object beyond capacity" << std::endl;
114 std::cout << ROW_SIZE <<
" vs " << signalA_capacity << std::endl;
120 std::memset(s_data, 0, (ROW_SIZE -1) * (COL_SIZE-1) *
sizeof(
double));
121 std::memset(M, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
122 std::memset(A, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
123 std::memset(B, 0, ROW_SIZE * COL_SIZE *
sizeof(
double));
125 std::memset(Path, 0, ROW_SIZE * COL_SIZE *
sizeof(
bool));
126 std::memset(simPath, 0, ROW_SIZE * COL_SIZE *
sizeof(
bool));
128 signalA_len = ROW_SIZE-1;
129 signalB_len = COL_SIZE-1;
133 indexA_aligned.clear();
134 indexB_aligned.clear();
146 signalA_capacity = rhs.signalA_capacity;
148 signalB_capacity = rhs.signalB_capacity;
161 allocateMemory_(ROW_SIZE, COL_SIZE);
162 copyData_(rhs, ROW_SIZE, COL_SIZE);
174 signalA_capacity = rhs.signalA_capacity;
176 signalB_capacity = rhs.signalB_capacity;
189 allocateMemory_(ROW_SIZE, COL_SIZE);
190 copyData_(rhs, ROW_SIZE, COL_SIZE);
217 void allocateMemory_(
int ROW_SIZE,
int COL_SIZE)
222 s_data =
new double[(ROW_SIZE -1) * (COL_SIZE-1)];
223 M =
new double[ROW_SIZE * COL_SIZE];
224 A =
new double[ROW_SIZE * COL_SIZE];
225 B =
new double[ROW_SIZE * COL_SIZE];
227 Path =
new bool[ROW_SIZE * COL_SIZE];
228 simPath =
new bool[ROW_SIZE * COL_SIZE];
232 void copyData_(
const AffineAlignObj& rhs,
int ROW_SIZE,
int COL_SIZE)
234 std::memcpy(s_data, rhs.
s_data, (ROW_SIZE -1) * (COL_SIZE-1) *
sizeof(
double));
235 std::memcpy(M, rhs.
M, ROW_SIZE * COL_SIZE *
sizeof(
double));
236 std::memcpy(A, rhs.
A, ROW_SIZE * COL_SIZE *
sizeof(
double));
237 std::memcpy(B, rhs.
B, ROW_SIZE * COL_SIZE *
sizeof(
double));
239 std::memcpy(Path, rhs.
Path, ROW_SIZE * COL_SIZE *
sizeof(
bool));
240 std::memcpy(simPath, rhs.
simPath, ROW_SIZE * COL_SIZE *
sizeof(
bool));
245 #endif // AFFINEALIGNOBJ_H bool FreeEndGaps
True for Overlap alignment.
Definition: affinealignobj.h:64
bool * Path
Path matrix would represent alignment path through similarity matrix as binary-hot encoding...
Definition: affinealignobj.h:56
tbJump
cumulative score-matrix names
Definition: affinealignobj.h:27
An affine alignment object.
Definition: affinealignobj.h:44
double * s_data
similarity score matrix.
Definition: affinealignobj.h:51
bool * simPath
Not needed, will be removed.
Definition: affinealignobj.h:57
double * A
Insert in sequence A, residue in A is aligned to gap in B. A(i,j) is the best score given that Ai is ...
Definition: affinealignobj.h:53
void reset(int ROW_SIZE, int COL_SIZE)
Reset object to initial state (without allocating new memory)
Definition: affinealignobj.h:109
Generic namespace for all classes and functions of DIAlign.
Definition: affinealignment.cpp:29
AffineAlignObj(int ROW_SIZE, int COL_SIZE, bool clearMemory=true)
Constructor for AffineAlignObj.
Definition: affinealignobj.h:79
int signalB_len
Number of data-points in signal B.
Definition: affinealignobj.h:61
double * M
Match or Mismatch matrix, residues of A and B are aligned without a gap. M(i,j) = Best score upto (i...
Definition: affinealignobj.h:52
std::ostream & operator<<(std::ostream &out, const TracebackType value)
This function overloads << to display TracebackType.
Definition: affinealignobj.cpp:10
std::vector< double > score
Cumulative score along the aligned path.
Definition: affinealignobj.h:67
int signalA_len
Number of data-points in signal A.
Definition: affinealignobj.h:60
Traceback::TracebackType * Traceback
Traceback matrices store source matrix name and direction as matrices are filled with dynamic program...
Definition: affinealignobj.h:55
double GapExten
Penalty for Gap extension. For n consecutive gaps: Penalty = GapOpen + (n-1)*GapExten.
Definition: affinealignobj.h:63
std::vector< int > indexB_aligned
Aligned signalB indices after affine alignment.
Definition: affinealignobj.h:66
AffineAlignObj & operator=(const AffineAlignObj &rhs)
Overloading copy assignment operator.
Definition: affinealignobj.h:142
std::vector< char > EnumToChar(std::vector< TracebackType > v)
This function converts TracebackType Enum to characters.
Definition: affinealignobj.cpp:30
TracebackType
All combinations of cumulative score-matrix name and arrow directions.
Definition: affinealignobj.h:24
std::vector< int > indexA_aligned
Aligned signalA indices after affine alignment.
Definition: affinealignobj.h:65
~AffineAlignObj()
Destructor: frees memory.
Definition: affinealignobj.h:194
AffineAlignObj(const AffineAlignObj &rhs)
Copy constructor.
Definition: affinealignobj.h:169
double GapOpen
Penalty for Gap opening. For n consecutive gaps: Penalty = GapOpen + (n-1)*GapExten.
Definition: affinealignobj.h:62
int nGaps
Total number of gaps in the alignment path.
Definition: affinealignobj.h:68
double * B
Insert in sequence B, residue in B is aligned to gap in A. B(i,j) is the best score given that Bj is ...
Definition: affinealignobj.h:54