Efficient algorithms for biological stems search

Background Motifs are significant patterns in DNA, RNA, and protein sequences, which play an important role in biological processes and functions, like identification of open reading frames, RNA transcription, protein binding, etc. Several versions of the motif search problem have been studied in the literature. One such version is called the Planted Motif Search (PMS)or (l, d)-motif Search. PMS is known to be NP complete. The time complexities of most of the planted motif search algorithms depend exponentially on the alphabet size. Recently a new version of the motif search problem has been introduced by Kuksa and Pavlovic. We call this version as the Motif Stems Search (MSS) problem. A motif stem is an l-mer (for some relevant value of l)with some wildcard characters and hence corresponds to a set of l-mers (without wildcards), some of which are (l, d)-motifs. Kuksa and Pavlovic have presented an efficient algorithm to find motif stems for inputs from large alphabets. Ideally, the number of stems output should be as small as possible since the stems form a superset of the motifs. Results In this paper we propose an efficient algorithm for MSS and evaluate it on both synthetic and real data. This evaluation reveals that our algorithm is much faster than Kuksa and Pavlovic’s algorithm. Conclusions Our MSS algorithm outperforms the algorithm of Kuksa and Pavlovic in terms of the run time as well as the number of stems output. Specifically, the stems output by our algorithm form a proper (and much smaller)subset of the stems output by Kuksa and Pavlovic’s algorithm.


Background
Motifs, or sequence motifs, are patterns of nucleotides or amino acids. Motifs are often related to primer selection, transcription factor binding sites, mRNA processing, transcription termination, etc. Sequence motifs of proteins are typically involved in functions such as binding to a target protein, protein trafficking, post-translational modifications, and so on. Motif search problem has been studied extensively due to its pivotal biological significance. Several types of algorithms have been proposed for motif search. In one such class of methods, putative motifs in an input biological query sequence are predicted based on a database of known motifs. Examples include [1][2][3]. In another class of methods, motifs are assumed to appear frequently in a set of sequences, like the same protein sequence from different species. Here the problem of motif search is reduced to that of finding subsequences that occur in many of the input sequences. Planted motif search (PMS) is one such formulation.
*Correspondence: rajasek@engr.uconn.edu Department of Computer Science and Engineering, University of Connecticut, Storrs, CT, USA Numerous algorithms have been proposed to solve the PMS problem. The WINNOWER algorithm uses a graph to transform this problem into one of finding large cliques in the graph [4]. The PatternBranching algorithm introduces a scoring technique for all the motif candidates [5]. The PROJECTION algorithm repeatedly picks several random positions and uses a hash table with a threshold to limit the motif candidates [6]. Bailey 1995 [7] employs expectation maximization algorithms while Gibbs sampling is used in [8,9]. MULTIPROFILER [10], MEME [11], and CONSENSUS [12] are also known PMS algorithms.
An exact PMS algorithm always outputs all the motifs present in a given set of sequences. MITRA employs a mismatch tree structure to generate the motif candidates efficiently [13]. RISOTTO constructs a suffix tree to compare sequences [14]. PMS1 [15] considers all the motif candidates and evaluates them using sorting. Voting uses a hash table to locate the motifs [16]. PMS2 is based on PMS1 and it extends smaller motifs to get longer motifs, and PMS3 forms a motif of a desired length using two smaller motifs [15]. PMSPrune introduces a tree structure for the motif candidates and uses a branch-and-bound algorithm to reduce the search space [17]. PMS4 is a http://www.biomedcentral.com/1471-2105/14/161 speed-up technique that finds a superset of the motifs using a subset of the input sequences and validates those candidates [18]. PMS5 employs an Integer Linear Programming (ILP) as the branch-bound algorithm for a speedup [19]. PMS6 uses the solutions of such ILPs to generate motif candidates [20].
Most of the work on exact algorithms for PMS has focussed on DNA or RNA sequences where | | = 4. Little work has been done on larger alphabet sizes, such as on proteins. A recent work focusses on protein sequences [21]. However, the stemming algorithm proposed in this paper does not solve the PMS problem. In particular, it does not find motifs but rather motif stems. A motif stem (denoted as stem from hereon) can be thought of as an lmer (for some relevant value of l) with some wild cards present in it. As a result, a stem stands for a set of motifs. A stemming algorithm generates stems (or motifs with wildcards) to represent motifs for large-alphabet inputs [21]. The stemming algorithm of [21] generates a very large set of stems (and hence a very large superset of motifs). In this paper we propose two algorithms for Motif Stems Search, MSS1 and MSS2, which outperform the stemming algorithm of [21]. The new algorithms generate a much smaller set of stems. The stems generated by the algorithm of [21] as well as MSS1 and MSS2 are guaranteed to be supersets of all the motifs present in a given set of input sequences.

