Email updates

Keep up to date with the latest news and content from BMC Bioinformatics and BioMed Central.

Open Access Highly Accessed Methodology article

Fast online and index-based algorithms for approximate search of RNA sequence-structure patterns

Fernando Meyer, Stefan Kurtz and Michael Beckstette*

Author Affiliations

Center for Bioinformatics, University of Hamburg, Bundesstrasse 43, Hamburg 20146, Germany

For all author emails, please log on.

BMC Bioinformatics 2013, 14:226  doi:10.1186/1471-2105-14-226


The electronic version of this article is the complete one and can be found online at: http://www.biomedcentral.com/1471-2105/14/226


Received:27 February 2013
Accepted:11 July 2013
Published:17 July 2013

© 2013 Meyer et al.; licensee BioMed Central Ltd.

This is an Open Access article distributed under the terms of the Creative Commons Attribution License ( http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Abstract

Background

It is well known that the search for homologous RNAs is more effective if both sequence and structure information is incorporated into the search. However, current tools for searching with RNA sequence-structure patterns cannot fully handle mutations occurring on both these levels or are simply not fast enough for searching large sequence databases because of the high computational costs of the underlying sequence-structure alignment problem.

Results

We present new fast index-based and online algorithms for approximate matching of RNA sequence-structure patterns supporting a full set of edit operations on single bases and base pairs. Our methods efficiently compute semi-global alignments of structural RNA patterns and substrings of the target sequence whose costs satisfy a user-defined sequence-structure edit distance threshold. For this purpose, we introduce a new computing scheme to optimally reuse the entries of the required dynamic programming matrices for all substrings and combine it with a technique for avoiding the alignment computation of non-matching substrings. Our new index-based methods exploit suffix arrays preprocessed from the target database and achieve running times that are sublinear in the size of the searched sequences. To support the description of RNA molecules that fold into complex secondary structures with multiple ordered sequence-structure patterns, we use fast algorithms for the local or global chaining of approximate sequence-structure pattern matches. The chaining step removes spurious matches from the set of intermediate results, in particular of patterns with little specificity. In benchmark experiments on the Rfam database, our improved online algorithm is faster than the best previous method by up to factor 45. Our best new index-based algorithm achieves a speedup of factor 560.

Conclusions

The presented methods achieve considerable speedups compared to the best previous method. This, together with the expected sublinear running time of the presented index-based algorithms, allows for the first time approximate matching of RNA sequence-structure patterns in large sequence databases. Beyond the algorithmic contributions, we provide with RaligNAtor a robust and well documented open-source software package implementing the algorithms presented in this manuscript. The RaligNAtor software is available at http://www.zbh.uni-hamburg.de/ralignator webcite.

Background

Due to their participation in several important molecular-biological processes, ranging from passive carriers of genetic information (tRNAs) over regulatory functions (microRNAs) to protein-like catalytic activities (Riboswitsches), non-coding RNAs (ncRNAs) are of central research interest in molceular biology [1]. NcRNAs, although synthesized as single-stranded molecules, present surprising complexity by being able to base pair with themselves and fold into numerous different structures. It is to a large extent the structure that allows them to interact with other molecules and hence to carry out various biological functions. This can also be observed in families of functionally related ncRNAs like the ones compiled in the Rfam database [2]. Here members of a family often share only few sequence features, but share by far more specific structural and functional properties. Consequently, methods for effective RNA homology search (i.e. finding new members of an RNA family) cannot rely on sequence similarity alone, but also have to take structural similarity into account.

In this paper, we address the problem of searching nucleotide databases for occurrences of RNA family members. Since for this task it is not sufficient to rely on pure sequence alignment, we briefly review search methods that employ sequence and structure information.

There exist various general sequence-structure alignment tools which determine structural similarities that are too diverse to be alignable at the sequence level. Such tools can roughly be divided into two classes. The first class consists of tools that align RNAs with given structures or determine a common structure during the alignment process. Tools like MARNA[3] and RNAforester[4] require an a priori known secondary structure for both input RNAs. However, they suffer from the low quality of secondary structure prediction. Addressing this problem, other tools implement variations of the Sankoff algorithm [5], which provides a general but computationally demanding solution to the problem of simultaneously computing an alignment and the common secondary structure of the two aligned sequences. Unfortunately, even tools with improved running times using variations of this algorithm (LocARNA[6], Foldalign[7,8], Dynalign[9,10]) or heuristics [11] are simply not fast enough for rapid searches in large nucleotide databases. Hence, in a second class we identify more specialized tools for searching RNA families in nucleotide databases. These tools use a model or motif descriptors (i.e. patterns) defining consensus sequence and secondary structure properties of the families to be searched for. For example, Infernal[12] and RSEARCH[13] infer a covariance model from a given multiple sequence alignment annotated with structure information. This model can then be used to search sequence databases for new family members. Another tool, ERPIN[14] is also based on automatically generated statistical secondary profiles. Although being very sensitive in RNA homology search, in particular Infernal and RSEARCH suffer from high computational demands. An alternative are tools like RNAMotif[15], RNAMOT[16], RNABOB[17], RNAMST[18], PatScan[19], PatSearch[20], or Palingol[21]. These methods use user-defined motif descriptors created from a priori knowledge about the secondary structure of the described RNA family. Another tool, Locomotif[22], generates a thermodynamic matcher program from a pattern drawn interactively by the user via a graphical interface. Although these tools based on motif descriptors are faster than the previously mentioned tools, they have a running time that scales at least linearly with the size of the target sequence database. This makes their application to large databases challenging. Previously, we addressed this problem by presenting Structator[23], an ultra fast index-based bidirectional matching tool that achieves sublinear running time by exploiting base pair complementarity constraints for search space reduction.

Apart from running time constraints, another major disadvantage of all current tools that search for sequence-structure patterns is their limited capacity to find approximate matches to the patterns. Although variability in length of pattern elements is often allowed, this is constrained to certain pattern positions that must be specified by the user. This limitation also holds for our Structator tool. Also, variations (insertions, deletions, or replacements) in the sequence that lead to small structural changes, such as the breaking of a base pair, are not supported. This often hampers the creation of patterns that are specific but generalized enough to match all family members. An algorithm presented in [24] only partially alleviates this problem by finding approximate matches of a helix in a genome allowing edit operations on single bases, but not on the structure.

To overcome these issues, we present new fast index-based and online algorithms for approximate matching of sequence-structure patterns, all implemented in an easy-to-use software package. Given one or more patterns describing any (branching, non-crossing) RNA secondary structure, our algorithms compute alignments of the complete patterns to substrings of the target sequence, i.e. semi-global alignments, taking sequence and structure into account. For this, they apply a full set of edit operations on single bases and base pairs. Matches are reported for alignments whose sequence-structure edit cost and number of insertions and deletions do not exceed user-defined thresholds. Our most basic algorithm is a scanning variant of the dynamic programming algorithm for global pairwise sequence-structure alignment of Jiang et al.[25], for which no implementation was available. Because its running time is too large for database searches on a large scale, we present accelerated online and index-based algorithms. All our new algorithms profit from a new computing scheme to optimally reuse the required dynamic programming matrices and a technique to save computation time by determining as early as possible whether a substring of the target sequence can contain a match. In addition, our index-based algorithms employ the suffix array data structure compiled from the search space. This further reduces the running time.

As in [23], we also support the description of an RNA molecule by multiple ordered sequence-structure patterns. In this way, the molecule’s secondary structure is decomposed into a sequence of substructures described by independent sequence-structure patterns. These patterns are efficiently aligned to the target sequences using one of our new algorithms and the results are combined with fast global and local chaining algorithms [23,26]. This allows a better balancing of running time, sensitivity, and specificity compared to searching with a single long pattern describing the complete sequence and secondary structure.

Before we describe our algorithms, we formalize the approximate search problem with the involved sequence-structure edit operations. Then we present, step by step, two efficient online and two index-based matching algorithms. We proceed with a short review of the approach for computing chains of matches. Finally, we present several benchmark experiments.

Methods

Preliminaries

An RNA sequenceS of length n = |S| over the set of bases <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M1','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M1">View MathML</a> is a juxtaposition of n bases from <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M2','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M2">View MathML</a>. S[i], 1 ≤ i ≤ n, denotes thebase ofS at positioni. Let ε denote the empty sequence, the only sequence of length 0. By <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M3','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M3">View MathML</a> we denote the set of sequences of length n ≥ 0 over <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M4','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M4">View MathML</a>. The set of all possible sequences over <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M5','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M5">View MathML</a> including the empty sequence ε is denoted by <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M6','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M6">View MathML</a>.

For a sequence S = S[1] S[2] … S[n] and 1 ≤ i ≤ j ≤ n, S[i..j] denotes the substringS[i] S[i + 1] … S[j] of S. For S = uv, u and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M7','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M7">View MathML</a>, u is a prefix of S, and v is a suffix of S. The k–th suffix of S starts at position k, while the k–th prefix of S ends at k. For 1 ≤ k ≤ n, Sk denotes the k–th suffix of S. For stating the space requirements of our index structures, we assume that |S| < 232, so that sequence positions and lengths can be stored in 4 bytes.

The secondary structure of an RNA molecule is formed by Watson-Crick pairing of complementary bases and also by the slightly weaker wobble pairs. We say that two bases <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M8','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M8">View MathML</a> are complementary and can form a base pair if and only if <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M9','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M9">View MathML</a>. If two bases a and b form a base pair we also say that there exists an arc between a and b. A non-crossing RNA structure<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M10','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M10">View MathML</a>of lengthm is a set of base pairs (i,j), 1 ≤ i < j ≤ m, stating that the base at position i pairs with the base at position j, such that for all <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M11','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M11">View MathML</a> or i < i < j < j or i < j < i < j or i < j < i < j. A standard notation for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M12','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M12">View MathML</a> is a structure string R over the alphabet {.,(,)} such that for each base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M13','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M13">View MathML</a>, R[i] = ( and R[j] = ), and R[r] = . for positions r, 1 ≤ r ≤ m, that do not occur in any base pair of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M14','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M14">View MathML</a>, i.e. r ≠ i and r ≠ j for all <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M15','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M15">View MathML</a>.

Let Φ = {R, Y, M, K, W, S, B, D, H, V, N} be a set of characters. According to the IUPAC definition, each character in Φ denotes a specific character class <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M16','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M16">View MathML</a>. Each character <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M17','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M17">View MathML</a> can be seen as a character class φ(x) = {x} of exactly one element. A sequence pattern is a sequence <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M18','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M18">View MathML</a>. An RNA sequence-structure pattern (RSSP)<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M19','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M19">View MathML</a> of length m is a pair of a sequence patternP and a structure stringR, both of length m. With <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M20','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M20">View MathML</a> we denote the RSSP region (P[i..j],R[i..j]).

Approximate matching of RNA sequence-structure patterns

To find in a long RNA sequence S approximate matches of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M21','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M21">View MathML</a> describing a part of an RNA molecule, we compute alignments of the complete <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M22','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M22">View MathML</a> and substrings of S considering edit operations for unpaired bases and base pairs. That is, we compute semi-global alignments simultaneously obtaining the sequence-structure edit distance of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M23','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M23">View MathML</a> and substrings of S.

We define the alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M24','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M24">View MathML</a> and a substring S[p..q], 1 ≤ p ≤ q ≤ n, as set A = Amatch ⊎ Agap. The set Amatch ⊆ [1..m] × [p..q] of match edges satisfies that, for all different (k,l),(k,l) ∈ Amatch, k > k implies l > l. The set Agap of gap edges is defined as <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M25','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M25">View MathML</a>. See Figure 1 for an example of a semi-global alignment and associated alignment edges. The alignment cost is based on a sequence-structure edit distance. The allowed edit operations on unpaired bases P[k] and S[l], 1 ≤ k ≤ m, p ≤ l ≤ q, are base mismatch (match), with cost ωm (zero), which occurs if there is an edge (k,l) ∈ Amatch and S[l] ∉ φ(P[k]) (S[l] ∈ φ(P[k])), and base deletion (insertion), with cost ωd, which occurs if (k,−) ∈ Agap ((−,l) ∈ Agap). The possible edit operations on base pairs were first introduced by Jiang et al.[25] and are defined as follows. Let (k1,k2) be a base pair in <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M26','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M26">View MathML</a> and l1 and l2, p ≤ l1 < l2 ≤ q, be positions in S.

• An arc breaking, with cost ωb, occurs if (k1,l1) ∈ Amatch and (k2,l2) ∈ Amatch but bases S[l1] and S[l2] are not complementary. An additional base mismatch cost ωm is caused if S[l1] ∉ φ(P[k1]) and another if S[l2] ∉ φ(P[k2]). To give an example, consider the semi-global alignment in Figure 1. RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M27','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M27">View MathML</a> contains base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M28','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M28">View MathML</a> and there exist edges (5,11) ∈ Amatch and (9,16) ∈ Amatch but S[11] = G and S[16] = G are not complementary. We note a difference between our definition and the definition of Jiang et al., where both aligned sequences are annotated with structure information. There, an arc breaking occurs if bases S[l1] and S[l2] are annotated as unpaired in addition to the condition of existing edges (k1,l1) ∈ Amatch and (k2,l2) ∈ Amatch. Hence, because in our case sequence S has no structure annotation, our definition is based on the complementarity of bases S[l1] and S[l2].

• An arc altering, with cost ωa, occurs if either (1) (k1,l1) ∈ Amatch and (k2,−) ∈ Agap or (2) (k2,l2) ∈ Amatch and (k1,−) ∈ Agap. Each case induces an additional base mismatch cost ωm if S[l1] ∉ φ(P[k1]) or S[l2] ∉ φ(P[k2]). As an example, observe in the alignment shown in Figure 1 that there exist a base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M29','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M29">View MathML</a> and edges (11,−) ∈ Agap and (16,21) ∈ Amatch.

• An arc removing, with cost ωr, occurs if (k1,−) ∈ Agap and (k2,−) ∈ Agap. As an example, observe in the alignment in Figure 1 that there exist a base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M30','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M30">View MathML</a>and edges (3,−) ∈ Agap and (19,−) ∈ Agap.

thumbnailFigure 1. Example of a semi-global alignment of a sequence-structure pattern<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M32','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M32">View MathML</a> and an RNA sequence S and involved sequence-structure edit operations. Continuous (dashed) lines indicate match (gap) alignment edges from Amatch (Agap).

With this set of edit operations on the sequence and structure we can now define the cost of the alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M33','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M33">View MathML</a> and S[p..q] as

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M34','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M34">View MathML</a>

(1)

where

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M35','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M35">View MathML</a>

(2)

An alignment A of minimum cost between <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M36','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M36">View MathML</a> and S[p..q] is an optimal alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M37','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M37">View MathML</a> and S[p..q].

In practice, one is often interested in finding substrings of an RNA sequence S having a certain degree of similarity to a given RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M38','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M38">View MathML</a> on both the sequence and structure levels. Therefore, we are only concerned about optimal alignments of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M39','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M39">View MathML</a> and substrings S[p..q] with up to a user-defined sequence-structure edit distance and a limited number of allowed insertions and deletions (indels). More precisely:

• the cost <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M40','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M40">View MathML</a> should not exceed a given threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M41','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M41">View MathML</a>, and

• the number of indels in the alignment should be at most d.

Thus, the approximate search problem for finding occurrences of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M42','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M42">View MathML</a> in S, given user-defined thresholds <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M43','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M43">View MathML</a> and d, is to report all intervals [p..q] such that

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M44','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M44">View MathML</a>

(3)

We call every substring S[p..q] satisfying Equation (3) a match of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M45','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M45">View MathML</a> in S. In the subsequent sections we present algorithms for searching for matches of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M46','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M46">View MathML</a> in a sequence S.

Online approximate RNA database search for RSSPs: ScanAlign

A straightforward algorithm to search for approximate matches of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M47','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M47">View MathML</a> in an RNA sequence S consists of sliding a window of length m = m + d along S while computing <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M48','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M48">View MathML</a> for 1 ≤ p ≤ q ≤ n and q − p + 1 = m. We note that, although the length of a match can vary in the range m − d to m + d, to find matches of all possible lengths it suffices to slide a window of length m along S corresponding to substrings S[p..q]. This holds because the alignment to a window of length m entails all possible alignments with up to d allowed indels. In the following we present a dynamic programming algorithm computing <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M49','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M49">View MathML</a> for every window S[p..q]. Our recurrences are derived from the algorithm for global pairwise sequence-structure alignment of Jiang et al.[25], i.e. an algorithm for aligning sequences of similar lengths. Although Jiang’s algorithm supports the sequence-structure edit operations described above, we emphasize that it is not suitable for computing semi-global alignments, which is what we are interested in.

We begin the description of our algorithm by defining three functions required by the dynamic programming recurrences. Let T = S[p..q].

1. For computing base match and mismatch costs for positions i and j of the RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M50','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M50">View MathML</a> and substring T, respectively, we define a function <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M51','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M51">View MathML</a> as:

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M52','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M52">View MathML</a>

(4)

2. To determine whether an arc breaking operation can occur, we must also be able to check for base complementarity at positions i and j of T. Therefore, we define a function <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M53','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M53">View MathML</a> as:

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M54','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M54">View MathML</a>

(5)

3. For determining the correct row (of the dynamic programming matrices introduced below) where certain operation costs must be stored we introduce a function <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M55','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M55">View MathML</a> defined as:

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M56','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M56">View MathML</a>

(6)

Intuitively, function row satisfies the following: (1) given the right index i of a base pair (i,i), it returns the left index i if (i,i) is preceded or followed by other structures; (2) given the left index i of a base pair (i,i), it returns 0 if the base at position i + 1 of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M57','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M57">View MathML</a> is unpaired; and (3) given any other position index i, it returns i itself.

Using these three functions, our algorithm determines the sequence-structure edit distance <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M58','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M58">View MathML</a> by computing a series of m + 1(m + 1) × (mk + 1) matrices DPk, for 1 ≤ k ≤ m + 1, such that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M59','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M59">View MathML</a>. We remark that DPk(i,j) is not defined for every subinterval [i..j]. While the recurrences of Jiang’s algorithm are divided in four main cases, we present a simplified recurrence relation with only two main cases. In addition, we observe that we use only three indices for a matrix entry instead of four. Our recurrences are as follows.

1. If i = 0 or R[i] =. (unpaired base), then

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M60','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M60">View MathML</a>

(7)

2. If R[i] ≠. (paired base), then

(a) If R[i] =) where i forms base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M61','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M61">View MathML</a>,

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M62','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M62">View MathML</a>

