Basic concepts
We present in this chapter algorithms to search for regular expressions in texts or biological sequences. Regular expressions are often used in text retrieval or computational biology applications to represent search patterns that are more complex than a string, a set of strings, or an extended string. We begin with a formal definition of a regular expression and the language (set of strings) it represents.
DefinitionA regular expression RE is a string on the set of symbols Σ ∪ { ε, |, ·, ⋆, (,) }, which is recursively defined as the empty character ε a character α ∈ Σ and (RE1), (RE1 · RE2), (RE1 | RE2), and (RE1⋆), where RE1and RE2are regular expressions.
For instance, in this chapter we consider the regular expression (((A·T) | (G·A))·(((A·G) | ((A·A)·A))⋆)). When there is no ambiguity, we simplify our expressions by writing RE1RE2 instead of (RE1 · RE2). This way, we obtain a more readable expression, in our case (AT|GA) ((AG|AAA)⋆). It is usual to use also the precedence order “*”, “·”, “|” to remove more parentheses, but we do not do this here. The symbols “·”, “|”, “⋆” are called operators. It is customary to add an extra postfix operator “+” to mean RE+ = RE · RE⋆. We define now the language represented by a regular expression.
DefinitionThe language represented by a regular expression RE is a set of strings over Σ which is defined recursively on the structure of RE as follows:
• If RE is ε, then L(RE) = {ε}, the empty string.
• If RE is α ∈ Σ, then L(RE) = {α}, a single string of one character.
• If RE is of the form (RE1), then L(RE) = L(RE1).
• If RE is of the form (RE1 · RE2), then L(RE) = L(RE1) · L(RE2), where W1 · W2is the set of strings w such that w = w1w2, with w1 ∈ W1and w2 ∈ W2. The operator “·” represents the classical concatenation of strings.
[…]