Motif search on large alphabets
In this section we provide some definitions pertinent to PMS and MSS problems.
Definition 2. Given two l-mers x and y, the Hamming distance between two l-mer is defined as:

Definition 4. (Planted Motif Search (PMS) Problem). Let S be a set of n sequences of length m each on an alphabet
. Specifically, let S = {s i | |s i | = m, 1 ≤ i ≤ n}. The planted motif search problem or (l, d) motif search problem takes as input S and two integers l and d, and finds every string x of length l such that for every s i , the Hamming distance between x and s i is no more than d. In particular, we want to compute the following set: Any such x is called an (l, d)-motif. Any l-mer of s i that is at a Hamming distance of ≤ d from x is called an occurrence or instance of x. PMS algorithms are typically tested on random data with n = 20 and m = 600. Each input string is randomly generated such that each symbol in each string is equally likely to be any character from the alphabet. A motif is generated randomly. Randomly mutated versions of this motif are planted in the input strings (one mutated motif per string). For a given value of l, we call the pair (l, d) a challenging instance if d is the smallest value for which the number of (l, d)-motifs occurring in the input strings by random chance is ≥ 1. Some of the challenging instances are: (9, 2), (11,3), (13,4), (15,5), (17,6), (19,7), and so on. One of the performance measures of interest for any exact algorithm is the largest challenging instance that it can solve. MITRA can solve the instance of (13, 4) [13], and RISOTTO [14] and Voting [16] successfully run on (15,5). PMSPrune solves up to (19,7) [17]. PMS5 [19] and PMS6 [20] can handle (23,9). These statistics are based on DNA sequences where | | = 4.
The time complexities of exact algorithms typically depend exponentially on the size of . PMS0 takes O(m 2 nl l d | | d ) time, and PMS1 costs O(mn l d | | d l w ) time where w is the word length of the computer [15]. It needs O(mn 2 l d l d | | d ) time for RISOTTO [14], O(mn l d | | d ) for Voting [16], and O(m 2 n l d | | d ) for PMSPrune [17].
When the size of the alphabet is large (e.g., | | = 20 for proteins), the above exact algorithms will take a very long time. Kuksa and Pavlovic have introduced a new version of the motif search problem and proposed an efficient algorithm to solve it on large alphabets. A motif stem is an l-mer with wildcards. Thus a stem represents a set of l-mers without wildcards. For example, if g * acc is a DNA stem, it represents the following 5-mers without wildcards: ggaac, gcaac, gtaac, and gaaac. Given a set of strings from some alphabet, the problem of finding motif stems in http://www.biomedcentral.com/1471-2105/14/161 them is known as the Motif Stem Search (MSS) problem. We focus on MSS in this paper.

Definition 6. Motif Stem Search (MSS) Problem. Input are N sequences and two integers l and d. The problem is
to find a set of stems such that the set of l-mers represented by these stems is a superset of all the (l, d)-motifs present in the N sequences.
As stated above, there are many possible solutions to the MSS problem. The challenge then is to come up with a superset as small as possible which covers all the (l, d)motifs. In other words, we want the number of l-mers (without wildcards) represented by the stems to be as small as possible.

MSS1 -A basic Algorithm
Based on OBSERVATION 1, if the Hamming distance between an l-mer x and a sequence s is larger than 2d, then no l-mer x exists such that HD(x, x ) ≤ d and HD(x , s) ≤ d. This leads us to the following observation.