(8)

(b) If (a) holds and either R[i−1] =. or R[i−1] =), compute in addition to Equation (8)

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M63','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M63">View MathML</a>

(9)

A natural way to compute these DP matrices is top down, checking whether case 1, 2(a), or 2(b) applies, in this order. Due to the matrix dependencies in cases 2(a) and (b), the matrices need to be computed simultaneously.

Note that for all j, 1 ≤ j ≤ m, clearly <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M64','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M64">View MathML</a>. Therefore all candidate matches shorter than m beginning at position p are also computed in the computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M65','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M65">View MathML</a>. The following Lemma is another important contribution of this work and also the key for the development of an efficient algorithm.

Lemma 1

When sliding a window along S to compute<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M66','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M66">View MathML</a>, 1 ≤ p ≤ q ≤ n, m = q − p + 1 = m + d, a window shift by one position to the right requires to compute only column mk + 1, i.e. the last column of matrices DPk, 1 ≤ k ≤ m.

Proof

Let T[1..m] = S[p..q]. The computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M67','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M67">View MathML</a> requires to compute m + 1 DP matrices, one for each suffix Tk of string T = T[1..m], 1 ≤ k ≤ m, and one for the empty sequence ε. As a result, it holds for every k that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M68','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M68">View MathML</a> which is obtained as a by-product of the <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M69','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M69">View MathML</a> computation. Because each substring Tl+1[1..ml] = S[p + l..q], 0 ≤ l < m, only differs by its last character from S[p + l + 1..q + 1] which are suffixes of the window substring shifted by one position to the right, the lemma holds. □

Due to Lemma 1, our algorithm computes only the last column of the DP matrices for every shifted window substring (see the example in Figure 2) and just for the first window S[1..m] it computes every column. We call this algorithm ScanAlign. We note that during the reviewing process of this manuscript, Will et al.[27] submitted and published an algorithm for semi-global sequence-structure alignment of RNAs. As our method, this algorithm saves computation time by reusing entries of dynamic programming tables while scanning the target sequence.

thumbnailFigure 2. DP tables for the sequence-structure alignment computation of RSSP<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M71','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M71">View MathML</a> and window substring T = ACCCUCUU when scanning a sequence S with algorithm ScanAlign . Only the entries in red have to be computed for each window shift, whereas the entries in green are reused. Entries in yellow boxes are on a possible minimizing path for alignments with up to d = 1 indels. The following operation costs were used: ωd = ωm = 1, ωb = ωa = 2, and ωr = 3.

Our ScanAlign algorithm has the following time complexity: computing DPk(i,j) in cases 1 and 2(a) takes O(1) time and in case 2(b) it takes O(m) time. Now consider the two situations:

• For the first computed window substring S[1..m], cases 1 and 2(a) require O(mm′2) time in total and case 2(b) requires O(mm′3) time in total. This leads to an overall time of O(mm′3).

• For one window shift, cases 1 and 2(a) require O(mm) time in total and case 2(b) requires O(mm′2) time in total, leading to an overall time of O(mm′2).

Since there are n − m−1 window shifts, the computation for all shifted windows takes O(mm′2(nm)) = O(mm′2n) time. We observe that the time needed by ScanAlign to compute all window shifts reduces to O(mmn) if recurrence case 2(b) is not required. This is the case if the structure of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M72','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M72">View MathML</a> does not contain unpaired bases before a base pair constituting e.g. a left dangling end or left bulge.

Faster online alignment with early-stop computation: LScanAlign

Often, before completing the computation of the alignment between an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M73','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M73">View MathML</a> and a window substring S[p..q] of the searched RNA sequence, we can determine whether the cost of this alignment will exceed the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M74','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M74">View MathML</a>. By identifying this situation as early as possible, we can improve algorithm ScanAlign to skip the window, thus saving computation time and proceed with aligning the next window. The idea consists in checking, during the alignment computation, whether the cost of an already aligned region of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M75','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M75">View MathML</a> and a substring of S[p..q] exceeds <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M76','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M76">View MathML</a>. In such a case, the alignment cost of the complete <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M77','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M77">View MathML</a> and S[p..q] will also exceed <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M78','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M78">View MathML</a>. In more detail, this works as follows.

• We decompose the RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M79','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M79">View MathML</a> into regions that can themselves represent a pattern, e.g. a stem-loop or unpaired region. A basic constraint is to not split base pairs to different regions.

• We compute the alignment of a given initial RSSP region and a substring of the current window S[p..q], progressively extending the alignment to other regions.

• If the cost of aligning an RSSP region to a substring of the window exceeds cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M80','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M80">View MathML</a>, then the entire pattern cannot match the window. This means that the window can immediately be skipped.

Formally, a valid RSSP region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M81','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M81">View MathML</a>, 1 ≤ x ≤ y ≤ m, satisfies exactly one of the following conditions.

1. <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M82','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M82">View MathML</a> is a left dangling (unpaired) end of the pattern in 5 to 3 direction, i.e. x = 1. Alternatively, it is an unpaired region of maximal length such that position x − 1 forms a base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M83','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M83">View MathML</a> for some position y of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M84','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M84">View MathML</a>. Observe that no extension of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M85','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M85">View MathML</a> by another unpaired position is possible. As an example, consider the green marked regions <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M86','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M86">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M87','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M87">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M88','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M88">View MathML</a>, and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M89','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M89">View MathML</a> in Figure 3.

2. Position y is unpaired and there is at least one base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M90','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M90">View MathML</a>, x ≤ x < y < y. No extension of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M91','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M91">View MathML</a> by another unpaired position is possible. As examples of regions under these requirements, see the regions in orange of the RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M92','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M92">View MathML</a> in Figure 3, namely <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M93','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M93">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M94','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M94">View MathML</a>, and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M95','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M95">View MathML</a>.

3. <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M96','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M96">View MathML</a> is a base pair. For examples of such RSSP regions, see the regions in blue of the RSSP in Figure 3, namely <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M97','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M97">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M98','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M98">View MathML</a>, and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M99','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M99">View MathML</a>.

4. y forms a base pair <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M100','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M100">View MathML</a> where either R[x−1] =. or R[x−1] =), 1 ≤ x ≤ x−1. In addition, x = 1 or <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M101','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M101">View MathML</a> for some y > y. Examples of such RSSP regions are shown in red in Figure 3, i.e. regions <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M102','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M102">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M103','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M103">View MathML</a>, and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M104','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M104">View MathML</a>.

thumbnailFigure 3. Regions of RSSP<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M106','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M106">View MathML</a> according to conditions 1 (green), 2 (orange), 3 (blue), and 4 (red) described in the text.

Note that regions can be embedded in other regions but cannot partially overlap another.

Our progressive alignment computation of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M107','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M107">View MathML</a> and a window substring of the searched RNA sequence S begins by considering only an in general small region of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M108','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M108">View MathML</a> embedded in another region. The computation is then extended to a surrounding region, e.g. from region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M109','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M109">View MathML</a> to <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M110','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M110">View MathML</a> of the RSSP shown in Figure 3, until it entails the largest region surrounding all other regions, e.g. <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M111','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M111">View MathML</a> of the same example. Formally, we elaborate the alignment computation as follows. Let T = T[1..m] be a window substring of length m = m + d of S and d be the number of allowed indels. Pattern regions have the property that, for any region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M112','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M112">View MathML</a>, computing <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M113','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M113">View MathML</a> does not depend on any other region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M114','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M114">View MathML</a> for some y < x and x < y. Therefore, they can easily be sorted to indicate the order by which the rows of the DP matrices are computed. We observe that the top-down computation of the DP matrices, as described above, automatically sorts the regions and respects the dependency between rows. To obtain from the sorted regions the indices of the rows to be computed, we consider the condition satisfied by each region. The rows obtained according to each condition are computed according to one case of the recurrence. Given region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M115','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M115">View MathML</a> identified by one of the four conditions this region satisfies, the following rows of the matrices have to be computed.

1. All rows in the interval [x..y] are computed by Equation (7).

2. One scans the structure of region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M116','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M116">View MathML</a> from position y to position x until one finds a paired position y. Then, all rows in the interval [y + 1..y] are computed by Equation (7).

3. Row y is computed by recurrence (a) of Equation (8).

4. Row row(y) is computed by recurrence (b) of Equation (8).

The sequential computation of the rows belonging to each region naturally leads to the computation of the entire alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M117','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M117">View MathML</a> and sequence-structure edit distance <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M118','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M118">View MathML</a>.

Our improvement of the ScanAlign algorithm is based on the following two observations.

• The standard dynamic programming algorithm for aligning two plain text sequences of lengths m and n requires an (m + 1) × (n + 1) matrix. Let i and j be indices of each of the matrix dimensions and a diagonal v be those entries defined by i and j such that j − i = v. Given that the cost of each edit operation is a positive value, the cost of the entries along a diagonal of the matrix are always non-decreasing [28].

• Moreover, one indel operation implies that an optimal alignment path including an entry on diagonal v also includes at least one entry on diagonal v + 1 or v − 1. Now let v be the diagonal ending at the entry on the lower-right corner of the matrix and d be the number of allowed indels. One can stop the alignment computation as soon as all the entries of one row in the matrix and along diagonals v + d, −d ≤ d ≤ d, exceed <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M119','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M119">View MathML</a>.

For our improvement of algorithm ScanAlign, based on the following Lemma, we define a diagonal for each RSSP region instead of only one for the entire matrices.

Lemma 2

Assume an RSSP<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M120','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M120">View MathML</a>, a region<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M121','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M121">View MathML</a>of length l = y − x + 1, a window substring T[1..m] of the searched RNA sequence, a cost threshold<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M122','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M122">View MathML</a>, and number d of allowed indels. If for every d, −d ≤ d ≤ min{d,x}, z ∈ {|d|−d,−|d|+d}, y + d ≤ m, it holds that<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M123','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M123">View MathML</a>, then, for every d′′, 0 ≤ d′′ ≤ d, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M124','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M124">View MathML</a>.

Proof

If the RSSP region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M125','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M125">View MathML</a> originates from condition 1 or 2 (3 or 4) above, we define the entries on a diagonal e as those entries DPk(i,j) (DPk(row(y),j)), 1 ≤ k ± d ≤ m, such that j − i + offset = e, where offset = x − 1. Without loss of generality let d = 1. Assuming x − 1 > 0 and y + 1 ≤ m, this means that an optimal alignment of pattern <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M126','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M126">View MathML</a> and substring T requires <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M127','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M127">View MathML</a> to align with:

• T[x..y], T[x..y − 1], or T[x..y + 1], requiring for all three alignments the computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M128','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M128">View MathML</a> for z ∈ {0−1,0 + 1} = {−1,1};

• T[x − 1..y − 1], requiring the computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M129','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M129">View MathML</a> for z ∈ {|−1|−1,−|−1| + 1} = {0}; or

• T[x + 1..y + 1], requiring the computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M130','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M130">View MathML</a>for z ∈ {|1|−1,−|1| + 1} = {0}.

The alignments with T[x..y], T[x..y + 1], and T[x..y−1] end in matrix DPx. The alignments with T[x−1..y−1] end in matrix DPx−1, and the alignments with T[x + 1..y + 1] end in matrix DPx+1. Every minimizing path obtained for the entire alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M131','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M131">View MathML</a> and T can only include the entries on the diagonals e, e + 1, and/or e − 1 for the alignments with T[x..y], T[x..y + 1], and T[x..y − 1], and can only include the entries on diagonal e for the alignments with T[x − 1..y − 1] and T[x + 1..y + 1] because these substrings already imply alignments with one indel. As the sum of the cost of the edit operations on the minimizing path increases monotonically and there cannot be other minimizing paths due to the limited number of indels d, the lemma holds. □

Let <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M132','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M132">View MathML</a> be an RSSP whose regions are sorted by the order of computation of their respective rows in the DP tables above, let d be the number of allowed indels, and T = T[1..m] be a window substring of the searched RNA sequence. Applying Lemma 2, we modify algorithm ScanAlign to compute the alignment of each region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M133','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M133">View MathML</a> to substrings <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M134','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M134">View MathML</a>, −d ≤ d ≤ min{d,x}, y + d ≤ m, and progressively extend the alignment to other RSSP regions and substrings of T as long as <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M135','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M135">View MathML</a>, z ∈ {|d|−d,−|d| + d}, holds. That is, for each RSSP region, it determines the rows and recurrence case required for their computation according to conditions 1, 2, 3, or 4 above. Then, within each processed row i, it checks whether for at least one entry DPk(i,j) on a possible minimizing path, i.e. on diagonals e, e − d ≤ e ≤ e + d, DPk(i,j) ≤ k. If no entry is below <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M136','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M136">View MathML</a>, it skips the alignment computation for all remaining RSSP regions and proceeds with aligning the next window. See Figure 2 for an example of the DP matrices of an alignment computation whose entries on a possible minimizing path are highlighted in yellow.

When scanning the searched RNA sequence, a window can be shifted before all DP matrices entries are computed. Hence, a direct application of Lemma 1 is no longer possible. To overcome this, we define an array Z in the range 1 to z, where z is the number of RSSP regions, and associate each region with an index r, 1 ≤ r ≤ z. Let p be the starting position of the window substring S[p..q] in the RNA sequence. We set Z[r] = p whenever all DP matrices rows and columns belonging to region r are computed. This occurs when the cost of aligning this region does not exceed cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M137','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M137">View MathML</a>. Now, when aligning the same RSSP region r to a different window substring S[p..q], p > p, computing all DP matrices columns requires to compute the last p − p columns. If p − p < m (recall that m = q − p = qp), this means that the two window substrings do not overlap and therefore no DP matrix column can be reused.

Our improved algorithm, hereinafter called LScanAlign, in the worst case needs to process every RSSP region for every window shift. Hence, it has the same time complexity as algorithm ScanAlign. However, as in many cases only a few RSSP regions are evaluated, it is much faster in practice as will be shown later. ScanAlign and LScanAlign are the basis for further improvements presented in the subsequent sections.

Index-based search: LESAAlign

Suffix trees and enhanced suffix arrays are powerful data structures for exact string matching and for solving other string processing problems [29,30]. In the following we show how the use of enhanced suffix arrays leads to even faster algorithms for searching for matches of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M138','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M138">View MathML</a> in an RNA sequence S.

The enhanced suffix array of a sequence S is composed of the suffix array suf and the longest common prefix array lcp. Let $, called terminator symbol, be a symbol not in <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M139','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M139">View MathML</a> for marking the end of a sequence. $ is larger than all the elements in <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M140','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M140">View MathML</a>. suf is an array of integers in the range 1 to n + 1 specifying the lexicographic order of the n + 1 suffixes of the string S$. That is, Ssuf[1],Ssuf[2],...,Ssuf[n+1] is the sequence of suffixes of S in ascending lexicographic order. Table suf requires 4n bytes and can be constructed in O(n) time and space [31]. In practice non-linear time construction algorithms [32,33] are often used as they are faster. lcp is a table in the range 1 to n + 1 such that lcp[1] = 0, and lcp[i] is the length of the longest common prefix between Ssuf[i−1] and Ssuf[i] for 1 < i ≤ n + 1. Table lcp requires n bytes and stores entries with value up to 255, whereas occasional larger entries are stored in an exception table using 8 bytes per entry [30]. More space efficient representations of the lcp table are possible (see [34]). The construction of table lcp can be accomplished in O(n) time and space given suf[35]. For an example of an enhanced suffix array, see Figure 4. In the following we assume that the enhanced suffix array of S has already been computed.

thumbnailFigure 4. Enhanced suffix array of sequence S$ = CCACCCCCCACCCACCACCCUCUU$ consisting of the suffix array suf, longest common prefix array lcp, and inverse suffix array suf−1. For the definition of suf−1, see the section describing algorithm LGSlinkAlign.

Consider an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M141','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M141">View MathML</a> to be matched against an RNA sequence S with up to d indels. For each i, 1 ≤ i ≤ n, let pi = min{m + d,|Ssuf[i]|} be the reading depth of suffix Ssuf[i]. When searching for matches of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M142','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M142">View MathML</a> in S, we observe that algorithms ScanAlign and LScanAlign scan S computing <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M143','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M143">View MathML</a> for every window substring of length q − p + 1 = m + d. In the suffix array, each substring S[p..q] is represented by a suffix Ssuf[i] up to reading depth pi, i.e. there is a substring Ssuf[i][1..pi] such that Ssuf[i][1..pi] = S[p..q]. To match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M144','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M144">View MathML</a> in S using a suffix array, we simulate a depth first traversal of the lcp interval tree [30] of S on the enhanced suffix array of S such that the reading depth of each suffix is limited by pi. That is, we traverse the suffix array of S top down, computing the sequence-structure edit distance <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M145','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M145">View MathML</a>for each suffix Ssuf[i]. We recall that candidate matches of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M146','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M146">View MathML</a> have length between m − d and m + d and that pi ≤ m + d. In case pi < m − d, we can skip Ssuf[i]. Also, remember that all candidate matches shorter than pi are obtained as a by-product of the computation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M147','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M147">View MathML</a>. Hence, for every p, m − d ≤ p ≤ pi, if <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M148','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M148">View MathML</a> we report [suf[i]..suf[i] + p] as a matching interval of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M149','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M149">View MathML</a> in S. That is, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M150','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M150">View MathML</a> matches substring S[suf[i]..suf[i] + p] beginning at position suf[i] of S.

Our algorithm for the suffix array traversal and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M151','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M151">View MathML</a> computation, hereinafter called LESAAlign, builds on algorithms ScanAlign and LScanAlign. ScanAlign and LScanAlign exploit overlapping substrings of consecutive window substrings to avoid recomputation of DP matrices entries. LESAAlign exploits the enhanced suffix array in two different ways. First, for a single suffix Ssuf[i], i > 0, it benefits from the common prefix of length lcp[i] between two consecutive suffixes Ssuf[i] and Ssuf[i−1] by avoiding the recomputation of columns j, 1 ≤ j ≤ lcp[i] − k + 1, of each matrix DPk. This means that, for lcp = min{pi,lcp[i]}, it avoids the recomputation of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M152','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M152">View MathML</a> columns for Ssuf[i]. See an example in Figure 5. We observe that if pi ≤ lcp, no DP entry needs to be recomputed. In this case, two situations arise:

1. If pi ≤ lcp and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M153','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M153">View MathML</a>, then clearly <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M154','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M154">View MathML</a> and at least one match of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M155','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M155">View MathML</a> starts at position suf[i] of S; and

2. If pi ≤ lcp and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M156','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M156">View MathML</a>, then <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M157','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M157">View MathML</a>.

thumbnailFigure 5. DP tables for the sequence-structure alignment computation of RSSP<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M159','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M159">View MathML</a> and substringSsuf[i][1..8] = ACCCUCUU. Given that suffix Ssuf[i] shares a common prefix of length lcp[i] = 4 with Ssuf[i−1], algorithm LESAAlign reuses the entries in green and computes the entries in red. Used operation costs: ωd = ωm = 1, ωb = ωa = 2, and ωr= 3.

These situations allow LESAAlign to benefit from the enhanced suffix array in a second important way. That is, it skips all suffixes Ssuf[i], Ssuf[i+1],..., Ssuf[j] sharing a common prefix of at least length lcp with Ssuf[i−1]. To find the index j of the last suffix Ssuf[j] to be skipped, it suffices to look for the largest j such that min{lcp[i],lcp[i+1],...,lcp[j]} ≥ lcp. If the first situation above holds, there are matches of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M160','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M160">View MathML</a> in S at positions suf[i], suf[i +1 ],..., suf[j]. We note that suffixes can also be efficiently skipped using so-called skip-tables as described in [36]. However, to save the 4n additional bytes required to store such tables we do not use them here. Our algorithm continues the top-down traversal of the suffix array with suffix Ssuf[j+1], taking into account that the DP tables were last computed for Ssuf[i−1]. Consequently, the length of the longest common prefix between Ssuf[i−1] and Ssuf[j+1] to be considered in the processing of Ssuf[j+1] is min{lcp[i],lcp[i+1],...,lcp[j],lcp[j+1]}.

We also incorporate in our index-based algorithm the early-stop alignment computation scheme of algorithm LScanAlign. This allows to skip suffixes Ssuf[i] as soon as it becomes clear that the sequence-structure edit distance of RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M161','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M161">View MathML</a> and Ssuf[i] up to reading depth pi will exceed the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M162','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M162">View MathML</a>. For this, LESAAlign progressively aligns regions of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M163','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M163">View MathML</a> to a substring of the current suffix as in algorithm LScanAlign, checking whether the cost of each subalignment remains below the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M164','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M164">View MathML</a>, thus applying Lemma 2. If the cost exceeds <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M165','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M165">View MathML</a>, the alignment computation of the remaining pattern regions is skipped and the algorithm proceeds with processing the next suffix. To avoid recomputing as many entries of the DP matrices as possible while traversing the suffix array, LESAAlign differs from LScanAlign in the way it manages (non-) aligned regions for each suffix. Lemma 1, which algorithm LScanAlign applies to support early-stop computation, relies on scanning the searched RNA sequence S and overlapping window substrings. This makes it unsuitable for use with the suffix array. Instead, LESAAlign only uses information from the lcp table as follows. Let z be the number of regions of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M166','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M166">View MathML</a> indexed from 1 to z and T = Ssuf[i][1..pi] be the current substring. When progressively aligning the regions of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M167','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M167">View MathML</a> to a substring of T, we store the index r of the first region whose alignment cost exceeds <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M168','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M168">View MathML</a>, if there is any. That is, for the first region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M169','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M169">View MathML</a> whose index r we store, it holds that for every d, −d ≤ d ≤ min{d,x}, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M170','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M170">View MathML</a> with l = y − x + 1, z ∈ {|d|−d,−|d|+d}, and y+d ≤ m + d (see Lemma 2). Then, when aligning <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M171','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M171">View MathML</a> to a subsequent substring Ssuf[j][1..pj], we must distinguish the regions of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M172','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M172">View MathML</a>previously computed from regions not computed.

• Previously computed pattern regions are all regions whose index is strictly smaller than r. The alignment computation of these regions profits from the common prefix between Ssuf[i][1..pi] and Ssuf[ j][1..pj] by avoiding the recomputation of DP matrices columns as described above.

• Non-computed pattern regions are all regions whose index is larger than or equal to r. In this case, all DP matrices columns of the respective pattern region need to be computed, even if Ssuf[i][1..pi] and Ssuf[ j][1..pj] share a common prefix.

We observe that longer ranges of suffixes not containing matches to <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M173','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M173">View MathML</a>can be skipped thanks to the early-stop alignment computation scheme. Note that the left-most character of T needed to assert <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M174','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M174">View MathML</a> is T[x + l + d − 1] = T[x + y − x + 1 + d − 1] = T[y + d] as l = y − x + 1. Therefore, no suffix sharing prefix T[1..y + d] can match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M175','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M175">View MathML</a> and thus can be skipped in the top-down traversal of the suffix array of S. Because in most cases y + d < pi, more suffixes are likely to share a prefix of length y + d than of length pi with Ssuf[i]. For the pseudocode of algorithm LESAAlign, see Section 1 of Additional file 1.

Additional file 1. Supplemental material. Additional file 1 contains additional experiments, figures, and tables.

Format: PDF Size: 308KB Download file

This file can be viewed with: Adobe Acrobat ReaderOpen Data

Enhanced index-based search: LGSlinkAlign

Given an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M176','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M176">View MathML</a> to be searched in an RNA sequence S, algorithm LESAAlign is very fast when it can

• avoid recomputation of DP matrices columns due to a common prefix between suffixes of S; and

• skip long ranges of suffixes of the suffix array suf whose common prefix up to a required reading depth are known to match or not match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M177','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M177">View MathML</a>.

Therefore, LESAAlign exploits repetitions of substrings of S, i.e. substrings shared by different suffixes, and information of the lcp table to save computation time. However, the use of information of the lcp table alone does not necessarily lead to large speedups. Consider e.g. the DP matrices for the computation of the alignment of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M178','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M178">View MathML</a> and substring Ssuf[4][1..p4] = ACCCUCUU in Figure 5. The enhanced suffix array of S is shown in Figure 4. The substring Ssuf[4][1..p4] of length 8 shares a common prefix of length lcp[4] = 4 with the previously processed substring Ssuf[3][1..p3]. Despite this common prefix, still 182/252 ≈ 72% of the DP matrices entries need to be computed (disregarding initialization rows and columns 0) in case no early-stop is possible, i.e. in case <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M179','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M179">View MathML</a>. This is more than the at most 56/252 ≈ 22% of the DP matrices entries computed by the online algorithm LScanAlign for a window shift.

Our next goal is to develop an algorithm traversing the enhanced suffix array of S that:

1. can skip more suffixes; and

2. improves the use of already computed DP matrices entries, reusing computed entries for as many suffixes as possible.

To address the first goal, we motivate our method by recalling the alignment computation example in Figure 2. In this example, one of the regions of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M180','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M180">View MathML</a> is <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M181','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M181">View MathML</a>. Assume <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M182','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M182">View MathML</a> and observe that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M183','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M183">View MathML</a> for every d, −1 ≤ d ≤ 1, z ∈ {|d|−1,−|d| + 1}, i.e. the alignment cost for this pattern region already exceeds the cost threshold of 1 (in accordance with Lemma 2). In other words, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M184','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M184">View MathML</a> cannot align to any of the substrings T[2..6] = CCCUC, T[3..6] = CCUC, T[3..7] = CCUCU, T[3..8] = CCUCUU, or T[4..8] = CUCUU with a cost lower than 1. Observe further that the alignment computation of region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M185','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M185">View MathML</a> does not depend on any previous computation of any other region. We can therefore conclude that no suffix containing substring T[2..8]=CCCUCUU from position 2 to 8 can match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M186','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M186">View MathML</a>, independently of any prefix of length 1. Our goal is to find and eliminate from the search space all such suffixes, in addition to skipping all suffixes sharing prefix T[1..8] as performed by LESAAlign. That is, we want to skip suffixes sharing a substring, not limited to a prefix, whose alignment cost to a pattern region exceeds cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M187','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M187">View MathML</a>.

Let S be an arbitrary RNA sequence and T[x..y] = Ssuf[i][x..y] contain all substrings whose alignment cost to a region of an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M188','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M188">View MathML</a> exceeds threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M189','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M189">View MathML</a>. Consider the following two cases for skipping suffixes that cannot match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M190','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M190">View MathML</a> as a consequence of containing substring T[x..y] from position x to y. (1) For any value of x, all suffixes sharing prefix T[1..y] can be skipped as performed by algorithm LESAAlign. (2) Now let x > 1. To find all suffixes of S sharing substring T[x..y] from position x to y, we first locate all suffixes sharing T[x..y] as a prefix. We begin by locating one such suffix, in particular the suffix of index suf[j] that contains all but the first x = x − 1 characters of Ssuf[i], i.e. suffix <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M191','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M191">View MathML</a>. We determine j using a generalization of a concept originated from suffix trees. It is a property of suffix trees that for any internal node spelling out string T there is also an internal node spelling out T2 whenever |T| > 1 [37]. A pointer from the former to the latter node is called a suffix link. In the case of suffix arrays, a suffix link can be computed using the inverse suffix array suf−1 of S$. suf−1 is a table in the range 1 to n + 1 such that suf−1[suf[i]] = i. It requires 4n bytes and can be computed via a single scan of suf in O(n) time. Given table suf−1, we can define the suffix link from T = Ssuf[i] to T2 = Ssuf[i]+1 as link = suf−1[suf[i] + 1], i.e. it holds that suf[link] = suf[i] + 1. Now, if x = 1, we already find that the index suf[j] of the suffix containing all but the first character of Ssuf[i] is suf[j] = suf[link] because <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M192','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M192">View MathML</a> holds. However, we also want to be able to determine j for any x ≥ 1. The obvious solution is to compute suffix links x successive times. Each suffix link skips the first character of the previously located suffix. For a more efficient solution, we generalize suffix links to point directly to the suffix without a prefix of any length x of the initial suffix. For this purpose we define a function <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M193','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M193">View MathML</a> as:

<a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M194','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M194">View MathML</a>

(10)

Then, by letting j = link(i,x), <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M195','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M195">View MathML</a> holds for any x ≥ 1. All suffixes sharing T[x..y] as a prefix are all suffixes in the range jstart to jend where jstart is the smallest and jend is the largest index satisfying min{lcp[jstart + 1],...,lcp[j],...,lcp[jend]} ≥ y − x + 1. Finally, we find that all suffixes of S sharing substring T[x..y] from position x to y are all <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M196','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M196">View MathML</a>, <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M197','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M197">View MathML</a>, satisfying <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M198','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M198">View MathML</a>. To skip these suffixes not containing matches to <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M199','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M199">View MathML</a> in the top-down traversal of the suffix array suf, we mark their positions as true (for already“processed”) in a bit array vtab of n bits. The suffix array traversal proceeds from position suf[i], but skips the marked suffixes when their positions are reached.

We remark that the described method for skipping suffixes can profit from a resorting according to the order by which RSSP regions are aligned. In the alignment computation example in Figure 2, determining <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M200','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M200">View MathML</a>, −1≤d ≤ 1, z ∈ {|d|−1,−|d| + 1}, does not depend on character T[1] and region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M201','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M201">View MathML</a>. Hence, region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M202','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M202">View MathML</a> is unnecessarily aligned first when the regions are sorted by a top-down analysis of the DP tables. To decrease the chance that unnecessary computations occur, we sort the RSSP regions to begin aligning with the left-most RSSP region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M203','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M203">View MathML</a> not depending on the alignment of any other region and satisfying x − d > 1.

We now address the second goal, namely reusing computed DP matrices entries for as many suffixes as possible. Recall that computing the sequence-structure edit distance <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M204','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M204">View MathML</a> for each suffix Ssuf[i] up to reading depth pi means computing pi + 1DP matrices, one for each suffix Tk of string T = Ssuf[i][1..pi], 1 ≤ k ≤ m, and one for the empty sequence ε. Observe that each suffix Tk, Tk ≠ T, also occurs itself as a prefix of a suffix in table suf, i.e. there exists a suffix Ssuf[j] shorter than Ssuf[i] by exactly k − 1 characters which has prefix Tk. Consequently, Tk is processed again in an alignment to RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M205','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M205">View MathML</a> at a different point in time during the traversal of suf. Let T = Ssuf[j][1..pj]. Now note that if T is at a (nearly) contiguous position in suf to T, T and T are likely to share a common prefix due to their similar lexicographic ranking. This allows algorithm LESAAlign to avoid recomputation of DP matrices columns by using information from the lcp table. Unfortunately, T and T can be lexicographically ranked far away from each other in table suf, meaning that the DP matrices computed for T either:

• were already computed once because T is lexicographically smaller than T, but were discarded to allow the processing of other suffixes until T was traversed; or

• are computed for the first time otherwise, but will not be reused to also allow the processing of other suffixes until T occurs in table suf as a prefix of a suffix itself.

In both cases, redundant computations occur. To avoid this, we optimize the use of computed DP matrices by processing T directly after processing T for fixed k = 2, recalling that T = Ssuf[i][1..pi] and T = Ssuf[j][1..pj]. This value of k implies that Ssuf[j] does not contain the first character of Ssuf[i] and that we can locate Ssuf[j] in table suf by computing the suffix link j = link(i,1). Also, k = 2 implies that T only differs by its last character from T, aside from not beginning with character T[1]. Therefore, to determine <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M206','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M206">View MathML</a>, we only have to compute the last column of the DP matrices required to compute <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M207','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M207">View MathML</a> as shown by Lemma 1. We note that, because i and j are not necessarily contiguous positions in suf, we mark the processed suffix Ssuf[j] in the bit array vtab so that it is only processed once. If no match to RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M208','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M208">View MathML</a> begins at position suf[j], we also mark and skip every suffix sharing the substring with T whose alignment to a region of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M209','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M209">View MathML</a> is known to exceed threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M210','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M210">View MathML</a>. Once T is processed and all possible suffixes are skipped, we recursively repeat this optimization scheme by setting T = T and processing the next <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M211','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M211">View MathML</a> where j = link(j,1). The recursion stops when <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M212','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M212">View MathML</a>, meaning that T is too short to match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M213','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M213">View MathML</a>, or when suf[j] is already marked as processed in vtab. The suffix array traversal proceeds at position i + 1 repeating the entire scheme.

We call our algorithm incorporating the presented improvements LGSlinkAlign. For its pseudocode, see Section 1 of Additional file 1. LGSlinkAlign inherits all the improvements of the above presented algorithms. In summary, its improvements are as follows.

• LGSlinkAlign traverses the enhanced suffix array of the searched sequence S, i.e. the suffix array suf enhanced with tables lcp and suf−1. During this traversal, it benefits from common prefixes shared among suffixes to (1) avoid the computation of DP matrix columns and to (2) skip ranges of suffixes known to match or not match RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M214','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M214">View MathML</a> as in algorithm LESAAlign.

• The suffix array traversal is predominantly top down, but non-contiguous suffixes are processed to optimize the use of computed DP matrices.

• LGSlinkAlign stops the alignment computation as early as the alignment cost of a region of RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M215','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M215">View MathML</a> and a substring of the prefix of the current suffix exceeds threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M216','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M216">View MathML</a>, an improvement first introduced in algorithm LScanAlign.

• Due to the early-stop computation scheme, suffixes sharing common prefixes shorter than m + d can be skipped, leading to larger ranges of skipped suffixes. The early-stop computation scheme also helps to identify and skip non-contiguous suffixes sharing a common substring which is not their prefix.

Example: searching for an RSSP with algorithm LGSlinkAlign

We elucidate the ideas of algorithm LGSlinkAlign with the following example. Consider the RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M217','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M217">View MathML</a> to be matched in the sequence S whose enhanced suffix array is shown in Figure 4. To keep the example simple, we only allow a small cost threshold and number of indels, i.e. we set <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M218','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M218">View MathML</a>. The costs of the edit operations are ωd = ωm = ωb = ωa = 1 and ωr = 2. When traversing the enhanced suffix array of S, LGSlinkAlign always begins to align <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M219','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M219">View MathML</a> to a substring of S with region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M220','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M220">View MathML</a>, because the alignment computation of this region does not depend on any other region. In addition, the left index of this region satisfies 4 − d > 1. This means that the alignment computation of region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M221','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M221">View MathML</a> is avoided if the cost of aligning region <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M222','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M222">View MathML</a> exceeds the threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M223','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M223">View MathML</a>. The algorithm starts the traversal of the enhanced suffix array of S aligning <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M224','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M224">View MathML</a> to substrings of T = Ssuf[1][1..p1] = S14[1..8] from positions 4 − d = 3 and 6 + d = 7. For this, it computes <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M225','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M225">View MathML</a> for −1 ≤ d ≤ 1 and z ∈ {|d|−1,−|d|+1}. Observe that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M226','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M226">View MathML</a> holds. Hence (1) no suffix with prefix T[1..6] = AACACC can match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M227','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M227">View MathML</a> and thus can be skipped and (2) no suffix containing substring T[3..6] = CACC from position 4−d = 3 to 5 + d = 6 can match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M228','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M228">View MathML</a> and thus can be skipped as well. We notice that there is no other suffix with prefix AACACC because lcp[2] < 6, so we analyze case (2). The algorithm looks for suffixes sharing substring CACC from position 3 to 6. It begins by locating suffixes without the first two characters of T and containing CACC as a prefix. It follows the suffix link link(1,2) = suf−1[suf[1]+2] = suf−1[16] = 7 and looks for the smallest jstart and largest jend satisfying min{lcp[jstart + 1],...,lcp[8],...,lcp[jend]} ≥ 4 = |CACC|. It finds that jstart = 5 and jend = 8, since min{lcp[5+1],lcp[7],lcp[8]} = min{4,5,5} ≥ 4 holds. The suffixes containing CACC from position 3 to 6 are Ssuf[5]−2 = S11, Ssuf[6]−2 = S7, and Ssuf[8]−2 = S14. S11and S7 are marked in the bit array vtab, whereas S14 = Ssuf[1] was already processed and does not need to be marked. We observe that Ssuf[7]−2 = S−1 is not a valid suffix. To reuse as many computed DP matrices entries as possible, the algorithm next processes the suffix Ssuf[j] which does not contain the first character of Ssuf[1]. It determines j = link(1,1)=suf−1[suf[1]+1] = 11 and sets T = Ssuf[12][1..p12] = S15[1..8]. The alignment to this substring T begins with its substrings from positions 3 to 7 and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M229','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M229">View MathML</a>. We observe that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M230','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M230">View MathML</a> holds and consequently T cannot match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M231','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M231">View MathML</a>. Because suffix Ssuf[12] = S15 was traversed via a suffix link, it is marked as processed in vtab. We now again analyze two cases of suffixes that cannot match <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M232','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M232">View MathML</a> and therefore can be skipped: (1) suffixes sharing prefix T[1..6] = CCACCC and (2) suffixes containing substring T[3..6] = ACCC from position 3 to 6. Satisfying case (1) are suffixes Ssuf[11] = S1 and Ssuf[10] = S8 since lcp[12] ≥ 6 and lcp[11] ≥ 6. These suffixes are marked in vtab. We now check if there are suffixes satisfying case (2). The algorithm begins by locating suffixes containing substring T[3..6] = ACCC as a prefix. For this, it follows the suffix link link(12,2) = suf−1[suf[12] + 2] = 4 and determines jstart = 2 and jend = 4. The property min{lcp[2 + 1],lcp[4]} ≥ 4 is satisfied. The suffixes containing ACCC from position 3 to 6 are Ssuf[2]−2 = S8, Ssuf[3]−2 = S1, and Ssuf[4]−2 = S15. Since these were already marked in vtab, none of them needs to be marked. The algorithmic scheme of LGSlinkAlign to reuse as many computed DP matrices entries as possible continues processing other suffixes which are located by iteratively following the suffix links. It locates suffixes Ssuf[8], Ssuf[4], Ssuf[18], and Ssuf[19] because link(12,1) = 8, link(8,1) = 4, link(4,1) = 18, and link(18,1) = 19, respectively. These suffixes are processed analogously as above, one after the other, not resulting in matches to <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M233','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M233">View MathML</a>. The iteration then leads to suffix Ssuf[20], since link(19,1) = 20. However, |Ssuf[20]| < md, meaning that this suffix is too short to contain a match to <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M234','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M234">View MathML</a>. This causes the iteration to stop. The suffix array traversal proceeds and repeats the entire matching scheme from the suffix that follows the last processed suffix not located via a suffix link, i.e. suffix Ssuf[2]. After processing and skipping all possible suffixes, we note that LGSlinkAlign does not report any matches for the defined cost threshold and allowed number of indels <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M235','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M235">View MathML</a>. By setting <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M236','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M236">View MathML</a>, it reports a match at position 16.

RNA secondary structure descriptors based on multiple ordered RSSPs

RNAs with complex branching structures often cannot be adequately described by a single RSSP due to difficulties in balancing sensitivity, specificity, and reasonable running time of the used search algorithm. Although their description by a single short RSSP specifying an unbranched fragment of the molecule might be very sensitive, it is often too unspecific and likely to generate many spurious matches when searching for structural homologs in large sequence databases or complete genomes. In contrast, using a single long RSSP often requires a higher cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M237','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M237">View MathML</a> for being sensitive enough which in turn, together with the increased RSSP length, has a negative influence on the search time. This might lead to disadvantageous running times in larger search scenarios in practice.

We solve this problem by applying the powerful concept of RNA secondary structure descriptors (SSDs for short) recently introduced in [23]. The underlying concept of SSDs is similar to the idea of PSSM family models [38], which are successfully used for fast and sensitive protein homology search. SSDs use the information of multiple ordered RSSPs derived from the decomposition of an RNA’s secondary structure into stem-loop like structural elements. In a first step, approximate matches to the single RSSPs the SSD consists of are obtained using one of the algorithms presented above. From these matches, either local or global high-scoring chains are computed with the efficient chaining algorithms described in [23]. These algorithms take the chain’s score, i.e. the weights of the fragments in the chain, into account (see [23] for details). For chaining of approximate RSSP matches, we use the fragment weight <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M238','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M238">View MathML</a> for an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M239','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M239">View MathML</a> of length m matching substring T, where <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M240','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M240">View MathML</a> and bps denotes the number of base pairs in <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M241','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M241">View MathML</a>. Here <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M242','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M242">View MathML</a> is the maximal possible weighting <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M243','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M243">View MathML</a> can gain when being aligned and therefore it reflects the situation of a perfect match between <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M244','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M244">View MathML</a> and T. With this definition of a fragment’s weight, a positive weight is always guaranteed, thus satisfying a requirement for the chaining algorithm. Once the chaining of matches to the RSSPs is completed, the high-scoring chains are reported in descending order of their chain score. By restricting to high-scoring chains, spurious RSSP matches are effectively eliminated. Moreover, the relatively short RSSPs used in an SSD can be matched efficiently with the presented algorithms leading to short running times that even allow for the large scale application of approximate RSSP search.

Results and discussion

Implementation and computational results

