Английская Википедия:FM-index

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

In computer science, an FM-index is a compressed full-text substring index based on the Burrows–Wheeler transform, with some similarities to the suffix array. It was created by Paolo Ferragina and Giovanni Manzini,[1] who describe it as an opportunistic data structure as it allows compression of the input text while still permitting fast substring queries. The name stands for Full-text index in Minute space.[2]

It can be used to efficiently find the number of occurrences of a pattern within the compressed text, as well as locate the position of each occurrence. The query time, as well as the required storage space, has a sublinear complexity with respect to the size of the input data.

The original authors have devised improvements to their original approach and dubbed it "FM-Index version 2".[3] A further improvement, the alphabet-friendly FM-index, combines the use of compression boosting and wavelet trees[4] to significantly reduce the space usage for large alphabets.

The FM-index has found use in, among other places, bioinformatics.[5]

Background

Using an index is a common strategy to efficiently search a large body of text. When the text is larger than what reasonably fits within a computer's main memory, there is a need to compress not only the text but also the index. When the FM-index was introduced, there were several suggested solutions that were based on traditional compression methods and tried to solve the compressed matching problem. In contrast, the FM-index is a compressed self-index, which means that it compresses the data and indexes it at the same time.

FM-index data structure

An FM-index is created by first taking the Burrows–Wheeler transform (BWT) of the input text. For example, the BWT of the string Шаблон:Mono"abracadabra$" is "ard$rcaaaabb", and here it is represented by the matrix Шаблон:Mono where each row is a rotation of the text, and the rows have been sorted lexicographically. The transform corresponds to the concatenation of the characters from the last column (labeled Шаблон:Mono).

Шаблон:Mono Шаблон:Mono Шаблон:Mono
1 Шаблон:Mono Шаблон:Mono Шаблон:Mono
2 Шаблон:Mono Шаблон:Mono Шаблон:Mono
3 Шаблон:Mono Шаблон:Mono Шаблон:Mono
4 Шаблон:Mono Шаблон:Mono Шаблон:Mono
5 Шаблон:Mono Шаблон:Mono Шаблон:Mono
6 Шаблон:Mono Шаблон:Mono Шаблон:Mono
7 Шаблон:Mono Шаблон:Mono Шаблон:Mono
8 Шаблон:Mono Шаблон:Mono Шаблон:Mono
9 Шаблон:Mono Шаблон:Mono Шаблон:Mono
10 Шаблон:Mono Шаблон:Mono Шаблон:Mono
11 Шаблон:Mono Шаблон:Mono Шаблон:Mono
12 Шаблон:Mono Шаблон:Mono Шаблон:Mono

The BWT in itself allows for some compression with, for instance, move to front and Huffman encoding, but the transform has even more uses. The rows in the matrix are essentially the sorted suffixes of the text and the first column F of the matrix shares similarities with suffix arrays. How the suffix array relates to the BWT lies at the heart of the FM-index.

It is possible to make a last-to-first column mapping Шаблон:Mono from an index Шаблон:Mono to an index Шаблон:Mono, such that Шаблон:Mono = Шаблон:Mono, with the help of a table Шаблон:Mono and a function Шаблон:Mono.

Шаблон:Mono of "Шаблон:Mono"
Шаблон:Mono $ a b c d r
Шаблон:Mono 0 1 6 8 9 10

The last-to-first mapping can now be defined as Шаблон:Mono. For instance, on row 9, Шаблон:Mono is Шаблон:Mono and the same Шаблон:Mono can be found on row 5 in the first column Шаблон:Mono, so Шаблон:Mono should be 5 and Шаблон:Mono. For any row Шаблон:Mono of the matrix, the character in the last column Шаблон:Mono precedes the character in the first column Шаблон:Mono also in T. Finally, if Шаблон:Mono, then Шаблон:Mono, and using the equality it is possible to extract a string of Шаблон:Mono from Шаблон:Mono.

The FM-index itself is a compression of the string Шаблон:Mono together with Шаблон:Mono and Шаблон:Mono in some form, as well as information that maps a selection of indices in Шаблон:Mono to positions in the original string Шаблон:Mono.

Шаблон:Mono of "Шаблон:Mono"
a r d $ r c a a a a b b
1 2 3 4 5 6 7 8 9 10 11 12
$ 0 0 0 1 1 1 1 1 1 1 1 1
a 1 1 1 1 1 1 2 3 4 5 5 5
b 0 0 0 0 0 0 0 0 0 0 1 2
c 0 0 0 0 0 1 1 1 1 1 1 1
d 0 0 1 1 1 1 1 1 1 1 1 1
r 0 1 1 1 2 2 2 2 2 2 2 2

Count

The operation count takes a pattern Шаблон:Mono and returns the number of occurrences of that pattern in the original text Шаблон:Mono. Since the rows of matrix Шаблон:Mono are sorted, and it contains every suffix of Шаблон:Mono, the occurrences of pattern Шаблон:Mono will be next to each other in a single continuous range. The operation iterates backwards over the pattern. For every character in the pattern, the range that has the character as a suffix is found. For example, the count of the pattern "bra" in "abracadabra" follows these steps:

  1. The first character we look for is Шаблон:Mono, the last character in the pattern. The initial range is set to Шаблон:Mono. This range over Шаблон:Mono represents every character of Шаблон:Mono that has a suffix beginning with a.
  2. The next character to look for is Шаблон:Mono. The new range is Шаблон:Mono Шаблон:Mono Шаблон:Mono, if Шаблон:Mono is the index of the beginning of the range and Шаблон:Mono is the end. This range over Шаблон:Mono is all the characters of Шаблон:Mono that have suffixes beginning with ra.
  3. The last character to look at is Шаблон:Mono. The new range is Шаблон:Mono Шаблон:Mono Шаблон:Mono. This range over Шаблон:Mono is all the characters that have a suffix that begins with bra. Now that the whole pattern has been processed, the count is the same as the size of the range: Шаблон:Mono.

If the range becomes empty or the range boundaries cross each other before the whole pattern has been looked up, the pattern does not occur in Шаблон:Mono. Because Шаблон:Mono can be performed in constant time, count can complete in linear time in the length of the pattern: Шаблон:Mono time.

Locate

The operation locate takes as input an index of a character in Шаблон:Mono and returns its position Шаблон:Mono in Шаблон:Mono. For instance Шаблон:Mono. To locate every occurrence of a pattern, first the range of character is found whose suffix is the pattern in the same way the count operation found the range. Then the position of every character in the range can be located.

To map an index in Шаблон:Mono to one in Шаблон:Mono, a subset of the indices in Шаблон:Mono are associated with a position in Шаблон:Mono. If Шаблон:Mono has a position associated with it, Шаблон:Mono is trivial. If it's not associated, the string is followed with Шаблон:Mono until an associated index is found. By associating a suitable number of indices, an upper bound can be found. Locate can be implemented to find occ occurrences of a pattern Шаблон:Mono in a text Шаблон:Mono in Шаблон:Math time with <math>O \left(H_k(T) + {{\log\log u}\over{\log^\epsilon u}} \right)</math> bits per input symbol for any Шаблон:Math.[1]

Applications

DNA read mapping

FM index with backtracking has been successfully (>2000 citations) applied to approximate string matching/sequence alignment, See Bowtie http://bowtie-bio.sourceforge.net/index.shtml

See also

References

Шаблон:Reflist

  1. 1,0 1,1 1,2 Paolo Ferragina and Giovanni Manzini (2000). "Opportunistic Data Structures with Applications". Proceedings of the 41st Annual Symposium on Foundations of Computer Science. p.390.
  2. Paolo Ferragina and Giovanni Manzini (2005). "Indexing Compressed Text". Journal of the ACM, 52, 4 (Jul. 2005). p. 553
  3. Шаблон:Cite web
  4. P. Ferragina, G. Manzini, V. Mäkinen and G. Navarro. An Alphabet-Friendly FM-index. In Proc. SPIRE'04, pages 150-160. LNCS 3246.
  5. Шаблон:Cite journal