Function
getFrequency
Returns the number of sequences, which contain the representative as a substring.
int getFrequency(iterator)
Include Headers
seqan/index.h
Parameters
iterator
An iterator of a suffix tree.
Return Values
The number of different sequences containing the representative.
Examples
The following code how getFrequency is used. Note that the result of alternative 1 and 2 is the same, however alternative one copies a string which requires more memory.
1#include <seqan/index.h>
2
3using namespace seqan;
4
5int main ()
6{
7    typedef StringSet<String<char> >    TText;
8    typedef Index<TText>                TIndex;
9    typedef SAValue<TIndex>::Type       TSAValue;
10
11    TText text;
12    appendValue(text, "MISSISSIPPI");
13    appendValue(text, "MYMISSISAHAPPY");
14
15    TIndex index(text);
16    Iterator<TIndex, TopDown<> >::Type it(index);
17
18    goDown(it, "SSI");
19
20    std::cout << "SSI occurs in " << getFrequency(it) << " sequences." << std::endl;
21
22    // 1 alternative to print the location of hits
23    String<TSAValue> saPositions = getOccurrences(it);
24    for (unsigned i = 0; i < length(saPositions); ++i)
25        std::cout << "Hit in sequence " << saPositions[i].i1 << " at position " << saPositions[i].i2 << std::endl;
26
27    std::cout << "----------------------------" << std::endl;
28
29    // 2 alternative to print the location of hits
30    Pair<unsigned> hitInterval = range(it);
31    for (; hitInterval.i1 < hitInterval.i2; ++hitInterval.i1)
32        std::cout << "Hit in sequence " << getFibre(index, FibreSA())[hitInterval.i1].i1 <<
33                     " at position " << getFibre(index, FibreSA())[hitInterval.i1].i2 << std::endl;
34
35    return 0;
36}
SSI occurs in 2 sequences.
Hit in sequence 0 at position 5
Hit in sequence 1 at position 4
Hit in sequence 0 at position 2
----------------------------
Hit in sequence 0 at position 5
Hit in sequence 1 at position 4
Hit in sequence 0 at position 2
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2013/07/11 09:12:36