Commit 2e9cad37 authored by Carsten Kemena's avatar Carsten Kemena

added raspodom matrix calculation

parent 75296622
......@@ -53,6 +53,8 @@ private:
short algorithm_;
size_t dim1_;
size_t dim2_;
size_t best_score_x;
size_t best_score_y;
void
traceback_nw_(std::vector<long int> &editString1, std::vector<long int> &editString2);
......@@ -446,8 +448,77 @@ template<typename SeqType>
void
AlignmentMatrix<DataType, SimMat>::raspodom(const SeqType &seq1, const SeqType &seq2)
{
algorithm_ = 0;
dim1_= 2 * seq1.size();
dim2_= 2 * seq2.size();
size_t j;
matrix_.resize(dim1_+1, dim2_+1);
for (size_t i=0; i<dim1_; ++i)
{
for (j=0; j<dim2_; ++j)
matrix_[i+1][j+1].first = simMat_.val(seq1[i % seq1.size()],seq2[j % seq2.size()]);
}
size_t dim2 = dim2_;
++dim2;
auto itPrev = matrix_[0].begin();
auto itVert = matrix_[0].begin();
auto it = matrix_[0].begin();
auto itEnd = matrix_[0].begin()+dim2;
char path;
size_t i;
j=0;
DataType score;
for (; it!=itEnd; ++it)
it->first=0;
for (i=1; i <= dim1_; ++i)
{
itPrev = it = matrix_[i].begin();
itEnd = matrix_[i].begin()+dim2;
itVert = matrix_[i-1].begin();
it->first = 0;
++it;
for (; it!=itEnd; ++it, ++itPrev)
{
score=it->first+itVert->first;
path=itVert->second;
++itVert;
// check gaps;
if (itVert->first > itPrev->first)
{
it->first = itVert->first;
it->second = 'i';
}
else
{
it->first = itPrev->first;
it->second = 'j';
}
it->first += gep_;
// check match
if ((score > it->first) || ((score == it->first) && (path=='m')))
{
it->first = score;
it->second = 'm';
}
}
}
// Calculate best score in bottome left quadrant and store.
score_ = 0;
for (size_t i=seq1.size(); i<=dim1_; ++i)
{
for (size_t j=seq2.size(); j<=dim2_; ++j)
{
if (matrix_[i][j] > score_)
{
score_ = matrix_[i][j];
best_score_x = i;
best_score_y = j;
}
}
}
}
template<typename DataType, typename SimMat>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment