| Example Program Supermaximal Repeats Example for using the SuperMaxRepeats Iterator. Given a sequences, a repeat is a substring that occurs at at least 2 different positions. A supermaximal repeat is a repeat that is not part of any longer repeat. The following example demonstrates how to iterate over all supermaximal repeats and output them. File "index_supermaxrepeats.cpp" A tutorial about finding supermaximal repeats.
1 | #include <iostream>
2 | #include <seqan/index.h>
3 |
4 | using namespace seqan;
5 |
6 | int main ()
7 | {
We begin with a String to store our sequence.
8 | String<char> myString = "How many wood would a woodchuck chuck.";
9 |
Then we create an Index of this StringSet.
10 | typedef Index< String<char> > TMyIndex;
11 | TMyIndex myIndex(myString);
12 |
To find supermaximal repeats, we use SeqAn's SuperMaxRepeats Iterator and set the minimum repeat length to 3.
13 | Iterator< TMyIndex, SuperMaxRepeats >::Type myRepeatIterator(myIndex, 3);
14 |
15 | while (!atEnd(myRepeatIterator))
16 | {
A repeat can be represented by its length and positions it occurs at. getOccurrences returns an unordered sequence of these positions The length of this sequence, i.e. the repeat abundance can be obtained from countOccurrences.
17 | for(unsigned i = 0; i < countOccurrences(myRepeatIterator); ++i)
18 | ::std::cout << getOccurrences(myRepeatIterator)[i] << ", ";
19 |
repLength returns the length of the repeat string.
20 | ::std::cout << repLength(myRepeatIterator) << " ";
21 |
The repeat string itself can be determined with representative.
22 | ::std::cout << "\t\"" << representative(myRepeatIterator) << '\"' << ::std::endl;
23 |
24 | ++myRepeatIterator;
25 | }
26 |
27 | return 0;
28 | }
Output The only supermaximal repeats of "How many wood would a woodchuck chuck." of length at least 3 are " wood" and "chuck". There are repeats of " wo" which are maximal (see Maximal Repeats), ut not supermaximal, as " wo" is part of the longer repeat " wood". weese@tanne:~/seqan$ cd demos weese@tanne:~/seqan/demos$ make index_supermaxrepeats weese@tanne:~/seqan/demos$ ./index_supermaxrepeats 8, 21, 5 " wood" 26, 32, 5 "chuck" weese@tanne:~/seqan/demos$ See Index, getOccurrences, SuperMaxRepeats Iterator, representative, repLength, countOccurrences SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2012/03/14 16:34:46