We implemented (1) the fast index-based algorithms LESAAlign and LGSlinkAlign, (2) the online algorithms LScanAlign, ScanAlign, both operating on the plain sequence, and (3) the efficient global and local chaining algorithms described in [23]. In our experiments we use ScanAlign, which is the scanning version of the method proposed in [25], for reference benchmarking. All algorithms are included in the program RaligNAtor. The algorithms for index construction were implemented in the program sufconstruct, which makes use of routines from the libdivsufsort2 library (see http://code.google.com/p/libdivsufsort/ webcite) for computing the suf table in O(n log n) time. For the construction of table lcp we employ our own implementation of the linear time algorithm of [35]. All programs were written in C and compiled with the GNU C compiler (version 4.5.0, optimization option -O3). All measurements are performed on a Quad Core Xeon E5620 CPU running at 2.4 GHz, with 64 GB main memory (using only one CPU core). To minimize the influence of disk subsystem performance, the reported running times are user times averaged over 10 runs. Allowed base pairs are canonical Watson-Crick and wobble, unless stated otherwise. The used sequence-structure operation costs are ωd = ωm = ωb = ωa = 1 and ωr = 2.

Comparison of running times

In a first benchmark experiment we measure the running times needed by the four algorithms to search with a single RSSP under different cost thresholds <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M245','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M245">View MathML</a> and number of allowed indels d. We set (1) <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M246','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M246">View MathML</a> varying the values in the interval [0,6], (2) <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M247','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M247">View MathML</a>varying d in the interval [0,6], and (3) d = 0 varying <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M248','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M248">View MathML</a> in the interval [0,6]. The searched dataset contains 2,756,313 sequences with a total length of ≈786 MB from the full alignments of all Rfam release 10.1 families. The construction of all necessary index tables needed for LESAAlign and LGSlinkAlign with sufconstruct and their storage on disk required 372 seconds. In the following we refer to this dataset as RFAM10.1 for short. In this experiment we use the RSSP tRNA-pat of length m = 74 shown in Figure 6 describing the consensus secondary structure of the tRNA family (Acc.: RF00005). The results of this experiment are presented in Figure 7 and Table S4, S5, and S6 of Additional file 1. LGSlinkAlign and LESAAlign are the fastest algorithms. LGSlinkAlign is faster in particular for increasing values of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M249','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M249">View MathML</a> and d, being only slower than LESAAlign for small values of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M250','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M250">View MathML</a> and d and for fixed d = 0. The advantage of LGSlinkAlign over LESAAlign with higher values of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M251','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M251">View MathML</a> and d is explained by the increased reading depth in the suffix array implicated by <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M252','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M252">View MathML</a> and d and the fewer suffixes sharing a common prefix that can be skipped. This holds for both LGSlinkAlign and LESAAlign, however LGSlinkAlign counterbalances this effect by reusing computed DP matrices for non-contiguous suffixes of the suffix array. In a comparison to the two online algorithms considering only approximate matching, i.e. <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M253','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M253">View MathML</a>, the speedup factor of LGSlinkAlign over ScanAlign (LScanAlign) is in the range from 560 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M254','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M254">View MathML</a> and d = 0 to 17 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M255','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M255">View MathML</a> (from 15 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M256','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M256">View MathML</a> and d = 0 to 3 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M257','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M257">View MathML</a>). LESAAlign achieves a speedup factor over ScanAlign (LScanAlign) in the range from 1,323 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M258','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M258">View MathML</a> and d = 0 to 9 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M259','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M259">View MathML</a> (29 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M260','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M260">View MathML</a> and d = 0 to 1.6 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M261','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M261">View MathML</a>). In a comparison between the online algorithms, LScanAlign is faster than ScanAlign by up to factor 45 for <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M262','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M262">View MathML</a>. In summary, all algorithms except ScanAlign profit from low values of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M263','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M263">View MathML</a> and d reducing their search times. This is a consequence of the use of the early-stop alignment computation scheme. As shown in Figure 7(2), also the number of allowed indels d influences the search time. For an additional experiment investigating the influence of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M264','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M264">View MathML</a> and d on the search time required by the four algorithms, see Section 2 of Additional file 1. A further experiment, described in Section 3 of Additional file 1, compares RaligNAtor and the widely used tool RNAMotif[15] in terms of sensitivity and specificity in searches for the tRNA-pat depicted in Figure 6.

thumbnailFigure 6. Consensus secondary structure of the tRNA family (Acc.: RF00005) as drawn byVARNA[39] (top) and respective sequence-structure patterntRNA-pat(bottom).

thumbnailFigure 7. Running times (in minutes andlog10 scale) needed by the different algorithms to search with an RSSP describing the tRNA inRFAM10.1. In (1) the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M265','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M265">View MathML</a> and the number of allowed indels d are identical. In (2) <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M266','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M266">View MathML</a>is constant and d ranges from 0 to 6. In (3) d = 0 is constant and <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M267','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M267">View MathML</a> ranges from 0 to 6. The numbers of resulting matches are given on the x-axes in brackets.

Scaling behavior of the online and index-based algorithms

In a second experiment we investigate how the search time of algorithms ScanAlign, LScanAlign, LESAAlign, and LGSlinkAlign scales on random subsets of RFAM10.1 of increasing size. The searched RSSPs flg1, flg2, and flg3 were derived from the three stem-loop substructures the members of family flg-Rhizobiales RNA motif (Acc.: RF01736) [40] fold into. These patterns differ in length, cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M268','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M268">View MathML</a> and number of allowed indels d; see Figure 8 for their definition, noting that <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M269','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M269">View MathML</a> and d are simply denoted cost and indels in the RaligNAtor RSSP syntax. The results are shown in Figure 9 and Table S7 of Additional file 1. LGSlinkAlign and LESAAlign show a sublinear scaling behavior, whereas LScanAlign and ScanAlign scale linearly. The fastest algorithm is LGSlinkAlign, requiring only 11.68 (53.08) minutes to search for all three patterns in the smallest (full) subset. The second fastest algorithm is LESAAlign, followed by LScanAlign and ScanAlign, which require 32.27 (126.97), 40.47 (321.01), and 98.35 (754.66) minutes, respectively, to search for all the patterns in the smallest (full) subset. This corresponds to a speedup of 8.4 to 14.2 of LGSlinkAlign over ScanAlign on the smallest and the full subsets. Comparing the search time for pattern flg3 individually, the speedup of LGSlinkAlign over ScanAlign ranges from 22.6 to 38.8. We also observe that ScanAlign requires the longest time to match the longest pattern flg2 of length m = 37. The other algorithms profit from the early-stop computation approach to reduce the search time for this pattern on every database subset.

thumbnailFigure 8. Consensus secondary structure of family flg-Rhizobiales RNA motif (Acc.: RF01736) showing its three stem-loop substructureshp1,hp2, andhp3as drawn byVARNA[39]. The secondary structure descriptor (SSD) for this family, on the right-hand side, consists of three RSSPs flg1, flg2, and flg3 derived from the stem-loop substructures.

thumbnailFigure 9. Scaling behavior of algorithms LGSlinkAlign , LESAAlign , LScanAlign , and ScanAlign when searching with RSSPsflg1,flg2, andflg3, in subsets ofRFAM10.1, of different length. For details, see main text.

Influence of stem and loop lengths on the search time

When searching a database for matches of a given pattern, our algorithms compute the required DP matrices using recurrences according to two main cases: either a row corresponds to an unpaired or to a paired base of the pattern. To analyze the influence of the used recurrence on the search time of each algorithm, we search RFAM10.1 for artificial stem-loop patterns. Therefore we vary the number of bases in the loop of pattern <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M270','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M270">View MathML</a> from 3 to 12 by using As and Cs. Additionally, we vary the number of base pairs in the stem of pattern <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M271','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M271">View MathML</a> from 2 to 11 by pairs of Ns. Matching the patterns in these two experiments means to increase the use of the DP recurrences in Equations (7) and (8), respectively. The cost threshold and the number of allowed indels are fixed at <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M272','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M272">View MathML</a>. Allowed base pairs are (A, U), (U, A), (C, G), and (G, C). The results are shown in Figure 10. We observe that increasing the number of bases in the loop has little influence and even reduces the running time of the two fastest algorithms LGSlinkAlign and LESAAlign. This can be explained by the use of the early-stop alignment computation scheme in these algorithms. The reduction of the running time is explained by the fewer matches that need to be processed as the pattern gets longer and more specific. For an increasing number of base pairs in the stem, LGSlinkAlign is the least affected algorithm. We also observe that the linear increase in running time of the basic online algorithm ScanAlign, caused by an extension of the pattern by one base pair, is similar to the effect of adding two bases in the loop.

thumbnailFigure 10. Search times for different number of bases in the loop (left-hand side) and base pairs in the stem (right-hand side) for given RSSPs.

RNA family classification by global chaining of RSSP matches

In the next experiment we show the effectiveness of global chaining when searching with two SSDs built for Rfam families Cripavirus internal ribosome entry site (Acc.: RF00458) and flg-Rhizobiales RNA motif (Acc.: RF01736) [40]. These two families present only 53% and 69% sequence identity, respectively, much below the average of ∼80% of the Rfam 10.1 families. This illustrates the importance of using both sequence and structure information encoded in the SSDs of this experiment. The SSD of family RF01736 comprises three RSSPs, denoted by flg1, flg2, and flg3 in Figure 8, derived from the three stem-loop substructures the members of this family fold into. The SSD of family RF00458 comprises five RSSPs, denoted by ires1, ires2, ires3, ires4, and ires5 in Figure S5 of Additional file 1, where the last four RSSPs describe the stem-loop substructures the members of this family fold into. ires1 describes a moderately conserved strand occurring in these members. Observe also in Figures 8 and S5 the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M273','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M273">View MathML</a> and allowed number of indels d used per pattern, remembering that these are denoted cost and indels in the RaligNAtor RSSP syntax.

Searching with the SSD of family RF00458 in RFAM10.1 delivers 16,033,351 matches for ires1, 8,950,417 for ires2, 1,052 for ires3, 112 for ires4, and 1,222,639 for ires5. From these matches, RaligNAtor computes high-scoring chains of matches, eliminating spurious matches and resulting in exactly 17 chains. Each chain occurs in one of the 16 sequence members of the family in the full alignment except in sequence AF014388, where two chains with equal score occur. The highest (lowest) chain score is 171 (162). Using ScanAlign, LScanAlign, LESAAlign, and LGSlinkAlign, the search for all five RSSPs requires 688.32, 585.59, 186.88, and 92.25 minutes, respectively, whereas chaining requires 13.66 seconds. See Table S8 of Additional file 1 for the time required to match each pattern using the different algorithms.

The same search is performed using the SSD of family RF01736. It results in 4,145 matches for flg1, 68,024 for flg2, and 67 for flg3. Chaining the matches leads to 15 chains occurring each in one of the 15 sequence members of the family in the full alignment. The highest (lowest) chain score is 163 (156). Using ScanAlign, LScanAlign, LESAAlign, and LGSlinkAlign, the search for all three RSSPs requires 755.48, 336.69, 133.58, and 52.86 minutes, respectively, whereas chaining requires 0.03 seconds. The time required to match each pattern using each algorithm is reported in Table S9 of Additional file 1.

We also show that the lack of the sequence-structure edit operations supported by RaligNAtor deteriorates sensitivity and specificity in the search for sequence members of families RF00458 and RF01736. For this, we report in Section 4 and Table S10 of Additional file 1 results obtained with the Structator tool [23]. Structator is much faster but, in contrast to RaligNAtor, does not support all sequence-structure edit operations.

Importance of structural constraints for RNA family classification

To assess the potential of using RSSPs for reliable RNA homology search on a broader scale and to investigate the effect of using base pairing information, we evaluated RaligNAtor on 35 RNA families taken from Rfam 10.1 with different degrees of sequence identity and of different sizes. See Table 1 for more information about the selected families. In our experiment, we compared (1) RaligNAtor results obtained by using RSSPs derived from Rfam seed alignments with (2) results obtained for the same RSSPs ignoring base pairing information and (3) results obtained by blastn[41] searches with the families’ consensus sequence. For each selected family, we automatically compiled an RSSP <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M274','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M274">View MathML</a> from the family’s seed alignment using the following procedure: at each position of the RSSP’s sequence pattern P, we choose the IUPAC wildcard matching all symbols in the corresponding alignment column. As structure string R, we use the secondary structure consensus available in the Rfam seed alignment. From the resulting RSSPs we remove the maximum prefix and suffix containing neither sequence information (i.e. IUPAC symbol N) nor base pairing information. To obtain a query sequence for blastn, we compute the consensus sequence from the family’s seed alignment. Because blastn does not appropriately handle IUPAC wildcard characters in the query, we choose the most frequent symbol occurring in a column as representative symbol in the consensus sequence. For the RaligNAtor searches, we adjust the cost threshold <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M275','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M275">View MathML</a> and number of allowed indels d such that we match the complete family. That is, we achieve a sensitivity of 100%. The used operation costs are ωd = ωm = 1, ωb = ωa = 2, and ωr = 3. For the Blast searches, we called blastn with parameters -m8 -b 250000 -v 250000 and a very relaxed E-value cutoff of 1000. From the two RaligNAtor and one blastn outputs we count the number of true positives (#TPs) and false positives (#FPs) and compute ROC curves on the basis of the RaligNAtor score <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M276','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M276">View MathML</a> and the blastn bit score. See Table 1 and Figure 11 for the results of this experiment. A ROC curve with values averaged over all families is shown in Figure 11(1).

Table 1. Results of RaligNAtor and blastn database searches for members of RNA families of different degrees of sequence identity inRFAM10.1

thumbnailFigure 11. Results of ROC analyses using RaligNAtor with and without base pairing information and blastn for the 35 selected Rfam families shown in Table1. ROC curves showing RaligNAtor’s classification performance using (ignoring) base pairing information are shown in green (blue). Blast performance results are shown in red. Subfigure (1) shows the performance results averaged over all selected families. (2) and (3) show each the ROC analysis for the family with the lowest and highest level of sequence identity.

In addition, we show in Figures 11(2) and (3) the results of the ROC analysis for the families with the lowest and highest degree of sequence identity. For the ROC curve of each selected family, see Figures S7 and S8 of Additional file 1. Clearly, by using base pairing information, RaligNAtor achieves a higher sensitivity with a reduced false positive rate compared to searches ignoring base pairing (compare columns “RaligNAtor” and “RaligNAtor (sequence only)” in Table 1). This is in particular evident when searching for families with a low degree of sequence identity. This can be explained by the small amount of information left in the RSSP for such a family, once the structural information is removed. Due to the high variability of bases in the columns of the multiple alignment of the family, the pattern contains a large number of wildcards. These symbols alone, without the constraints imposed by the base pairs, lead to unspecific patterns and therefore to a large number of false positives. We observe that, for families with sequence identity of up to 59%, the area under the curve (AUC) is considerably larger when base pairing information is taken into account. This difference decreases with increasing sequence identity (compare Figures 11(2) and (3)). Overall, the average AUC value over all families is, with a value of 0.93, still notably higher when base pairing information is considered compared to 0.89 if base pairing information is ignored (see Table 1). In this experiment, blastn only finds all members of those families whose sequence identity is at least 85%. This is due to the fact that blastn cannot appropriately handle IUPAC wildcard characters. Hence, by taking the most frequent symbol in an alignment column as consensus symbol, the heterogeneity of less conserved positions in the alignment cannot be adequately modeled. For the blastn searches, the average AUC value over all families is only 0.72.

RaligNAtor software package

RaligNAtor is an open-source software package for fast approximate matching of RNA sequence-structure patterns (RSSPs). It allows the user to search target RNA or DNA sequences choosing one of the new online or further accelerated index-based algorithms presented in this work. The index of the sequence to be searched can be easily constructed with program sufconstruct distributed with RaligNAtor.

Searched RSSPs can describe any (branching, non-crossing) RNA secondary structure; see examples in Figures 1, 6, 8, and S5 of Additional file 1. Bases composing the sequence information of RSSPs can be ambiguous IUPAC characters. As part of the search parameters for RSSPs, the user can specify the cost of each sequence-structure edit operation defined above, the cost threshold of possible matches, and the number of allowed indels. The RSSPs, along with costs and thresholds per RSSP, are specified in a simple text file using a syntax that is expressive but easy to understand as shown in the mentioned figures. Another possibility is to provide the same costs and thresholds for all searched patterns as parameters in the command line call to RaligNAtor. To ensure maximal flexibility, the user can also define the base pairing rules from an arbitrary subset of <a onClick="popup('http://www.biomedcentral.com/1471-2105/14/226/mathml/M279','MathML',630,470);return false;" target="_blank" href="http://www.biomedcentral.com/1471-2105/14/226/mathml/M279">View MathML</a> as valid pairings in a separate text file. Searches can be performed on the forward and reverse strands of the target sequence. Searching on the reverse strand is implemented by reversal of the RSSP and transformation according to Watson-Crick base pairing. Wobble pairs {(G,U), (U,G)} automatically become {(C,A), (A,C)}. Due to these transformations, the index is built for one strand only.

For describing a complex RNA with our concept of secondary structure descriptor (SSD), i.e. with multiple RSSPs, the user specifies all RSSPs in one text file. The order of the RSSPs in the file will then specify the order of the RSSP matches used to build high-scoring chains. The chain score directly depends on the score of each match occurring in the chain. This is inversely proportional to the sequence-structure edit distance of the RSSP and its matching substring in the target sequence. Hence, higher scores indicate sequences with a higher conservation which are probably more closely related to the sought RNA family.

Chaining of matches discards spurious matches not occurring in any chain. An additional filtering option eliminates matches overlapping another with a higher score for the same RSSP. This is particularly useful when indels lead to almost identical matches that are only shifted by a few positions in the target sequence.

The output of RaligNAtor includes not only matching positions to single RSSPs and chains, but their sequence-structure alignment to the matched substrings as well. In the RaligNAtor software package, all programs for searching patterns support multithreading to take advantage of computer systems with multiple CPU cores. There are two modes of parallelism. At first, different patterns are searched using multiple threads. Additionally, the search space (i.e. the sequence for the online algorithms and the index structure for the index-based methods) is partitioned, processing each part using a different thread. Lastly, we remark that our software also provides an implementation of the original algorithm of Jiang et al. for global sequence-structure alignment [25], easily applicable by the user.

Conclusions

We have presented new index-based and online algorithms for fast approximate matching of RNA sequence-structure patterns. Our algorithms, all implemented in the RaligNAtor software, stand out from previous search tools based on motif descriptors by supporting a full set of edit operations on single bases and base pairs. See Table 2 for an overview of the algorithms. In each algorithm, the application of a new computing scheme to optimally reuse the entries of the required dynamic programming matrices and an early-stop technique to avoid the alignment computation of non-matching substrings led to considerable speedups compared to the basic scanning algorithm ScanAlign. Our experiments show superior performance of the index-based algorithms LGSlinkAlign and LESAAlign, which employ the suffix array data structure and achieve running time sublinear in the length of the target database. When searching for approximate matches of biologically relevant patterns on the Rfam database, LGSlinkAlign (LESAAlign) was faster than ScanAlign and LScanAlign by a factor of up to 560 (1,323) and 17 (29), respectively (see Figure 7). Comparing the two index-based algorithms, LESAAlign was faster than LGSlinkAlign when searching with tight cost threshold (i.e. sequence-structure edit distance) and no allowed indels, but became considerably slower when the number of allowed indels was increased. In this scenario, LGSlinkAlign was faster than LESAAlign by up to 4 times. In regard to the two online algorithms, LScanAlign was faster than ScanAlign by up to factor 45. In summary, LGSlinkAlign is the best performing algorithm when searching with diverse thresholds, whereas LScanAlign is a very fast and space-efficient alternative. RaligNAtor also allows to use the powerful concept of RNA secondary descriptors [23], i.e. searching for multiple ordered sequence-structure patterns each describing a substructure of a larger RNA molecule. For this, RaligNAtor integrates fast global and local chaining algorithms. We further performed experiments using RaligNAtor to search for members of RNA families based on information from the consensus secondary structure. In these experiments, RaligNAtor showed a high degree of sensitivity and specificity. Compared to searching with primary sequence only, the use of secondary structure information considerably improved the search sensitivity and specificity, in particular for families with a characteristic secondary structure but low degree of sequence conservation. We remark that, up to now, RaligNAtor uses a relatively simple scoring scheme. By incorporating more fine grained scoring schemes like RIBOSUM [13] or energy based scoring [42], we believe that the performance of RaligNAtor for RNA homology search can be further improved. Beyond the algorithmic contributions, we provide with the RaligNAtor software distribution, a robust, well-documented, and easy-to-use software package implementing the ideas and algorithms presented in this manuscript.

Table 2. Overview of the presented algorithms

Availability

The RaligNAtor software package including documentation is available in binary format for different operating systems and architectures and as source code under the GNU General Public License Version 3. See http://www.zbh.uni-hamburg.de/ralignator webcite for details.

Competing interests

The authors declare that they have no competing interests.

Authors’ contributions

FM and MB developed the algorithms. FM implemented the algorithms. SK implemented the chaining algorithms. MB initiated the project and provided supervision and guidance. All three authors contributed to the manuscript. All authors read and approved the final manuscript.

Acknowledgements

This work was supported by basic funding of the University of Hamburg. We thank Steffen Dettmann for interesting discussions and algorithmic ideas that contributed to this work.

References

  1. Mattick J: RNA regulation: a new genetics?

    Nat Rev Genet 2004, 5(4):316-323. PubMed Abstract | Publisher Full Text OpenURL

  2. Burge SW, Daub J, Eberhardt R, Tate J, Barquist L, Nawrocki EP, Eddy SR, Gardner PP, Bateman A: Rfam 11.0: 10 years of RNA families.

    Nucleic Acids Res 2012., 41(D1) OpenURL

  3. Siebert S, Backofen R: MARNA: multiple alignment and consensus structure prediction of RNAs based on sequence structure comparisons.

    Bioinformatics 2005, 21(16):3352-3359. PubMed Abstract | Publisher Full Text OpenURL

  4. Höchsmann M, Voss B, Giegerich R: Pure multiple RNA secondary structure alignments: a progressive profile approach.

    IEEE/ACM Trans Comput Bio Bioinformatics 2004, 1:53-62. Publisher Full Text OpenURL

  5. Sankoff D: Simultaneous solution of the RNA folding, alignment and protosequence problem.

    SIAM J Appl Mathe 1985, 45:810-825. Publisher Full Text OpenURL

  6. Will S, Reiche K, Hofacker IL, Stadler PF, Backofen R: Inferring noncoding RNA families and classes by means of genome-scale structure-based clustering.

    PLoS Comput Biol 2007, 3(4):e65+. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  7. Havgaard JH, Torarinsson E, Gorodkin J: Fast pairwise structural RNA alignments by pruning of the dynamical programming matrix.

    PLoS Comput Biol 2007, 3(10):e193+. OpenURL

  8. Torarinsson E, Havgaard JH, Gorodkin J: Multiple structural alignment and clustering of RNA sequences.

    Bioinformatics 2007, 23(8):926-932. PubMed Abstract | Publisher Full Text OpenURL

  9. Mathews DH, Turner DH: Dynalign: an algorithm for finding the secondary structure common to two RNA sequences.

    J Mol Biol 2002, 317(2):191-203. PubMed Abstract | Publisher Full Text OpenURL

  10. Mathews DH: Predicting a set of minimal free energy RNA secondary structures common to two sequences.

    Bioinformatics 2005, 21(10):2246-2253. PubMed Abstract | Publisher Full Text OpenURL

  11. Dalli D, Wilm A, Mainz I, Steger G: STRAL: progressive alignment of non-coding RNA using base pairing probability vectors in quadratic time.

    Bioinformatics 2006, 22(13):1593-1599. PubMed Abstract | Publisher Full Text OpenURL

  12. Nawrocki EP, Kolbe DL, Eddy SR: Infernal 1.0: inference of RNA alignments.

    Bioinformatics 2009, 25(10):1335-1337. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  13. Klein R, Eddy S: RSEARCH: finding homologs of single structured RNA sequences.

    BMC Bioinformatics 2003, 4:44. PubMed Abstract | BioMed Central Full Text | PubMed Central Full Text OpenURL

  14. Gautheret D, Lambert A: Direct RNA motif definition and identification from multiple sequence alignments using secondary structure profiles.

    J Mol Biol 2001, 313:1003-11. PubMed Abstract | Publisher Full Text OpenURL

  15. Macke T, Ecker D, Gutell R, Gautheret D, Case D, Sampath R: RNAMotif – A new RNA secondary structure definition and discovery algorithm.

    Nucleic Acids Res 2001, 29(22):4724-4735. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  16. Gautheret D, Major F, Cedergren R: Pattern searching/alignment with RNA primary and secondary structures: an effective descriptor for tRNA.

    Comput Appl Biosci 1990, 6(4):325-331. PubMed Abstract OpenURL

  17. RNABOB: a program to search for RNA secondary structure motifs in sequence databases [ http://selab.janelia.org/software.html webcite]

  18. Chang T, Huang H, Chuang T, Shien D, Horng J: RNAMST: efficient and flexible approach for identifying RNA structural homologs.

    Nucleic Acids Res 2006, 34:W423-W428. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  19. Dsouza M, Larsen N, Overbeek R: Searching for patterns in genomic data.

    Trends Genet 1997, 13(12):497-498. PubMed Abstract | Publisher Full Text OpenURL

  20. Grillo G, Licciulli F, Liuni S, SbisÃă E, Pesole G: PatSearch: A program for the detection of patterns and structural motifs in nucleotide sequences.

    Nucleic Acids Res 2003, 31(13):3608-3612. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  21. Billoud B, Kontic M, Viari A: Palingol: a declarative programming language to describe nucleic acids’ secondary structures and to scan sequence database.

    Nucleic Acids Res 1996, 24(8):1395-1403. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  22. Reeder J, Giegerich R: A graphical programming system for molecular motif search. In Proceedings of the 5th international Conference on Generative Programming and Component Engineering. New York: ACM Press; 2006:131-140. OpenURL

  23. Meyer F, Kurtz S, Backofen R, Will S, Beckstette M: Structator: fast index-based search for RNA sequence-structure patterns.

    BMC Bioinformatics 2011, 12:214. PubMed Abstract | BioMed Central Full Text | PubMed Central Full Text OpenURL

  24. El-Mabrouk N, Raffinot M, Duchesne JE, Lajoie M, Luc N: Approximate matching of structured motifs in DNA sequences.

    J Bioinform Comput Biol 2005, 3(2):317-342. PubMed Abstract | Publisher Full Text OpenURL

  25. Jiang T, Lin G, Ma B, Zhang K: A general edit distance between RNA structures.

    J Comput Biol 2002, 9(2):371-388. PubMed Abstract | Publisher Full Text OpenURL

  26. Abouelhoda M, Ohlebusch E: Chaining algorithms for multiple genome comparison.

    J Discrete Algo 2005, 3(2–4):321-341. OpenURL

  27. Will S, Siebauer M, Heyne S, Engelhardt J, Stadler P, Reiche K, Backofen R: LocARNAscan: incorporating thermodynamic stability in sequence and structure-based RNA homology search.

    Algo Mol Biol 2013, 8:14. BioMed Central Full Text OpenURL

  28. Ukkonen E: Algorithms for approximate string matching.

    Inf Control 1985, 64(1–3):100-118. OpenURL

  29. Manber U, Myers E: Suffix arrays: a new method for on-line string searches.

    SIAM J Comput 1993, 22(5):935-948. Publisher Full Text OpenURL

  30. Abouelhoda M, Kurtz S, Ohlebusch E: Replacing suffix trees with enhanced suffix arrays.

    J Discrete Algo 2004, 2:53-86. Publisher Full Text OpenURL

  31. Kärkkäinen J, Sanders P: Simple linear work suffix array construction. In Proceedings of the 13th International Conference on Automata, Languages and Programming. Berlin - Heidelberg: Springer; 2003. OpenURL

  32. Puglisi SJ, Smyth W, Turpin A: The performance of linear time suffix sorting algorithms. In DCC ’05: Proceedings of the Data Compression Conference. Washington: IEEE Computer Society; 2005:358-367. PubMed Abstract | Publisher Full Text OpenURL

  33. Manzini G, Ferragina P: Engineering a lightweight suffix array construction algorithm.

    Algorithmica 2004, 40:33-50. Publisher Full Text OpenURL

  34. Fischer J: Wee LCP.

    Inf Proc Let 2010, 110(8–9):317-320. OpenURL

  35. Kasai T, Lee G, Arimura H, Arikawa S, Park K: Linear-time longest-common-prefix computation in suffix arrays and its applications. In Proceedings of the 18th Annual Symposium on Combinatorial Pattern Matching. Berlin - Heidelberg: Springer; 2001:181-192. OpenURL

  36. Beckstette M, Homann R, Giegerich R, Kurtz S: Fast index based algorithms and software for matching position specific scoring matrices.

    BMC Bioinformatics 2006, 7:389. PubMed Abstract | BioMed Central Full Text | PubMed Central Full Text OpenURL

  37. Ukkonen E: On-line construction of suffix trees.

    Algorithmica 1995, 14(3):249-260. Publisher Full Text OpenURL

  38. Beckstette M, Homann R, Giegerich R, Kurtz S: Significant speedup of database searches with HMMs by search space reduction with PSSM family models.

    Bioinformatics 2009, 25(24):3251-3258. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  39. Darty K, Denise A, Ponty Y: VARNA: Interactive drawing and editing of the RNA secondary structure.

    Bioinformatics 2009, 25(15):1974-1975. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  40. Weinberg Z, Wang J, Bogue J, Yang J, Corbino K, Moy R, Breaker R: Comparative genomics reveals 104 candidate structured RNAs from bacteria, archaea, and their metagenomes.

    Genome Biol 2010, 11(3):R31. PubMed Abstract | BioMed Central Full Text | PubMed Central Full Text OpenURL

  41. Altschul SF, Madden TL, Schäffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ: Gapped BLAST and PSI-BLAST: a new generation of protein database search programs.

    Nucleic Acids Res 1997, 25(17):3389-3402. PubMed Abstract | Publisher Full Text | PubMed Central Full Text OpenURL

  42. Mathews DH, Turner DH: Prediction of RNA secondary structure by free energy minimization.

    Curr Opin Struct Biol 2006, 16(3):270-278. PubMed Abstract | Publisher Full Text OpenURL