Observation 2. Given an l-mer x, if ∃s i such that HD(x, s i ) > 2d, then none of x's d-neighbors can be a motif.
The stemming algorithm of [21] works as follows. It makes use of OBSERVATION 2 crucially. OBSERVA-TION 2 states that an l-mer x in any input string cannot be an instance of an (l, d)-motif if there exists at least one input string s such that HD(x, s) > 2d. The algorithm of [21] first identifies a set I of possible motif instances. An l-mer x in any input string s will be included in I if and only if HD(x, s ) ≤ 2d for every input string s . Having found such a set I, the algorithm then uses I to generate stems. The stems are found as follows: For every x, y ∈ I, the algorithm generates the common d-neighbors of x and y as stems. The union of all such stems will constitute candidate motif stems. This union is a superset of the motif stems. Finally, for each candidate stem, the algorithm checks if this is a correct answer or not. All valid stems that pass this test are output.
In Algorithm 1 and Algorithm 2 we present a faster algorithm (than that of [21]) for generating motif stems. In Algorithm 1 we present an algorithm for generating the set I. The cardinality of I that we generate is a much smaller subset of the I generated in the stemming algorithm of [21]. For any pair of l-mers (x, x ) in the set I, we begin with x and replace some characters in x with wildcards to generate MSS candidates. The positions in which x and x match are referred to as the matching region and the positions in which x and x differ are referred to as the non-matching region. The wildcards can be placed in the matching region and/or the non-matching region. Any stem t is generated by placing wildcards in x. Therefore, wildcards in the generated stem t are always treated as mismatches between t and x, independent of whether they are in the matching or the non-matching region. However, for x , in the non-matching region, wildcards in the generated stem t are assumed to be matches between t and x while in the matching region they are still treated as mismatches between t and x . The number of wildcards is dependent on the Hamming distance between x and x and d. Let HD(x, x ) = d x . Table 1 shows how many wildcards should be placed in different cases.
Assume that i wildcards are placed in the non-matching region of x to form t, resulting in i mismatches between t and x and (d x − i) mismatches between t and x . We consider the following two cases: In the matching region, d − max(i, d x − i) is an upper bound on the number of wildcards. However, it is not necessary to enumerate all the cases from 0 to d − max(i, d x − i). Similarly, it is not necessary to repeat stems generation for all pairs in I. For any x let and let O i be the set of motif instances in s i . Then, clearly, O i ⊂ I i . The motifs form a subset of stems that can be obtained between x and each of O i . The motif stems we generate are stems that can be obtained from l-mer pairs of ((x, To minimize the number of stems generated from I, we have to use the sequence with the smallest j.  the (l, d)-motifs are included in the stems set, which is generated from the pairs (x,

Observation 3. For any l-mer x, let its 2d-neighbors in sequence s i be I
The detailed MSS1 algorithm is given in Algorithm 1 and Algorithm 2.
In lines 2-18 we find the sequence in which x has the minimum number of 2d-neighbors. Also, if one sequence has no 2d-neighbor, the current l-mer x is skipped (line 12). The stems are generated by placing wildcards in each pair of x × I min , as shown in Algorithm 2.
Hamming distance is called m 2 n times. Therefore, excluding wildcards placement, Algorithm 1 takes O(m 2 nl) time.

MSS2 -A speedup Algorithm
The computation of the 2d-neighbors of x from s 1 in a certain sequence s i can be thought of as the calculation of a distance matrix between all (m−l +1) l-mers in s 1 against those in s i as shown in Figure 1B. A straight forward algorithm takes O(m 2 l) time. When i ranges from 2 to n, the total time will be O(m 2 nl). In this section we show how to reduce this total time from O(m 2 nl) to O(m 2 n).
Assume that we have computed the Hamming distance between x 1 in s 1 and x j in s i . Let this be HD(x 1 , x j ) = d 1 . Then, HD(x 2 , x j+1 ) can be obtained by comparing: 1) the first characters of x 1 and x j ; and 2) the last characters of x 2 and x j+1 . Observe that the (l − 1)-length prefix of x 2 is the (l − 1)-length suffix of x 1 , and x j and x j+1 also share the same (l − 1)-mer.
If the first characters of x 1 and x j match, then the  if d x ≤ d then 5: for i ← 0, d x do 6: t ← x for i ← d x − d, d do 12: t ← x  (1): However, HD(x p , x q ) where p > q is left out when OBSERVATION 4 is used repeatedly and reaches the end of s i . We simply append a copy of s i to s i to cover all the pairwise alignments ( Figure 1A). Then, by calculating the Hamming distance only once and applying OBSER-VATION 4 repeatedly, each diagonal in the matrix of Figure 1B can be computed in O(l + m) time.
We do the above for m diagonals from cell (x 1 , x 1 ) to (x 1 , x m ) in Figure 1B Optionally, a post-process phase is used following both MSS1 and MSS2 algorithms to refine the output stems. In the post-process phase, a stem is retained only if this stem has at least one neighbor in each sequence at a distance of ≤ d. This phase takes a total of O(mnl * |stem|) time.

An estimation on the number of stems
We can compute the expected number of stems generated by our algorithms as follows. Let q be any l-mer in s 1 . What can we say about |I min | corresponding to q? Consider any sequence s other than s 1 . Let Q be any l-mer of s. The probability p that HD(q, Q) ≤ 2d is 2d This implies that the expected number for k ← 2, m − l + 1 do k th l-mer in s 1 vs. (j + k − 1) th l-mer in s i 13: 15: currHD ← currHD − 1 16: end if 17: if 18: currHD ← currHD + 1 19: end if 20: if 21: if currHD ≤ 2d then 22:  Table 2 for σ = 4 and σ = 20. In all the previous works (see e.g., [6]), analyses have been done assuming that all the l-mers in any sequence are independent. If we assume this, then we can apply Chernoff bounds and show that the number of such Q's is O(mp) with high probability. This in turn will imply that |I min | = O(mp) with high probability. N stems , the number of stems generated between any two l-mers with the hamming distance d HM , is given in (2), which is crudely bounded by O(2 l l d ). As a result, it follows that the expected number of stems generated by our algorithms is O(m 2 p2 l l d ).
(2) http://www.biomedcentral.com/1471-2105/14/161 Challenging instances Consider a PMS instance with n sequences of length m each. For a given value l, let d be the smallest integer such that the expected number of (l, d) motifs that occur by random chance is ≥ 1. We refer to (l, d) as a challenging instance. We can compute challenging instances as follows. Let the alphabet under concern be with | | = σ . The probability that two random characters in this alphabet match is 1/ |σ |.
Then assuming an IID background, the probability that the Hamming distance between two l-mers is no more the probability that a random l-mer has at least one dneighbor (i.e., an l-mer with a Hamming distance of no more than d) in this sequence is This means that the expected number of randomly occurring (l, d) motifs in the n sequences is σ l P n . From this we can calculate the challenging instances. For σ = 4, the challenging instances are (7, 1), (9, 2), etc. When σ = 20, the challenging instances are (7,4), (9,5), etc. Because of Observation 1, in our tests of challenging instances of protein sequences, we have used the cases of (7, 3), (9,4), and (11,5).
The testing data was generated as follows: 1) 20 sequences of length 600 each were generated such that each character in each sequence is equally likely to be one of the characters from the alphabet; 2) a motif of length l was generated randomly; 3) a random number of mismatch positions which is smaller than or equal to d was selected and the characters in these positions were replaced by other amino acids randomly to form a motif instance; 4) step 3) was done 20 times to generate 20 such instances and these were planted in the 20 sequences (at random places with one instance per sequence).
We have implemented and compared our algorithms with RISOTTO [14] and the stemming algorithm of [21]. Please note that we have implemented the algorithm of [21] since we have no access to a running version of the corresponding program. Both the running time and the number of stems generated were used as performance measures. The machine used had an Intel Core i7-2760QM 2.40GHZ processor with a memory size of 4GB, as shown in Table 3 and Table 4. In these tables "-" indicates that the algorithm took too long to finish. These tables show that MSS1 and MSS2 run faster than RISOTTO [14] and stemming [21]. Since the set of stems is a superset of the true motifs, the stems set contains true motifs and false motifs (or false positive predictions). A smaller number of stems indicates less false predictions. The proposed algorithms generate a much smaller subset of the stems generated by the stemming algorithm [21]. Since instances such  as (7, 1), (9, 2), (11,3), etc. are commonly used in DNA sequences, we have also tested the algorithms on more challenging cases such as (7, 3), (9,4), and (11, 5) as shown in Table 5. In addition to the case of = 20, we have also tried different alphabet sizes: 40, 60, 80, and 100. Table 6 displays the running time for various alphabet sizes. The fact that the rune times are nearly the same for different alphabet sizes indicates that the running time of all the algorithms are independent of the alphabet size. The postprocessing phase takes longer time as the alphabet size increases since the number of stems increases. Due to better performance, we have used MSS2 in real biological protein data. In Minimotif Miner 3.0 database [1], we randomly sampled 14 protein motifs. Each of these motifs has multiple source proteins. Comparison of MSS, RISOTTO, and stemming is shown in Table 7.
Finally, we have compared the MSS2 algorithm with PMSPrune, a well-known Plant Motif Search (PMS) algorithm on DNA sequences [22]. As is clear from Table 8, MSS2 is not as fast as PMSPrune. On DNA sequences, the number of spurious motifs is very large. Therefore, the Motif Stems Search algorithms, which are efficient for large alphabets are not as efficient for small alphabets.

