Example Program
Index countOccurrencesMultiple
Example for using the functions countOccurrencesMultiple and countSequences for q-gram indices.
This example shows how to create a q-gram index for a string set and subsequently how to count the number of occurrences of a pattern in all strings of the stringset. Before this we output the number of sequences in the index. Finally we output the frequencies of shared q-grams between pairs of sequences in the string set.
File "index_qgram_counts.cpp"
A tutorial about the counts fibre of the q-gram index.
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 |
First, we create a StringSet of 4 Strings.
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
Now we output how often "be" occurs in each sequence.
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 |
Remember that we constructed the q-gram index with ungapped 2-grams. The following function computes the fraction of common 2-grams between all pairs of sequences and outputs them.
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 |
Output
2 occurrences in sequence 0
1 occurrences in sequence 1
1 occurrences in sequence 3
SeqAn - Sequence Analysis Library - www.seqan.de