Local Alignments

| 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[" << clippedBeginPosition(row(ali, 0)) << ":" << (clippedEndPosition(row(ali, 0))-1) << "]";
14 | ::std::cout << " and Seq2[" << clippedBeginPosition(row(ali, 1)) << ":" << (clippedEndPosition(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 or equal 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[" << clippedBeginPosition(row(ali2, 0)) << ":" << (clippedEndPosition(row(ali2, 0))-1) << "]";
27 | ::std::cout << " and Seq2[" << clippedBeginPosition(row(ali2, 1)) << ":" << (clippedEndPosition(row(ali2, 1))-1) << "]" << ::std::endl << ::std::endl;
28 | }
29 |
Example 3
30 | Align< String<Dna> > ali3;
31 | appendValue(rows(ali3), "cccccc");
32 | appendValue(rows(ali3), "tttttggccccccgg");
33 | LocalAlignmentFinder<> finder3(ali3);
34 | Score<int> scoring3(1, -1, -1, -1);
35 | while (localAlignment(ali3, finder3, scoring3, 5, WatermanEggert())) {
36 | ::std::cout << "Score = " << getScore(finder3) << ::std::endl;
37 | ::std::cout << ali3;
38 | ::std::cout << "Aligns Seq1[" << clippedBeginPosition(row(ali3, 0)) << ":" << (clippedEndPosition(row(ali3, 0))-1) << "]";
39 | ::std::cout << " and Seq2[" << clippedBeginPosition(row(ali3, 1)) << ":" << (clippedEndPosition(row(ali3, 1))-1) << "]" << ::std::endl << ::std::endl;
40 | }
41 |
Example 4: This program applies the banded Waterman-Eggert algorithm to compute all non-overlapping local alignments with score or equal 5 in the band from diagonal -1 to diagonal 8.
42 | Align< String<Dna5> > ali4;
43 | appendValue(rows(ali4), "AAAAAAANAAAGGGNGGGGGGGGNGGGGGANAA");
44 | appendValue(rows(ali4), "GGGGGGCGGGGGGGA");
45 |
46 | LocalAlignmentFinder<> finder4(ali4);
47 | Score<int> scoring4(1, -1, -1, -1);
48 | while (localAlignment(ali4, finder4, scoring4, 5, -1, 8, BandedWatermanEggert())) {
49 | ::std::cout << "Score = " << getScore(finder4) << ::std::endl;
50 | ::std::cout << ali4;
51 | ::std::cout << "Aligns Seq1[" << clippedBeginPosition(row(ali4, 0)) << ":" << (clippedEndPosition(row(ali4, 0))-1) << "]";
52 | ::std::cout << " and Seq2[" << clippedBeginPosition(row(ali4, 1)) << ":" << (clippedEndPosition(row(ali4, 1))-1) << "]" << ::std::endl << ::std::endl;
53 | }
54 |
55 | return 0;
56 | }
See localAlignment, Score, Align SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2011/02/08 21:37:01