Discussion and conclusions
The analysis in [21] shows that, assuming IID background, the expected number of the (l, 2d)-motifs depends highly on the alphabet size | |. Therefore, when | | is large, the expected number of 2d-neighbors in the n m-length sequences is very small in comparison with the total number of l-mers (n(m − l + 1)).
The proposed algorithms consider an even smaller size of candidates by introducing I min . In particular, for any given l-mer x, we focus on the sequence that has the smallest number of 2d-neighbors for x. The expected size of I min is 1 n times the total number of 2d-neighbors of x in all the sequences. Please note that we do not miss any of the valid motifs.
On the other hand, when generating the stems, as shown in Table 1, once i wildcards in the non-matching region are placed, it is known that the upper bound of wildcards in the matching region is d − max(i, d x − i). However, it is not necessary to enumerate all the cases from 0 to d − max(i, d x − i) in the matching region. As long as the case of (d − max(i, d x − i)) wildcards cannot be eliminated, 0 to (d − max(i, d x − i) − 1) wildcards are contained in the (d − max(i, d x − i)) wildcards placement.  Therefore, the proposed algorithms do not enumerate 0 to The proposed algorithms MSS1 and MSS2 provide an efficient way to solve the Motif Stems Search problem in terms of both time and space. Also, the stems generated by MSS1 and MSS2 form a much smaller subset, with less false predictions, of the stems generated by the algorithm of [21].