| Example Program MSA with UPGMA Progressive multiple sequence alignment using UPGMA for building the guide tree File "graph_align_guide_upgma.cpp" This code example illustrates a guide tree creation using upgma
1 | #include <seqan/graph.h>
2 | #include <iostream>
3 |
4 | using namespace seqan;
5 |
6 | int main() {
Create an artificial distance matrix
7 | String<double> mat;
8 | fill(mat, 8*8, 0);
9 | assignValue(mat, 0*8+0, 0);assignValue(mat, 0*8+1, 32);assignValue(mat, 0*8+2, 48);assignValue(mat, 0*8+3, 51);
10 | assignValue(mat, 0*8+4, 50);assignValue(mat, 0*8+5, 48);assignValue(mat, 0*8+6, 98);assignValue(mat, 0*8+7, 148);
11 | assignValue(mat, 1*8+0, 32);assignValue(mat, 1*8+1, 0);assignValue(mat, 1*8+2, 26);assignValue(mat, 1*8+3, 34);
12 | assignValue(mat, 1*8+4, 29);assignValue(mat, 1*8+5, 33);assignValue(mat, 1*8+6, 84);assignValue(mat, 1*8+7, 136);
13 | assignValue(mat, 2*8+0, 48);assignValue(mat, 2*8+1, 26);assignValue(mat, 2*8+2, 0);assignValue(mat, 2*8+3, 42);
14 | assignValue(mat, 2*8+4, 44);assignValue(mat, 2*8+5, 44);assignValue(mat, 2*8+6, 92);assignValue(mat, 2*8+7, 152);
15 | assignValue(mat, 3*8+0, 51);assignValue(mat, 3*8+1, 34);assignValue(mat, 3*8+2, 42);assignValue(mat, 3*8+3, 0);
16 | assignValue(mat, 3*8+4, 44);assignValue(mat, 3*8+5, 38);assignValue(mat, 3*8+6, 86);assignValue(mat, 3*8+7, 142);
17 | assignValue(mat, 4*8+0, 50);assignValue(mat, 4*8+1, 29);assignValue(mat, 4*8+2, 44);assignValue(mat, 4*8+3, 44);
18 | assignValue(mat, 4*8+4, 0);assignValue(mat, 4*8+5, 24);assignValue(mat, 4*8+6, 89);assignValue(mat, 4*8+7, 142);
19 | assignValue(mat, 5*8+0, 48);assignValue(mat, 5*8+1, 33);assignValue(mat, 5*8+2, 44);assignValue(mat, 5*8+3, 38);
20 | assignValue(mat, 5*8+4, 24);assignValue(mat, 5*8+5, 0);assignValue(mat, 5*8+6, 90);assignValue(mat, 5*8+7, 142);
21 | assignValue(mat, 6*8+0, 98);assignValue(mat, 6*8+1, 84);assignValue(mat, 6*8+2, 92);assignValue(mat, 6*8+3, 86);
22 | assignValue(mat, 6*8+4, 89);assignValue(mat, 6*8+5, 90);assignValue(mat, 6*8+6, 0);assignValue(mat, 6*8+7, 148);
23 | assignValue(mat, 7*8+0, 148);assignValue(mat, 7*8+1, 136);assignValue(mat, 7*8+2, 152);assignValue(mat, 7*8+3, 142);
24 | assignValue(mat, 7*8+4, 142);assignValue(mat, 7*8+5, 142);assignValue(mat, 7*8+6, 148);assignValue(mat, 7*8+7, 0);
Out-parameter: A guide tree based upon a distance matrix
25 | typedef Graph<Tree<double> > TGraph;
26 | TGraph upgmaTreeOut;
UPGMA
27 | upgmaTree(mat, upgmaTreeOut);
Console output
28 | std::cout << upgmaTreeOut << std::endl;
29 | // Dfs Iterator
30 | typedef Iterator<TGraph, DfsPreorder>::Type TDfsPreorder;
31 | TDfsPreorder dfsIt(upgmaTreeOut,getRoot(upgmaTreeOut));
32 | std::cout << "Dfs: ";
33 | for(;!atEnd(dfsIt);goNext(dfsIt)) {
34 | std::cout << *dfsIt << ", ";
35 | }
36 | std::cout << std::endl;
37 | typedef Iterator<TGraph, EdgeIterator>::Type TEdgeIter;
38 | TEdgeIter edIt(upgmaTreeOut);
39 | std::cout << "Edges: " << std::endl;
40 | for(;!atEnd(edIt);goNext(edIt)) {
41 | std::cout << sourceVertex(edIt) << " -- " << targetVertex(edIt) << ": Weight = " << getCargo(*edIt) << std::endl;
42 | }
43 | return 0;
44 | }
See Graph SeqAn - Sequence Analysis Library - www.seqan.de