13 #ifndef CONSISTENCY_ALN_HPP_
14 #define CONSISTENCY_ALN_HPP_
23 #include "../utils/MatrixStack.hpp"
24 #include "../clustering/Tree.hpp"
50 nw_dyn_consistency_traceback(
size_t i,
size_t j,
const Matrix<std::pair<int, char> > &matrix, std::string &edit_string1, std::string &edit_string2);
64 gotoh_dyn_consistency(
int dim1,
int dim2, MatrixStack<3, std::pair<int, char> > &matrices,
int gop,
int gep);
75 gotoh_dyn_consistency_traceback(
size_t i,
size_t j, MatrixStack<3,std::pair<int, char> > &matrices, std::string &edit_string1, std::string &edit_string2);
109 template<
typename DataType>
111 enterDataIntoMatrix(
Matrix<std::pair<DataType, char> > &matrix,
size_t dim1,
size_t dim2,
const std::map<Match, DataType> &match_points)
113 matrix.resize(dim1+1, dim2+1);
114 matrix.fill(std::pair<DataType, char>(0,
'-'));
115 typename std::map<Match, DataType>::const_iterator it, it_end=match_points.end();
116 for (it=match_points.begin(); it!=it_end; ++it)
117 matrix[it->first.first+1][it->first.second+1].first=it->second;
129 template<
typename DataType,
typename GapFunction>
133 size_t n_elems =
set.size();
134 std::stack<std::pair<TreeNode*, unsigned int> > to_do;
135 to_do.push(std::pair<TreeNode*, int>(guide_tree.
root(), 0));
136 std::map<Match, int> match_points;
139 std::vector<std::pair<unsigned int, unsigned int> > gap1, gap2;
142 for (
size_t i=0; i<n_elems; ++i)
145 size_t dim1, dim2, i;
146 std::string edit_string1, edit_string2;
147 while (!to_do.empty())
149 std::pair<TreeNode*, unsigned int> ¤t = to_do.top();
150 if (current.first->children.empty())
152 else if (current.second == current.first->children.size())
154 std::vector<size_t> &ids1 = ids[current.first->children[0]->id];
155 dim1=
set[ids1[0]].length();
156 std::vector<size_t> &ids2 = ids[current.first->children[1]->id];
157 dim2=
set[ids2[0]].length();
158 lib.
get(ids1, ids2, match_points, gap_func);
162 for (i=0; i<ids1.size(); ++i)
163 set[ids1[i]].insert_gaps(edit_string1);
164 for (i=0; i<ids2.size(); ++i)
165 set[ids2[i]].insert_gaps(edit_string2);
166 ids1.reserve( ids1.size() + ids2.size() );
167 ids1.insert(ids1.end(), ids2.begin(), ids2.end());
168 current.first->id = current.first->children[0]->id;
173 to_do.push(std::pair<TreeNode*, int>(&(*current.first->children[current.second]), 0));