| Example Program Local Alignments Computing local alignments between two sequences. File "alignment_local.cpp" A tutorial about local alignments.
1 | #include <iostream>
2 | #include <seqan/align.h>
3 |
4 | using namespace seqan;
5 |
6 | int main()
7 | {
Example 1: This program applies the Smith-Waterman algorithm to compute the best local alignment between two given sequences.
8 | Align< String<char> > ali;
9 | appendValue(rows(ali), "aphilologicaltheorem");
10 | appendValue(rows(ali), "bizarreamphibology");
11 | ::std::cout << "Score = " << localAlignment(ali, Score<int>(3,-3,-2, -2), SmithWaterman()) << ::std::endl;
12 | ::std::cout << ali;
13 | ::std::cout << "Aligns Seq1[" << sourceBeginPosition(row(ali, 0)) << ":" << (sourceEndPosition(row(ali, 0))-1) << "]";
14 | ::std::cout << " and Seq2[" << sourceBeginPosition(row(ali, 1)) << ":" << (sourceEndPosition(row(ali, 1))-1) << "]" << ::std::endl << ::std::endl;
15 |
16 |
Example 2: This program applies the Waterman-Eggert algorithm to compute all non-overlapping local alignments with score better than 2.
17 | Align< String<Dna> > ali2;
18 | appendValue(rows(ali2), "ataagcgtctcg");
19 | appendValue(rows(ali2), "tcatagagttgc");
20 |
21 | LocalAlignmentFinder<> finder(ali2);
22 | Score<int> scoring(2, -1, -2, 0);
23 | while (localAlignment(ali2, finder, scoring, 2, WatermanEggert())) {
24 | ::std::cout << "Score = " << getScore(finder) << ::std::endl;
25 | ::std::cout << ali2;
26 | ::std::cout << "Aligns Seq1[" << sourceBeginPosition(row(ali2, 0)) << ":" << (sourceEndPosition(row(ali2, 0))-1) << "]";
27 | ::std::cout << " and Seq2[" << sourceBeginPosition(row(ali2, 1)) << ":" << (sourceEndPosition(row(ali2, 1))-1) << "]" << ::std::endl << ::std::endl;
28 | }
29 |
30 | return 0;
31 | }
See Align, localAlignment, Score SeqAn - Sequence Analysis Library - www.seqan.de