Open Access
This article is

- freely available
- re-usable

*Algorithms*
**2013**,
*6*(4),
636-677;
https://doi.org/10.3390/a6040636

Article

Sublinear Time Motif Discovery from Multiple Sequences

Department of Computer Science, University of Texas-Pan American, 1201 W University Dr., Edinburg, TX 78539, USA

^{*}

Author to whom correspondence should be addressed.

Received: 11 June 2013; in revised form: 30 September 2013 / Accepted: 1 October 2013 / Published: 14 October 2013

## Abstract

**:**

In this paper, a natural probabilistic model for motif discovery has been used to experimentally test the quality of motif discovery programs. In this model, there are k background sequences, and each character in a background sequence is a random character from an alphabet, Σ. A motif $G={g}_{1}{g}_{2}\dots {g}_{m}$ is a string of m characters. In each background sequence is implanted a probabilistically-generated approximate copy of G. For a probabilistically-generated approximate copy ${b}_{1}{b}_{2}\dots {b}_{m}$ of G, every character, ${b}_{i}$, is probabilistically generated, such that the probability for ${b}_{i}\ne {g}_{i}$ is at most α. We develop two new randomized algorithms and one new deterministic algorithm. They make advancements in the following aspects: (1) The algorithms are much faster than those before. Our algorithms can even run in sublinear time. (2) They can handle any motif pattern. (3) The restriction for the alphabet size is a lower bound of four. This gives them potential applications in practical problems, since gene sequences have an alphabet size of four. (4) All algorithms have rigorous proofs about their performances. The methods developed in this paper have been used in the software implementation. We observed some encouraging results that show improved performance for motif detection compared with other software.

Keywords:

motif discovery; sublinear time; randomized algorithm; deterministic algorithm## 1. Introduction

Motif discovery is an important problem in computational biology and computer science. For instance, it has applications in coding theory [1,2], locating binding sites and conserved regions in unaligned sequences [3,4,5,6], genetic drug target identification [7], designing genetic probes [7] and universal PCR primer design [7,8,9,10].

This paper focuses on the application of motif discovery to find conserved regions in a set of given DNA, RNA or protein sequences. Such conserved regions may represent common biological functions or structures. Many performance measures have been proposed for motif discovery. Let C be a subset of 0–1 sequences of length n. The covering radius of C is the smallest integer, r, such that each vector in ${\{0,1\}}^{n}$ is at a distance at most r from a string in C. The decision problem associated with the covering radius for a set of binary sequences is NP-complete [1]. The similar closest string and substring problems were proven to be NP-hard [1,7]. Some approximation algorithms have been proposed. Li et al. [11] gave an approximation scheme for the closest string and substring problems. The related consensus patterns problem is that given n sequences ${s}_{1},\cdots ,{s}_{n}$, find a region of length L in each ${s}_{i}$ and a string, s, of length L, so that the total Hamming distance from s to these regions is minimized. Approximation algorithms for the consensus patterns problem were reported in [12]. Furthermore, a number of heuristics and programs have been developed [13,14,15,16,17].

In many applications, motifs are faint and may not be apparent when two sequences alone are compared, but may become clearer when more sequences are compared together [18]. For this reason, it has been conjectured that comparing more sequences together can help with identifying faint motifs. This paper is a theoretical approach with a rigorous probabilistic analysis.

We study a natural probabilistic model for motif discovery. In this model, there are k background sequences, and each character in the background sequence is a random character from an alphabet, Σ. A motif $G={g}_{1}{g}_{2}\dots {g}_{m}$ is a string of m characters. In each background sequence is implanted a probabilistically-generated approximate copy of G. For a probabilistically-generated approximate copy ${b}_{1}{b}_{2}\dots {b}_{m}$ of G, every character, ${b}_{i}$, is probabilistically generated, such that the probability for ${b}_{i}\ne {g}_{i}$, which is called a mutation, is at most α. This model was first proposed in [13] and has been widely used in experimentally testing motif discovery programs [14,15,16,17]. We note that a mutation in our model converts a character, ${g}_{i}$, in the motif into a different character, ${b}_{i}$, without probability restriction. This means that a character, ${g}_{i}$, in the motif may not become any character ${b}_{i}$ in $\Sigma -\{{g}_{i}\}$ with equal probability.

We develop three algorithms for which, under the probabilistic model, one can find the implanted motif with high probability via a tradeoff between computational time and the probability of mutation. Each algorithm has a preprocessing phase and the voting phase. We use a pair of functions, $({t}_{1}(n,k),{t}_{2}(n,k))$, to describe the computational complexity of the motif detection algorithm, where n is the largest length of the input sequence and k is the number of sequences. Function ${t}_{1}(n,k)$ is the time complexity for the part for preprocessing, and ${t}_{2}(n,k)$ is the time complexity for recovering one character for the motif after preprocessing. The total time is $O({t}_{1}(n,k)+{t}_{2}(n,k)|G|)$.

(1) There exists a randomized algorithm, such that there are positive constants, ${c}_{0}$ and ${c}_{1}$, such that, if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most $\frac{1}{{(logn)}^{2+\mu}}$ of mutation for some fixed $\mu >0$, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O(\frac{n}{\sqrt{h}}{(logn)}^{\frac{7}{2}}+{h}^{2}{log}^{2}n),O(logn))$ time, where n is the longest length of any input sequences and $h=min(|G|,{n}^{\frac{2}{5}})$. The algorithm’s total time is sublinear if the motif length, $|G|$, is in the range $[{(logn)}^{7+\mu},\frac{n}{{(logn)}^{1+\mu}}]$. This is the first sublinear time algorithm with rigorous analysis in this model.

(2) There exists a randomized algorithm, such that there are positive constants, ${c}_{0},{c}_{1}$ and α, such that if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most α of mutation, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O(\frac{{n}^{2}}{|G|}{(logn)}^{O(1)}),O(logn))$ time.

(3) There exists a deterministic algorithm, such that there are positive constants, ${c}_{0},{c}_{1}$ and α, such that if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most α of mutation, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O({n}^{2}{(logn)}^{O(1)}),O(logn))$ time.

The research in this model has been reported in [19,20,21]. In [19], Fu et al.. developed an algorithm that needs the alphabet size to be a constant that is much larger than four. In [20], our algorithm cannot handle all possible motif patterns. In [21], Liu et al. designed an algorithm that runs in $O({n}^{3})$ time and lacks rigorous analysis about its performance. The motif recovery in this natural and simple model has not been fully understood and seems to be a complicated problem.

This paper presents two new randomized algorithms and one new deterministic algorithm. They make advancements in the following aspects: (1) The algorithms are much faster than those before. Our algorithms can even run in sublinear time. (2) They can handle any motif pattern. (3) The restriction for the alphabet size is as small as four, giving them potential applications in practical problems, since gene sequences have an alphabet size of four. (4) All algorithms have rigorous proofs about their performances.

The algorithm for motif detection is named Recover-Motif(.). The entire Recover-Motif(.) is described in Section 4.2. We analyze Algorithm Recover-Motif (.) in Section 6.

## 2. Notations and the Model of Sequence Generation

For a set, A, $||A||$ denotes the number of elements in A. Σ is an alphabet with $||\Sigma ||=t\ge 2$. For an integer, $n\ge 0$, ${\Sigma}^{n}$ is the set of sequences of a length of n with characters from Σ. For a sequence $S={a}_{1}{a}_{2}\cdots {a}_{n}$, $S[i]$ denotes the character, ${a}_{i}$, and $S[i,j]$ denotes the substring, ${a}_{i}\cdots {a}_{j}$, for $1\le i\le j\le n$. $|S|$ denotes the length of the sequence, S. We use ∅ to represent the empty sequence, which has a length of zero.

Let $G={g}_{1}{g}_{2}\cdots {g}_{m}$ be a fixed sequence of m characters. G is the motif to be discovered by our algorithm. A $\Theta (n,G,\alpha )$-sequence has the form $S={a}_{1}\cdots {a}_{{n}_{1}}{b}_{1}\cdots {b}_{m}{a}_{{n}_{1}+1}\cdots {a}_{{n}_{2}}$, where ${n}_{2}+m\le n$, each ${a}_{i}$ has a probability of $\frac{1}{t}$ to be equal to π for each $\pi \in \Sigma $ and ${b}_{i}$ has a probability of at most α and not equal to ${g}_{i}$ for $1\le i\le m$, where $m=|G|$. $\aleph (S)$ denotes the motif region ${b}_{1}\cdots {b}_{m}$ of S. A mutation converts a character, ${g}_{i}$, in the motif into an arbitrary, different character, ${b}_{i}$, without probability restriction. This allows a character, ${g}_{i}$, in the motif to change into any character, ${b}_{i}$, in $\Sigma -\{{g}_{i}\}$ with even a different probability. The motif region of S may start at an arbitrary position in S. Furthermore, a mutation may convert a character, ${g}_{i}$, in the motif into an arbitrary, different character, ${b}_{i}$, only subject to the restriction that ${g}_{i}$ will mutate with a probability of at most α.

For two sequences ${S}_{1}={a}_{1}\cdots {a}_{m}$ and ${S}_{2}={b}_{1}\cdots {b}_{m}$ of the same length, let the relative Hamming distance $\mathrm{diff}({S}_{1},{S}_{2})=\frac{|\{i|{a}_{i}\ne {b}_{i}(i=1,\cdots ,m)\}|}{m}$.

**Definition**

**1.**

For two intervals, $[{i}_{1},{j}_{1}]$ and $[{i}_{2},{j}_{2}]$, define $\mathrm{shift}([{i}_{1},{j}_{1}],[{i}_{2},{j}_{2}])=min(|{i}_{1}-{i}_{2}|,|{j}_{1}-{j}_{2}|)$.

## 3. Brief Introduction to the Algorithm

Every detection algorithm in this paper has two phases. The first phase is preprocessing, so that the motif regions from multiple sequences can be aligned in the same column region. The second phase is to recover the motif via voting. We use a pair of functions, $({t}_{1}(n,k),{t}_{2}(n,k))$, to describe the computational complexity of the motif detection algorithm. Function ${t}_{1}(n,k)$ is the time complexity for the preprocessing phase, and ${t}_{2}(n,k)$ is the time complexity for outputting one character for the motif in the voting phase.

The motif, G, is a pattern unknown to algorithm Recover-Motif, and algorithm Recover-Motif will attempt to recover G from a series of $\Theta (n,G,\alpha )$-sequences generated by the probabilistic model.

#### 3.1. Algorithm

The algorithm first detects a position that is close to the left motif boundary in a sequence. It finds such a position via sampling and collision between two sequences. After the rough left boundary of a sequence is found, it is used to find the rough boundaries of the rest of the sequences. Similarly, we find those right boundaries of the motif among the input sequences. The exact left boundary of each motif region will be detected in the next phase via voting. Each character of the motif is recovered by voting among all the characters at the same positions in the motif regions of input sequences. For a sequence, S, a sample point is a random position, i, in S. For two sequences, S and ${S}^{\prime}$, with two sample points, i and j, respectively, a rough motif boundary is detected by the similarity of $S[i,i+l]$ and ${S}^{\prime}[i,i+l]$ for some reasonably large parameter, l.

**Descriptions of the Algorithm**

Input: $Z={Z}_{1}\cup {Z}_{2}$, where ${Z}_{1}=\{{S}_{1}^{\prime},\cdots ,{S}_{2{k}_{1}}^{\prime}\}$ and ${Z}_{2}=\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ are two sets of input sequences.

Output: planted motif in each sequence and consensus string.

**Start:**Randomly select sample points from each sequence, both in ${Z}_{1}$ and ${Z}_{2}$.

For each pair of sequences selected from ${Z}_{1}$ and ${Z}_{2}$,

find the rough left and rough right boundaries via the matching at sample points.

Improve the rough boundaries.

If the motif boundaries of each sequence in ${Z}_{2}$ are not empty,

use the Voting algorithm to get the planted motifs.

**End of Algorithm.**

#### 3.2. An Example

We provide the following example for the brief idea of our algorithm. Let the following input strings be defined as below. We assume that the original motif is

**TTTTTAACGATTAGCS**. The motif part is displayed with bold font, and the mutated characters in the motif region have been marked by * in their feet.#### 3.2.1.. Input Sequences

This contains two groups ${Z}_{1}=\{{S}_{1}^{\prime},{S}_{2}^{\prime}\}$ and ${Z}_{2}=\{{S}_{1}^{\u2033},{S}_{2}^{\u2033},{S}_{3}^{\u2033},{S}_{4}^{\u2033},{S}_{5}^{\u2033}\}$.

$$\begin{array}{ccc}\hfill {Z}_{1}:& & \\ \hfill {S}_{1}^{\prime}& =& GTACCATGGA\mathbf{TT}{\mathbf{A}}_{*}\mathbf{TTAACGATTAGCS}TAGAGGACCTA.\hfill \\ \hfill {S}_{2}^{\prime}& =& AATCCTTA{\mathbf{C}}_{*}\mathbf{TTTTAACGATTAGCS}GTC.\hfill \end{array}$$

The above two strings are used to detect the initial motif region and use them to deal with the motif in the second group below.

$$\begin{array}{ccc}\hfill {Z}_{2}:& & \\ \hfill {S}_{1}^{\u2033}& =& ATTCGATCCAG\mathbf{TTTTTAACG}{\mathbf{G}}_{*}\mathbf{TTAGCS}CAATTACTTAG.\hfill \\ \hfill {S}_{2}^{\u2033}& =& GCATTGCAT\mathbf{TTTTTAACGATTA}{\mathbf{C}}_{*}\mathbf{CS}GTACTTAGCTAGATC.\hfill \\ \hfill {S}_{3}^{\u2033}& =& TCAGGGCATCGAGAC\mathbf{TTTTTA}{\mathbf{G}}_{*}\mathbf{CGATTAGCS}CTAGAATCAGACCT.\hfill \\ \hfill {S}_{4}^{\u2033}& =& GTACCTGGCATTGAACG\mathbf{TTTTTAACGATTAGC}{\mathbf{A}}_{*}TGCAGATGGACCTTTA.\hfill \\ \hfill {S}_{5}^{\u2033}& =& AATGGATCAGA\mathbf{TTTTTAACGATT}{\mathbf{C}}_{*}\mathbf{GCS}CTAGATTCAG.\hfill \end{array}$$

#### 3.2.2.. Select Sample Points

Some sample points of two sequences in ${Z}_{1}$ are selected randomly and marked with the little dots on the top.

$$\begin{array}{ccc}\hfill {S}_{1}^{\prime}& =& GT\dot{A}CC\dot{A}TG\dot{G}A\mathbf{T}\dot{\mathbf{T}}{\mathbf{A}}_{*}\mathbf{T}\mathbf{TA}\dot{\mathbf{A}}\mathbf{CGA}\dot{\mathbf{T}}\mathbf{T}\dot{\mathbf{A}}\mathbf{GC}\dot{\mathbf{S}}TA\dot{G}AG\dot{G}ACC\dot{T}A.\hfill \\ \hfill {S}_{2}^{\prime}& =& \dot{A}AT\dot{C}CTT\dot{A}{\mathbf{C}}_{*}\dot{\mathbf{T}}\mathbf{TTT}\dot{\mathbf{A}}\mathbf{AC}\dot{\mathbf{G}}\mathbf{A}\dot{\mathbf{T}}\mathbf{TA}\dot{\mathbf{G}}\mathbf{CS}\dot{G}TC.\hfill \end{array}$$

#### 3.2.3.. Collision Detection

In this step, the left and right rough boundaries of two sequences will be marked. The following shows the left collision, which happens nearby the left motif boundary and are marked by two overline $\overline{TATT}$ and $\overline{TTTT}$ subsequences.

$$\begin{array}{ccc}\hfill {S}_{1}^{\prime}& =& GT\dot{A}CC\dot{A}TG\dot{G}A\mathbf{T}\overline{\dot{\mathbf{T}}{\mathbf{A}}_{*}\mathbf{TT}}\mathbf{A}\dot{\mathbf{A}}\mathbf{CGA}\dot{\mathbf{T}}\mathbf{T}\dot{\mathbf{A}}\mathbf{GC}\dot{\mathbf{S}}TA\dot{G}AG\dot{G}ACC\dot{T}A.\hfill \\ \hfill {S}_{2}^{\prime}& =& \dot{A}AT\dot{C}{C}_{*}TT\dot{A}{\mathbf{C}}_{*}\overline{\dot{\mathbf{T}}\mathbf{TTT}}\dot{\mathbf{A}}\mathbf{AC}\dot{\mathbf{G}}\mathbf{A}\dot{\mathbf{T}}\mathbf{TA}\dot{\mathbf{G}}\mathbf{CS}\dot{G}TC.\hfill \end{array}$$

The following shows the right collision, which happens nearby the right motif boundary and is marked by two overline $\overline{TTAG}$ subsequences.

$$\begin{array}{ccc}\hfill {S}_{1}^{\prime}& =& GT\dot{A}CC\dot{{A}_{*}}TG\dot{G}A\mathbf{T}\dot{\mathbf{T}}{\mathbf{A}}_{*}\mathbf{TT}\mathbf{A}\dot{\mathbf{A}}\mathbf{CGA}\overline{\dot{\mathbf{T}}\mathbf{T}\dot{\mathbf{A}}\mathbf{G}}\mathbf{C}\dot{\mathbf{S}}TA\dot{G}AG\dot{G}ACC\dot{T}A.\hfill \\ \hfill {S}_{2}^{\prime}& =& \dot{A}AT\dot{C}{C}_{*}TT\dot{A}{\mathbf{C}}_{*}\dot{\mathbf{T}}\mathbf{TTT}\dot{\mathbf{A}}\mathbf{AC}\dot{\mathbf{G}}\mathbf{A}\overline{\dot{\mathbf{T}}\mathbf{TA}\dot{\mathbf{G}}}\mathbf{CS}\dot{G}TC.\hfill \end{array}$$

#### 3.2.4.. Improving the Boundaries

In the early phase of the algorithm, we first detect a small piece of the motif in ${S}_{1}^{\prime}$ by comparing ${S}_{1}^{\prime}$ and ${S}_{2}^{\prime}$. Assume that “$\mathbf{T}{\mathbf{A}}_{*}\mathbf{TT}$” and “$\mathbf{TTAG}$” are found in the left and right motif regions of ${S}_{1}^{\prime}$, respectively. The rough motif length will be calculated via the difference of the location of the first character, ‘T’, of the first subsequence and the location of the last character, ‘G’, of the second subsequence. The position marked by “A” is the rough left boundary of the motif, and the position marked by “T” is the rough right boundary of the motif in ${S}_{1}^{\prime}$ below.

$$\begin{array}{ccc}\hfill {S}_{1}^{\prime}& =& GTACCATGG\underline{A}{\mathbf{TTA}}_{*}\mathbf{TTAACGATTAGCS}\underline{T}AGAGGACCTA.\hfill \\ \hfill {S}_{2}^{\prime}& =& AATCCTT\underline{A}{\mathbf{C}}_{*}\mathbf{TTTTAACGATTAGCS}\underline{G}TC.\hfill \end{array}$$

#### 3.2.5.. Select Sample Points for the Sequences in ${Z}_{2}$

Some sample points near the motif boundaries of ${S}_{1}^{\prime}$ are selected.

${S}_{1}^{\prime}=GTACCATG\dot{G}A\mathbf{T}\dot{\mathbf{T}}{\mathbf{A}}_{*}\dot{\mathbf{T}}\mathbf{T}\mathbf{AACGATT}\dot{\mathbf{A}}\mathbf{G}\dot{\mathbf{C}}\mathbf{S}T\dot{A}GAGGACCTA$.

Sample points are selected in each sequence in ${Z}_{2}$.

$$\begin{array}{ccc}\hfill {S}_{1}^{\u2033}& =& A\dot{T}TC\dot{G}ATCC\dot{A}G\mathbf{T}\dot{\mathbf{T}}\mathbf{T}\dot{\mathbf{T}}{\mathbf{TAACGG}}_{*}\mathbf{TTAG}\dot{\mathbf{C}}\mathbf{S}C\dot{A}AT\dot{T}ACTT\dot{A}G.\hfill \\ \hfill {S}_{2}^{\u2033}& =& G\dot{C}ATT\dot{G}CAT\mathbf{T}\dot{\mathbf{T}}{\mathbf{TTTAACGATTAC}}_{*}\dot{\mathbf{C}}\mathbf{S}GT\dot{A}CTT\dot{A}GCT\dot{A}GA\dot{T}C.\hfill \\ \hfill {S}_{3}^{\u2033}& =& \dot{T}CA\dot{G}GGCA\dot{T}CGA\dot{G}AC\mathbf{TTT}\dot{\mathbf{T}}{\mathbf{TAG}}_{*}\mathbf{CGATTAG}\dot{\mathbf{C}}\mathbf{S}CTA\dot{G}AATC\dot{A}GAC\dot{C}T.\hfill \\ \hfill {S}_{4}^{\u2033}& =& GT\dot{A}CCT\dot{G}GCAT\dot{T}GAACG\mathbf{T}\dot{\mathbf{T}}\mathbf{TTTAACGATT}\dot{\mathbf{A}}{\mathbf{GCA}}_{*}TGC\dot{A}GAT\dot{G}GACCT\dot{T}TA.\hfill \\ \hfill {S}_{5}^{\u2033}& =& AA\dot{T}GGA\dot{T}CAGA\mathbf{T}\dot{\mathbf{T}}{\mathbf{TTTAACGATTC}}_{*}\mathbf{G}\dot{\mathbf{C}}\mathbf{S}CTA\dot{G}ATT\dot{C}AG.\hfill \end{array}$$

#### 3.2.6.. Collision Detection Between ${S}_{1}^{\prime}$ with the Sequences in ${Z}_{2}$

The rough motif boundaries of the sequences in ${Z}_{2}$ are detected via the collisions with the subsequences near the motif area of ${S}_{1}^{\prime}$.

${S}_{1}^{\prime}=GTACCATG\dot{G}A\mathbf{T}\dot{\mathbf{T}}{\mathbf{A}}_{*}\dot{\mathbf{T}}\mathbf{T}\mathbf{AACGATT}\dot{\mathbf{A}}\mathbf{G}\dot{\mathbf{C}}\mathbf{S}T\dot{A}GAGGACCTA$.

The rough motif boundaries are marked by the lines over the matched subsequences.

$$\begin{array}{ccc}\hfill {S}_{1}^{\u2033}& =& A\dot{T}TC\dot{G}ATCC\dot{A}G\mathbf{T}\overline{\dot{\mathbf{T}}\mathbf{T}\dot{\mathbf{T}}\mathbf{T}}{\mathbf{AACGG}}_{*}\mathbf{T}\overline{\mathbf{TAG}\dot{\mathbf{C}}}\mathbf{S}C\dot{A}AT\dot{T}ACTT\dot{A}G.\hfill \\ \hfill {S}_{2}^{\u2033}& =& G\dot{C}ATT\dot{G}CAT\mathbf{T}\overline{\dot{\mathbf{T}}\mathbf{TTT}}\mathbf{AACGAT}\overline{{\mathbf{TAC}}_{*}\dot{\mathbf{C}}}\mathbf{S}GT\dot{A}CTT\dot{A}GCT\dot{A}GA\dot{T}C.\hfill \\ \hfill {S}_{3}^{\u2033}& =& \dot{T}CA\dot{G}GGCA\dot{T}CGA\dot{G}AC\mathbf{TTT}\overline{\dot{\mathbf{T}}{\mathbf{TAG}}_{*}}\mathbf{CGAT}\overline{\mathbf{TAG}\dot{\mathbf{C}}}\mathbf{S}CTA\dot{G}AATC\dot{A}GAC\dot{C}T.\hfill \\ \hfill {S}_{4}^{\u2033}& =& GT\dot{A}CCT\dot{G}GCAT\dot{T}GAACG\mathbf{T}\overline{\dot{\mathbf{T}}\mathbf{TTT}}\mathbf{AACG}\overline{\mathbf{ATT}\dot{\mathbf{A}}}{\mathbf{GCA}}_{*}TGC\dot{A}GAT\dot{G}GACCT\dot{T}TA.\hfill \\ \hfill {S}_{5}^{\u2033}& =& AA\dot{T}GGA\dot{T}CAGA\mathbf{T}\overline{\dot{\mathbf{T}}\mathbf{TTT}}\mathbf{AACGAT}\overline{{\mathbf{TC}}_{*}\mathbf{G}\dot{\mathbf{C}}}\mathbf{S}CTA\dot{G}ATT\dot{C}AG.\hfill \end{array}$$

#### 3.2.7.. Improving the Motif Boundaries for the Sequences in ${Z}_{2}$

After the collision with the sequences in ${Z}_{2}$, we obtain the rough location of the motifs of the sequences in ${Z}_{2}$. Their rough motif boundaries for the sequences in ${Z}_{2}$ are improved to be closer to exact boundaries.

${S}_{1}^{\prime}=GTACCATGGA\overline{{\mathbf{TTA}}_{*}\mathbf{T}}\mathbf{T}\mathbf{AACGATT}\overline{\mathbf{AGCS}}TAGAGGACCTA$.

The improved motif boundaries of the sequences in ${Z}_{2}$ are marked below. This phase does not cost much time, as only the positions near the rough motif boundaries are tested.

$$\begin{array}{ccc}\hfill {S}_{1}^{\u2033}& =& ATTCGATCCA\underline{G}\mathbf{TTTTTAACG}{\mathbf{G}}_{*}\mathbf{TTAGCS}\underline{C}AATTACTTAG.\hfill \\ \hfill {S}_{2}^{\u2033}& =& GCATTGC\underline{A}T{\mathbf{TTTTTAACGATTAC}}_{*}\mathbf{CS}\underline{G}TACTTAGCTAGATC.\hfill \\ \hfill {S}_{3}^{\u2033}& =& TCAGGGCATCGAGA\underline{C}{\mathbf{TTTTTAG}}_{*}\mathbf{CGATTAGCS}\underline{C}TAGAATCAGACCT.\hfill \\ \hfill {S}_{4}^{\u2033}& =& GTACCTGGCATTGAAC\underline{G}{\mathbf{TTTTTAACGATTAGCA}}_{*}\underline{T}GCAGATGGACCTTTA.\hfill \\ \hfill {S}_{5}^{\u2033}& =& AATGGATCAG\underline{A}{\mathbf{TTTTTAACGATTC}}_{*}\mathbf{GCS}C\underline{T}AGATTCAG.\hfill \end{array}$$

#### 3.2.8.. Motif Boundaries for the Sequences in ${Z}_{2}$

${S}_{1}^{\prime}=GTACCATGGA\overline{{\mathbf{TTA}}_{*}\mathbf{T}}\mathbf{T}\mathbf{AACGATT}\overline{\mathbf{AGCS}}TAGAGGACCTA$.

Use the pair $({G}_{L},{G}_{R})$ with ${G}_{L}=\overline{\mathbf{TTAT}}$ and ${G}_{R}=\overline{\mathbf{AGCS}}$ to find the motif boundaries in the sequences of ${Z}_{2}$. The rough boundaries of the second group are marked below with underlines. In this phase, the exact motif boundaries for most sequences of ${Z}_{2}$ can be found.

$$\begin{array}{ccc}\hfill {S}_{1}^{\u2033}& =& ATTCGATCCA\underline{G}\mathbf{TTTTTAACG}{\mathbf{G}}_{*}\mathbf{TTAGCS}\underline{C}AATTACTTAG.\hfill \\ \hfill {S}_{2}^{\u2033}& =& GCATTGCA\underline{T}{\mathbf{TTTTTAACGATTAC}}_{*}\mathbf{CS}\underline{G}TACTTAGCTAGATC.\hfill \\ \hfill {S}_{3}^{\u2033}& =& TCAGGGCATCGAGA\underline{C}{\mathbf{TTTTTAG}}_{*}\mathbf{CGATTAGCS}\underline{C}TAGAATCAGACCT.\hfill \\ \hfill {S}_{4}^{\u2033}& =& GTACCTGGCATTGAAC\underline{G}{\mathbf{TTTTTAACGATTAGCA}}_{*}\underline{T}GCAGATGGACCTTTA.\hfill \\ \hfill {S}_{5}^{\u2033}& =& AATGGATCAG\underline{A}{\mathbf{TTTTTAACGATTC}}_{*}\mathbf{GCS}\underline{C}TAGATTCAG.\hfill \end{array}$$

#### 3.2.9.. Extracting the Motif Regions

The motif regions of the second group will be extracted. The original motif is recovered via voting at each column.

$$\begin{array}{ccc}\hfill {G}_{1}^{\u2033}& =& \mathbf{TTTTTAACG}{\mathbf{G}}_{*}\mathbf{TTAGCS}\hfill \\ \hfill {G}_{2}^{\u2033}& =& \mathbf{TTTTTAACGATTA}{\mathbf{C}}_{*}\mathbf{CS}\hfill \\ \hfill {G}_{3}^{\u2033}& =& \mathbf{TTTTTA}{\mathbf{G}}_{*}\mathbf{CGATTAGCS}\hfill \\ \hfill {G}_{4}^{\u2033}& =& \mathbf{TTTTTAACGATTAGC}{\mathbf{A}}_{*}\hfill \\ \hfill {G}_{5}^{\u2033}& =& \mathbf{TTTTTAACGATT}{\mathbf{C}}_{*}\mathbf{GCS}\hfill \end{array}$$

#### 3.2.10.. Recovering Motif via Voting

The original motif,

**TTTTTAACGATTAGCS**, is recovered via voting at all columns. For example, the last**S**in the motif is recovered via voting among the characters,**S**,**S**,**S**,**A**,**S**, in the last column.#### 3.3. Our Results

We give an algorithm for the case with at most a $\frac{1}{{(logn)}^{2+\mu}}$ mutation rate. The performance of the algorithm is stated in Theorem 2. Theorem 2 implies Corollary 3 by selecting $k={c}_{1}logn$ with some constant ${c}_{1}$ that is large enough.

**Theorem**

**2.**

Assume that μ is a fixed number in $(0,1)$ and the alphabet size, t, is at least four. There exists a randomized algorithm and a constant ${c}_{0}$, such that if the length of the motif, G, is at least ${c}_{0}logn$, then, given k independent $\Theta (n,G,\frac{1}{{(logn)}^{2+\mu}})$-sequences, the algorithm outputs ${G}^{\prime}$, such that:

(1) with a probability of at most ${e}^{-\Omega (k)}$, $|{G}^{\prime}|\ne |G|$;

(2) for each $1\le i\le |G|$, with a probability of at most ${e}^{-\Omega (k)}$, ${G}^{\prime}[i]\ne G[i]$; and

(3) with a probability of at most $\frac{k}{{n}^{3}}$, the algorithm does not stop in $(O(k(\frac{n}{\sqrt{h}}{(logn)}^{\frac{5}{2}}+{h}^{2}logn)),O(k))$ time, where n is the longest length of any input sequences, and $h=min(|G|,{n}^{\frac{2}{5}})$.

**Corollary**

**3.**

There exists a randomized algorithm and positive constants, ${c}_{0},{c}_{1}$ and μ, such that if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most $\frac{1}{{(logn)}^{2+\mu}}$ of mutation, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O(\frac{n}{\sqrt{h}}{(logn)}^{\frac{7}{2}}+{h}^{2}{log}^{2}n),O(logn))$ time, where n is the longest length of any input sequences, and $h=min(|G|,{n}^{\frac{2}{5}})$.

We give a randomized algorithm for the case with a $\Omega (1)$ mutation rate. The performance of the algorithm is stated in Theorem 4. Theorem 4 implies Corollary 5 by selecting $k={c}_{1}logn$ with some constant ${c}_{1}$ that is large enough.

**Theorem**

**4.**

Assume that the alphabet size, t, is at least four. There exists a randomized algorithm and a constant ${c}_{0}$, such that if the length of the motif G is at least ${c}_{0}logn$, then, given k independent $\Theta (n,G,\mu ))$-sequences, the algorithm outputs ${G}^{\prime}$, such that:

(1) with a probability of at most ${e}^{-\Omega (k)}$, $|{G}^{\prime}|\ne |G|$;

(2) for each $1\le i\le |G|$, with a probability of at most ${e}^{-\Omega (k)}$, ${G}^{\prime}[i]\ne G[i]$; and

(3) with a probability of at most $\frac{k}{{n}^{3}}$, the algorithm does not stop in $(O(k(\frac{{n}^{2}}{|G|}{(logn)}^{O(1)}+{h}^{2})),O(k))$,

where n is the longest length of any input sequences, and $h=min(|G|,{n}^{\frac{2}{5}})$.

**Corollary**

**5.**

There exists a randomized algorithm and positive constants, ${c}_{0},{c}_{1}$ and α, such that if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most α of mutation, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O(\frac{{n}^{2}}{|G|}{(logn)}^{O(1)}),O(logn))$ time.

We give a deterministic algorithm for the case with a $\Omega (1)$ mutation rate. The performance of the algorithm is stated in Theorem 6. Theorem 6 implies Corollary 7 by selecting $k={c}_{1}logn$ with some constant ${c}_{1}$ that is large enough.

**Theorem**

**6.**

Assume that the alphabet size, t, is at least four. There exists a deterministic algorithm and a constant, ${c}_{0}$, such that if the length of the motif G is at least ${c}_{0}logn$, then, given k independent $\Theta (n,G,\mu ))$-sequences, the algorithm runs in $(O({n}^{2}{(logn)}^{O(1)}+{h}^{2}k),O(k))$ and outputs ${G}^{\prime}$, such that:

(1) with a probability of at most ${e}^{-\Omega (k)}$, $|{G}^{\prime}|\ne |G|$;

(2) for each $1\le i\le |G|$, with a probability of at most ${e}^{-\Omega (k)}$, ${G}^{\prime}[i]\ne G[i]$; and

(3) with a probability of at most $\frac{k}{{n}^{3}}$, the algorithm does not stop in $(O(k({n}^{2}{(logn)}^{O(1)}+{h}^{2})),O(k))$ time, where nis the longest length of any input sequences, and $h=min(|G|,{n}^{\frac{2}{5}})$.

**Corollary**

**7.**

There exists a deterministic algorithm and positive constants, ${c}_{0},{c}_{1}$ and α, such that if the alphabet size is at least four, the number of sequences is at least ${c}_{1}logn$, the motif length is at least ${c}_{0}logn$ and each character in the motif region has a probability of at most α of mutation, then the motif can be recovered with a probability of at least $\frac{3}{4}$ in $(O({n}^{2}{(logn)}^{O(1)}),O(logn))$ time.

## 4. Algorithm Recover-Motif

In this section, we give a unified approach to describe three algorithms. The performance of the algorithms is stated in Theorems 2, 4 and 6. The description of Algorithm Recover-Motif is given in Section 4.2. The analysis of the algorithm is given at Section 6.

#### 4.1. Some Parameters

**Definition**

**8.**

- i.
- Parameter x is selected to be 10. This parameter controls the failure probability of our algorithms to be at most $\frac{1}{{2}^{x}}$.
- ii.
- The size of the alphabet is $t\ge 4$.
- iii.
- Select a constant ${\rho}_{0}\in (0,1)$ to have inequality (1):$$\begin{array}{c}\hfill {\rho}_{0}<\frac{t-1}{2t}\end{array}$$
- iv.
- The constant $\u03f5\in (0,1)$ is selected to satisfy:$$\begin{array}{c}\hfill \u03f5<min((\frac{t-1}{t}-(2{\rho}_{0}+2\u03f5)),\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\frac{1}{5}(1-\frac{2}{t-1}-\frac{4}{{2}^{x}}),\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\frac{1}{3})\end{array}$$The existence of ϵ follows from inequality (1). The constant ϵ is used to control the mutation in the motif area. It is a part of parameter β defined in item (xiv) of this definition.
- v.
- Let $c={e}^{-\frac{{\u03f5}^{2}}{3}}$. The constant, c, is used to simplify probabilistic bounds, which are derived from the applications of Chernoff bounds (see Corollary 18).
- vi.
- Define $r(y)=(\frac{1}{t-1}+\frac{{c}^{y}}{1-c})$.
- vii.
- Define ${u}_{1}$ to be a large constant that, for all $v\ge 0$:$$\begin{array}{c}\hfill \frac{2(v+{u}_{1}){c}^{v+{u}_{1}}}{{(1-c)}^{2}}\le \frac{1}{5\xb7{2}^{x}}\end{array}$$
- viii.
- Select constant ${\rho}_{1}\in (0,1)$, such that:$$\begin{array}{c}\hfill \frac{2}{t-1}+\frac{4}{{2}^{x}}+5\u03f5+{\rho}_{1}<1\end{array}$$The existence of ${\rho}_{1}$ follows from $\u03f5<\frac{1}{5}(1-\frac{2}{t-1}-\frac{4}{{2}^{x}})$, which is implied by inequality (2).
- ix.
- Select constant ${\rho}_{2}\in (0,1)$ and constant positive integer v that are large enough, such that:$$\begin{array}{ccc}& & \frac{6(v+{u}_{1}){c}^{v}}{1-c}+{\rho}_{2}<{\rho}_{1},\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\mathrm{and}\phantom{\rule{4pt}{0ex}}\hfill \end{array}$$$$\begin{array}{ccc}& & (\frac{1}{{2}^{x}}+(v+{u}_{1})\frac{{c}^{v}}{1-c}+\frac{{c}^{v}}{1-c}+\frac{1}{5\xb7{2}^{x}})\le 1/2\hfill \end{array}$$
- x.
- Define ${\varsigma}_{0}=\frac{1}{{2}^{x}}$, and: $\phi (v)=(v+{u}_{1})\frac{{c}^{v}}{1-c}+\frac{{c}^{v}}{1-c})$
- xi.
- Select constant ${\alpha}_{0}$, such that:$$\begin{array}{ccc}\hfill 4(v-1){\alpha}_{0}+{\alpha}_{0}& <& {\rho}_{2},\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\mathrm{and}\hfill \end{array}$$$$\begin{array}{ccc}\hfill {\alpha}_{0}& <& {\rho}_{0}\hfill \end{array}$$
- xii.
- The maximal mutation rate, α, for the second algorithm (Theorem 4) and the third algorithm (Theorem 6) are selected as ${\alpha}_{0}$. Since the mutation rate of our sublinear time algorithm is bounded by $\frac{1}{{(logn)}^{2+\mu}}$, the maximal mutation rate α for the first algorithm (Theorem 2) is less than ${\alpha}_{0}$ when n is large enough. We always assume that all mutation rates α in our three algorithms are in the range $(0,{\alpha}_{0}]$.
- xiii.
- Define $q(y)=2(v-1)\alpha +\frac{2{c}^{y}}{1-c}$. By inequality (10), the definition of $q(y)$ and the fact that $\alpha \in (0,{\alpha}_{0})$, we have:$$\begin{array}{ccc}\hfill 2(q(v)+r(v)+2({\varsigma}_{0}+\phi (v))+2\u03f5)+({\alpha}_{0}+\u03f5)& <& 1\hfill \end{array}$$Inequality (11) implies $q(v)\le \frac{1}{2}$. By inequality (6), we have that:$$\begin{array}{c}\hfill (\frac{1}{{2}^{x}}+(v+{u}_{1})\frac{{c}^{v}}{1-c}+\frac{{c}^{v}}{1-c}+\frac{1}{5\xb7{2}^{x}})+q(v)\le 3/4\end{array}$$
- xiv.
- Let $\beta =2\alpha +2\u03f5$. The parameter, β, controls the similarity of $\aleph (S)$ and the original motif, G (see Lemma 27).
- xv.
- Define $R=r(v)$.
- xvi.
- We define the following ${Q}_{0}$.$$\begin{array}{c}\hfill {Q}_{0}=q(v)\end{array}$$The parameter, ${Q}_{0}$, used in Lemma 27 gives an upper bound of the probability that a $\Theta (n,G,\alpha )$-sequence, S, whose $\aleph (S)$ will not be similar enough to the original motif, G, according to the conditions in Lemma 27.
- xvii.
- Select constant ${d}_{0}$, such that:$$\begin{array}{c}\hfill {n}^{3}{c}^{{d}_{0}logn}<\frac{1}{5\xb7{2}^{x}}\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\mathrm{for}\phantom{\rule{4pt}{0ex}}\mathrm{all}\phantom{\rule{4pt}{0ex}}\mathrm{large}\phantom{\rule{4pt}{0ex}}n\end{array}$$
- xviii.
- Select constant ${d}_{1}$, such that $(v+{u}_{1}){c}^{{d}_{1}logn}<\frac{1}{5\xb7{2}^{x}}$.
- xix.
- Select number ${u}_{2}$, such that:$$\begin{array}{ccc}\hfill ({d}_{1}logn)(v+{u}_{1})\frac{{c}^{v+{u}_{2}}}{1-c}& \le & \frac{1}{5\xb7{2}^{x}}.\phantom{\rule{4pt}{0ex}}\mathrm{and}\phantom{\rule{4pt}{0ex}}\hfill \end{array}$$$$\begin{array}{ccc}\hfill (v+{u}_{1})\frac{{c}^{v+{u}_{2}}}{1-c}& <& \frac{1}{5\xb7{2}^{x}}\hfill \end{array}$$Since only n is variable, we can make ${u}_{2}=O(loglogn)$.
- xx.
- For a fixed ${c}_{0}\in (0,1)$, define ${\delta}_{{c}_{0}}=\frac{ln\frac{1}{{c}_{0}}}{2}$.

#### 4.2. Description of Algorithm Recover-Motif

The algorithms are described in this section. The description combines three algorithms together. The simplest deterministic algorithm is also given in Section 5. Before presenting the algorithm, we define some notions.

**Definition**

**9.**

- Two sequences, ${X}_{1}$ and ${X}_{2}$, are weakly left matched if: (1) both $|{X}_{1}|$ and $|{X}_{2}|$ are at least ${d}_{0}logn$; and (2) $\mathrm{diff}({X}_{1}[1,i],{X}_{2}[1,i])\le \beta $ for all integers i, $v\le i\le {d}_{0}logn$, where v is defined in item (ix) in Definition 8.
- Two sequences, ${X}_{1}$ and ${X}_{2}$, are left matched if: (1) ${d}_{0}logn\le |{X}_{1}|,|{X}_{2}|$; (2) ${X}_{1}[i]={X}_{2}[i]$ for $i=1,\cdots ,v-1$; and (3) $\mathrm{diff}({X}_{1}[1,i],{X}_{2}[1,i])\le \beta $ for all integers i, $v\le i\le {d}_{0}logn$.
- Two sequences, ${X}_{1}$ and ${X}_{2}$, are weakly right matched if ${X}_{1}^{R}$ and ${X}_{2}^{R}$ are weakly left matched, where ${X}^{R}={a}_{n}\cdots {a}_{1}$ is the inverse sequence of $X={a}_{1}\cdots {a}_{n}$.
- Two sequences, ${X}_{1}$ and ${X}_{2}$, are right matched if ${X}_{1}^{R}$ and ${X}_{2}^{R}$ are left matched, where ${X}^{R}={a}_{n}\cdots {a}_{1}$ is the inverse sequence of $X={a}_{1}\cdots {a}_{n}$.
- Two sequences, ${X}_{1}$ and ${X}_{2}$, are matched if ${X}_{1}$ and ${X}_{2}$ are both left and right matched.

Variable L will be controlled in the range $L\in [{(logn)}^{3+{\u03f5}_{1}},{n}^{\frac{2}{5}-{\u03f5}_{2}}]$ in our algorithm with a high probability. We define the following functions that depend on L.

**Definition**

**10.**

Define $M(L)=\frac{\sqrt{3logn+x}}{\sqrt{1-\gamma}}\sqrt{L}logn$. Define ${M}_{1}(L)=\frac{{\delta}_{{c}_{0}}M(L)}{logn}$ (see (xx) of Definition 8 for ${\delta}_{{c}_{0}}$), where ${c}_{0}=\frac{1}{4}$.

We would like to minimize the function $(\frac{n}{L}M+{L}^{2})logn$. This selection can make the total time complexity sublinear.

**Definition**

**11.**

For a $\Theta (n,G,\alpha )$ sequence, S, define LB(S) to be the left boundary, l, of the motif region $\aleph (S)$ in S and RB(S) to be the right boundary, r, of the motif region $\aleph (S)$ in S, such that $\aleph (S)=S[l,r]$.

#### 4.2.1.. Boundary-Phase of Algorithm Recover-Motif

The first phase of Algorithm Recover-Motif finds the rough motif boundaries of all input sequences. It first detects the rough motif boundaries of one sequence via comparing two input sequences. Then, the rough boundaries of the first sequence are used to find the rough motif boundaries of other input sequences.

Three algorithms share most of the functions. We have a unified approach to describe them. A special variable, “algorithm-type”, selects one of the three algorithms, respectively.

**Definition**

**12.**

Let algorithm-type represent one of the three algorithm types, “RANDOMIZED-SUBLINEAR”, “RANDOMIZED-SUBQUADRATIC” and “DETERMINISTIC-SUPERQUADRATIC”.

**Definition**

**13.**

Assume that ${A}_{1}$ is a set of positions in a $\Theta (n,G,\alpha )$ sequence, ${S}_{1}$, and ${A}_{2}$ is a set of positions in a $\Theta (n,G,\alpha )$ sequence, ${S}_{2}$. If there are positions ${a}_{1}\in {A}_{1}$ and ${a}_{2}\in {A}_{2}$, such that for some position, j, with $1\le j\le |G|$, ${a}_{1}$ is the position of $\aleph ({S}_{1})[j]$ in ${S}_{1}$ and ${a}_{2}$ is the position of $\aleph ({S}_{2})[j]$ in ${S}_{2}$, then ${A}_{1}$ and ${A}_{2}$ have a collision at $({a}_{1},{a}_{2})$.

In the following function, Collision-Detection, the parameter, $\omega \le \beta $, is defined below in the three algorithms.

$$\begin{array}{ccc}\hfill {\omega}_{\mathrm{algorithm}-\mathrm{type}}& =& \left\{\begin{array}{cc}0\hfill & \phantom{\rule{4pt}{0ex}}\mathrm{if}\phantom{\rule{4pt}{0ex}}\mathrm{algorithm}-\mathrm{type}=\mathrm{RANDOMIZED}-\mathrm{SUBLINEAR};\hfill \\ \beta \hfill & \phantom{\rule{4pt}{0ex}}if\phantom{\rule{4pt}{0ex}}\mathrm{algorithm}-\mathrm{type}=\mathrm{RANDOMIZED}-\mathrm{SUBQUADRATIC};\hfill \\ \beta \hfill & \phantom{\rule{4pt}{0ex}}if\phantom{\rule{4pt}{0ex}}\mathrm{algorithm}-\mathrm{type}=\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}.\hfill \end{array}\right.\hfill \end{array}$$

Function

**Collision-Detection$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$**is used to detect a point, ${a}_{1}\in {U}_{1}$, in the motif area in ${S}_{1}$ and another ${a}_{1}^{\prime}\in {U}_{1}$ point in the motif area of ${S}_{1}$. The two points, ${a}_{1}$ and ${a}_{1}^{\prime}$, are close to the left and right motif boundaries of ${S}_{1}$, respectively. A similar pair of points, ${e}_{1}$ and ${e}_{1}^{\prime}$, in ${U}_{2}$ is also derived for ${S}_{2}$. See the examples in Section 3.2.3..**Collision-Detection**$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$

**Input:**a pair of $\Theta (n,G,\alpha )$-sequences, ${S}_{1}$ and ${S}_{2}$; ${U}_{i}$ is a set of locations in ${S}_{i}$ for $i=1,2$.

**Output:**the left and right rough boundaries of two sequences.

Let ${D}_{1}$ be all subsequences ${S}_{1}[a,a+{d}_{0}logn-1]$ of ${S}_{1}$ of a length of ${d}_{0}logn$ with $a\in {U}_{1}$.

Let ${D}_{2}$ be all subsequences ${S}_{2}[b,b+{d}_{0}logn-1]$ of ${S}_{2}$ of a length of ${d}_{0}logn$ with $b\in {U}_{2}$.

Find two subsequences, ${X}_{1}={S}_{1}[{a}_{1},{a}_{1}+{d}_{0}logn-1]\in {D}_{1}$ and

${X}_{2}={S}_{2}[{b}_{1},{b}_{1}+{d}_{0}logn-1]\in {D}_{2}$, such that ${a}_{1}$ is the least and $\mathrm{diff}({X}_{1},{X}_{2})\le {\omega}_{\mathrm{algorithm}-\mathrm{type}}$.

Find two subsequences, ${X}_{1}^{\prime}={S}_{1}[{a}_{1}^{\prime},{a}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{1}$ and

${X}_{2}^{\prime}={S}_{2}[{b}_{1}^{\prime},{b}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{2}$, such that ${a}_{1}^{\prime}$ is the largest and

$\mathrm{diff}({X}_{1}^{\prime},{X}_{2}^{\prime})\le {\omega}_{\mathrm{algorithm}-\mathrm{type}}$.

Find two subsequences, ${Y}_{1}={S}_{1}[{f}_{1},{f}_{1}+{d}_{0}logn-1]\in {D}_{1}$ and

${Y}_{2}={S}_{2}[{e}_{1},{e}_{1}+{d}_{0}logn-1]\in {D}_{2}$, such that ${e}_{1}$ is the least and

$\mathrm{diff}({Y}_{1},{Y}_{2})\le {\omega}_{\mathrm{algorithm}-\mathrm{type}}$.

Find two subsequences, ${Y}_{1}^{\prime}={S}_{1}[{f}_{1}^{\prime},{f}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{1}$ and

${Y}_{2}^{\prime}={S}_{2}[{e}_{1}^{\prime},{e}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{2}$, such that ${e}_{1}^{\prime}$ is the largest and

$\mathrm{diff}({Y}_{1}^{\prime},{Y}_{2}^{\prime})\le {\omega}_{\mathrm{algorithm}-\mathrm{type}}$.

Return $({a}_{1},{a}_{1}^{\prime},{e}_{1},{e}_{1}^{\prime})$.

**End of Collision-Detection.**

**Definition**

**14.**

Let $[a,b]$ be an interval with two integers boundaries, a and b, and l be a positive integer parameter. Define an l-partition of $[a,b]$ to be l-$P([a,b])$, which contains the intervals $[{a}_{1},{b}_{1}],[{a}_{2},{b}_{2}],\cdots ,[{a}_{r},{b}_{r}]$, such that ${a}_{1}=a,{b}_{r}=b,{a}_{i+1}={b}_{i}+1,{b}_{i}={a}_{i}+l-1$ for $i=1,2,\cdots ,r-1$ and ${a}_{r}\le {b}_{r}\le {a}_{i}+l-1$.

For example, the three-partition of the interval $[1,10]$ is 3-$P([1,10])=\{[1,3],[4,6],[7,9],[10,10]\}$. Function

**Point-Selection$(S,L,I)$**will be defined differently in three different algorithms, where I is an interval of positions in sequence S and L is a positive integer parameter. For randomized algorithms, some random points are selected in L-$P(I)$. For a deterministic algorithm, all points in I are selected. See the examples in Section 3.2.2..**Point-Selection$(S,L,I)$**

**Input:**a pair of $\Theta (n,G,\alpha )$-sequences, S, a size parameter, L, of partition and a set of intervals, I, of positions in S.

**Output:**a set, U, of positions from S, respectively.

**Steps:**

Let $U=\varnothing $.

If algorithm-type=RANDOMIZED-SUBLINEAR or RANDOMIZED-SUBQUADRATICand

if $(L\ge \frac{{(logn)}^{3+\tau}}{100})$:

for each interval, ${I}^{\prime}$, in I, obtain its L-partition in L-$P({I}^{\prime})$ and for each interval, J, in L-$P({I}^{\prime})$,

sample $M(L)$ (see Definition 10) random positions in J and put them into U.

Else,

put every position of I into ${U}_{1}$.

If algorithm-type=DETERMINISTIC-SUPERQUADRATIC,

put every position of I into U.

Return U.

**End of Point-Selection.**

The function,

**Improve-Boundaries**$({S}_{1},{a}_{l},{a}_{r},{S}_{2},{f}_{l},{f}_{r},L)$, is used to improve the existing rough left and right boundaries, ${a}_{l}$ and ${a}_{r}$, of ${S}_{1}$, respectively, and to improve the existing rough left and right boundaries, ${f}_{l}$ and ${f}_{r}$, of ${S}_{2}$, respectively. We assume ${a}_{l}\in [\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]$, ${a}_{r}\in [\mathrm{RB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]$, ${f}_{l}\in [\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]$ and ${f}_{r}\in [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]$. After calling this function, more accurate approximate boundaries will be derived. From the probabilistic analysis, we have a good chance to get the exact motif boundaries for both ${S}_{1}$ and ${S}_{2}$. See the examples in Section 3.2.7..**Improve-Boundaries**$({S}_{1},{a}_{l},{a}_{r},{S}_{2},{f}_{l},{f}_{r},L)$

**Input:**a $\Theta (n,G,\alpha )$-sequence, ${S}_{1}$, with rough left and right boundaries, ${a}_{l}$ and ${a}_{r}$, a $\Theta (n,G,\alpha )$-sequences, ${S}_{2}$ with rough left and right boundaries, ${f}_{l}$ and ${f}_{r}$, and an approximate distance, L, to the nearest motif boundary from those rough boundaries (the parameter, L, usually has the properties of $\mathrm{LB}({S}_{1})\in [{a}_{l}-L,{a}_{l}]$, $\mathrm{RB}({S}_{1})\in [{a}_{r},{a}_{r}+L]$, $\mathrm{LB}({S}_{2})\in [{f}_{l}-L,{f}_{l}]$ and $\mathrm{RB}({S}_{2})\in [{f}_{r},{f}_{r}+L]$).

**Output:**improved rough left and right boundaries for both ${S}_{1}$ and ${S}_{2}$.

**Steps:**

Find two subsequences, ${X}_{1}={S}_{1}[{a}_{1},{a}_{1}+{d}_{0}logn-1]$ and ${X}_{2}={S}_{2}[{b}_{2},{b}_{2}+{d}_{0}logn-1]$,

with ${a}_{1}\in [{a}_{l}-L,{a}_{l}+L]$ and ${b}_{2}\in [{f}_{l}-L,{f}_{l}+L]$, such that $\mathrm{diff}({X}_{1},{X}_{2})\le \beta $ and ${a}_{1}$ is

the least.

Find two subsequences, ${X}_{1}^{\prime}={S}_{1}[{a}_{1}^{\prime},{a}_{1}^{\prime}+{d}_{0}logn-1]$ and ${X}_{2}^{\prime}={S}_{2}[{b}_{2}^{\prime},{b}_{2}^{\prime}+{d}_{0}logn-1]$,

with ${a}_{1}^{\prime}\in [{a}_{r}-L,{a}_{r}+L]$ and ${b}_{2}\in [{f}_{r}-L,{f}_{r}+L]$, such that $\mathrm{diff}({X}_{1}^{\prime},{X}_{2}^{\prime})\le \beta $ and ${a}_{1}^{\prime}$ is

the largest.

Find two subsequences, ${Y}_{1}={S}_{1}[{e}_{1},{e}_{1}+{d}_{0}logn-1]$ and ${Y}_{2}={S}_{2}[{f}_{2},{f}_{2}+{d}_{0}logn-1]$,

with ${e}_{1}\in [{a}_{l}-L,{a}_{l}+L]$ and ${f}_{2}\in [{f}_{l}-L,{f}_{l}+L]$, such that $\mathrm{diff}({Y}_{1},{Y}_{2})\le \beta $ and ${f}_{2}$ is

the least.

Find two subsequences, ${Y}_{1}^{\prime}={S}_{1}[{e}_{1}^{\prime},{e}_{1}^{\prime}+{d}_{0}logn-1]$ and ${Y}_{2}^{\prime}={S}_{2}[{f}_{2}^{\prime},{f}_{2}^{\prime}+{d}_{0}logn-1]$,

with ${e}_{1}^{\prime}\in [{a}_{r}-L,{a}_{r}+L]$ and ${f}_{2}^{\prime}\in [{f}_{r}-L,{f}_{r}+L]$, such that $\mathrm{diff}({Y}_{1}^{\prime},{Y}_{2}^{\prime})\le \beta $ and ${f}_{2}^{\prime}$ is

the largest.

Return $({a}_{1},{a}_{1}^{\prime},{f}_{2},{f}_{2}^{\prime})$.

**End of Improve-Boundaries.**

The function,

**Initial-Boundaries**$({S}_{1},{S}_{2})$, detects the motif boundaries for two sequences, ${S}_{1}$ and ${S}_{2}$. It first detects rough motif boundaries that are controlled by parameter L. The rough boundaries will be improved to exact motif boundaries via calling**Improve-Boundaries**$(.)$. See the examples inSection 3.2.2., Section 3.2.3., Section 3.2.4., Section 3.2.5., Section 3.2.6., Section 3.2.7. and Section 3.2.8..**Initial-Boundaries**$({S}_{1},{S}_{2})$

**Input:**a pair of $\Theta (n,G,\alpha )$-sequences, ${S}_{1}$ and ${S}_{2}$.

**Output:**rough left boundary ${\mathrm{roughLeft}}_{{S}_{1}}$ of ${S}_{1}$, right boundary ${\mathrm{roughRight}}_{{S}_{1}}$ of ${S}_{1}$, rough left boundary ${\mathrm{roughLeft}}_{{S}_{2}}$ of ${S}_{2}$ and right boundary ${\mathrm{roughRight}}_{{S}_{2}}$ of ${S}_{2}$.

**Steps:**

Let ${U}_{1}={U}_{2}=\varnothing $.

Let $L={n}^{2/5}$.

Repeat.

Let ${U}_{1}=$Point-Selection$({S}_{1},L,[1,|{S}_{1}|])$.

Let ${U}_{2}=$Point-Selection$({S}_{2},L,[1,|{S}_{2}|])$.

Let $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$Collision-Detection$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$.

If (${L}_{{S}_{1}}\ne \varnothing $ and ${R}_{{S}_{1}}\ne \varnothing $),

then go to H.

Else, $L=L/2$,

until $(L<\frac{1}{2}\frac{{(logn)}^{3+\tau}}{100})$.

H: Return Improve-Boundaries$({S}_{1},{L}_{{S}_{1}},{R}_{{S}_{1}},{S}_{2},{L}_{{S}_{2}},{R}_{{S}_{2}},2L)$.

**End of Initial-Boundaries.**

If ${L}_{S}$ and ${R}_{S}$ are the left and right motif boundaries of a sequence, S, then the motif length is ${R}_{S}-{L}_{S}+1$. When we have the exact motif boundaries, ${L}_{{S}_{i}}^{\prime}$ and ${R}_{{S}_{i}}^{\prime}$, for most sequences, ${S}_{i}$, with high probability, their motif length can be derived via the median in ${\cup}_{i}\{{R}_{{S}_{i}}^{\prime}-{L}_{{S}_{i}}^{\prime}+1\}$. Therefore, we have the function,

**Motif-Length-And-Boundaries(${Z}_{1}$)**, to compute the length of the motif region.**Motif-Length-And-Boundaries**(${Z}_{1}$)

**Input:**${Z}_{1}=\{{S}_{1}^{\prime},\cdots ,{S}_{2{k}_{1}}^{\prime}\}$ is a set of independent $\Theta (n,G,\alpha )$ sequences.

**Steps:**

For $i=1$ to ${k}_{1}$,

let $({\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}},{\mathrm{roughRight}}_{{S}_{2i}^{\prime}})$=Initial-Boundaries$({S}_{2i-1}^{\prime},{S}_{2i}^{\prime})$.

Let ${L}_{1}$ be the median of ${\cup}_{i=1}^{{k}_{1}}\{({\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}-{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}+1)\}$.

Return ${L}_{1}$.

**End of Motif-Length-And-Boundaries.**

#### 4.2.2.. Extract-Phase of Algorithm Recover-Motif

After a set of motif candidates, W, is produced from Boundary-Phase of algorithm Recover-Motif, we use this set to match with another set of input sequences to recover the hidden motif by voting.

**Match**$({G}_{l},{G}_{r},{S}_{i}^{\u2033})$

**Input:**a motif left part, ${G}_{l}$ (which can be derived from the rough left boundary of an input sequence, S), a motif right part, ${G}_{r}$, and a sequence, ${S}_{i}^{\u2033}$, from the group, ${Z}_{2}$, with known rough left and right boundaries.

**Output:**either a rough motif region of ${S}_{i}^{\u2033}$ or an empty sequence, which means the failure in extracting the motif region, $\aleph ({S}_{i}^{\u2033})$, of ${S}_{i}^{\u2033}$.

**Steps:**

Find a position, a, in ${S}_{i}^{\u2033}$ with ${\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}\le a\le {\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}+(v+{u}_{2})$,

such that ${G}_{l}$ and ${S}_{i}^{\u2033}[a,a+|{G}_{l}|-1]$ are left matched (see Definition 9).

Find a position, b, in ${S}_{i}^{\u2033}$ with ${\mathrm{roughRight}}_{{S}_{i}^{\u2033}}-(v+{u}_{2})\le b\le {\mathrm{roughRight}}_{{S}_{i}^{\u2033}}$,

such that ${G}_{r}$ and ${S}_{i}^{\u2033}[b-|{G}_{r}|+1,b]$ are right matched (see Definition 9).

If both a and b are found,

then output ${S}_{i}^{\u2033}[a,b]$.

Else, output ∅ (empty string).

**End of Match.**

If the left, ${G}_{l}$, and right, ${G}_{r}$, motif parts are known, we extract all the motif regions for all sequences in the set, ${Z}_{2}$, by the function,

**Extract$({G}_{l},{G}_{r},{Z}_{2}$)**.**Extract**$({G}_{l},{G}_{r},{Z}_{2}$)

Input ${Z}_{2}=\{{S}_{1}^{\u2033},{S}_{2}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ and left and right motif parts, ${G}_{l}$ and ${G}_{r}$ (see function

**Match**$({G}_{l},{G}_{r},{S}_{i})$).**Steps:**

For each ${S}_{i}^{\u2033}$ with $i=1,2,\cdots ,{k}_{2}$,

let ${G}_{i}^{\u2033}=\mathrm{Match}({G}_{l},{G}_{r},{S}_{i}^{\u2033})$.

Return $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$.

**End of Extract.**

The following is Extract-Phase of algorithm Recover-Motif. It extracts the motif regions of another set, ${Z}_{2}$, of input sequences. The function is based on the condition that exact motif boundaries can be derived for most sequences. See the examples in Section 3.2.9..

**Extract-Phase**(${S}^{\prime},{Z}_{2}$):

Input ${S}^{\prime}$ is an input sequence with known ${\mathrm{roughLeft}}_{{S}^{\prime}}$ and ${\mathrm{roughRight}}_{{S}^{\prime}}$ for its rough left and right boundaries, respectively, and ${Z}_{2}=\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ is a set of input sequences.

**Steps:**

For each subsequence ${G}_{l}={S}^{\prime}[a,a+{d}_{0}logn-1]$ with $a\in [{\mathrm{roughLeft}}_{{S}^{\prime}},{\mathrm{roughLeft}}_{{S}^{\prime}}+(v+{u}_{1})]$

and ${G}_{r}={S}^{\prime}[b-{d}_{0}logn+1,b]$, with $b\in [{\mathrm{roughRight}}_{{S}^{\prime}}-(v+{u}_{1}),{\mathrm{roughRight}}_{{S}^{\prime}}]$,

let $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ be the output from Extract$({G}_{l},{G}_{r},{Z}_{2}$).

If the number of empty sequences in ${G}_{1}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033}$ is at most $({Q}_{0}+(R+2\u03f5)){k}_{2}$,

then return $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$.

Return ∅ (empty set).

**End of Extract-Phase .**

#### 4.2.3.. Voting-Phase

The function, Vote$({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$, is to generate another sequence, ${G}^{\prime}$, by voting, where ${G}^{\prime}[i]$ is the most frequent character among ${G}_{1}^{\u2033}[i],{G}_{2}^{\u2033}[i],\cdots ,{G}_{{k}_{2}}^{\u2033}[i]$. See the examples in Section 3.2.10..

**Voting-Phase**$({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$

**Input:**$\Theta (n,G,\alpha )$ sequences, ${G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033}$, of the same length, m.

**Output:**a sequence, ${G}^{\prime}$, which is derived by voting on every position of the input sequences.

**Steps:**

For each $j=1,\cdots ,m$,

let ${a}_{j}$ be the most frequent character among ${G}_{1}^{\u2033}[j],\cdots ,{G}_{{k}_{2}}^{\u2033}[j]$.

Return ${G}^{\prime}={a}_{1}\cdots {a}_{m}$.

**End of Vote.**

#### 4.2.4.. Entire Algorithm Recover-Motif

The entire algorithm is described below. The input has two sets of sequences, ${Z}_{1}$ and ${Z}_{2}$. It detects the motif boundaries for the sequences in ${Z}_{1}$ via pairwise comparisons and, also, the motif length. The motif regions of the sequences in ${Z}_{2}$ are detected in the next phase and will be extracted. The original motif is recovered via voting for each column of characters among the extracted motif regions.

We maintain the sizes of ${Z}_{1}$ and ${Z}_{2}$ to be roughly equal, which implies:

$$\begin{array}{c}\hfill |{Z}_{1}|=\Theta (|{Z}_{2}|)\end{array}$$

**Algorithm Recover-Motif (Z)**

**Input**: $Z={Z}_{1}\cup {Z}_{2}$, where ${Z}_{1}=\{{S}_{1}^{\prime},\cdots ,{S}_{2{k}_{1}}^{\prime}\}$ and ${Z}_{2}=\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ are two sets of input sequences.

**Steps:**

**Preprocessing part:**

For each $S\in {Z}_{1}\cup {Z}_{2}$, let ${\mathrm{roughLeft}}_{S}={\mathrm{roughRight}}_{S}=0$ (the two boundaries are unknown).

${l}_{motif}=$MotifLengthAndBoundaries(${Z}_{1}$).

Let $L={l}_{motif}/4$.

For $i=1$ to ${k}_{1}$,

let ${U}_{{S}_{2i-1}^{\prime}}=$Point-Selection$({S}_{2i-1}^{\prime},L,[{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}-2L,{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}+2L])\cup $

Point-Selection$({S}_{2i-1}^{\prime},L,[{\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}-2L,{\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}+2L])$.

For $j=1$ to ${k}_{2}$,

let ${U}_{{S}_{j}^{\u2033}}=$Point-Selection$({S}_{j}^{\u2033},L,[1,|{S}_{j}^{\u2033}|])$.

For $i=1$ to ${k}_{1}$,

for each ${S}_{j}^{\u2033}\in {Z}_{2}$,

Let $({L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{L}_{{S}_{j}^{\u2033}},{R}_{{S}_{j}^{\u2033}})=$Collision-Detection$({S}_{2i-1}^{\prime},{U}_{{S}_{2i-1}^{\prime}},{S}_{j}^{\u2033},{U}_{{S}_{j}^{\u2033}})$.

Let $({L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{\mathrm{roughLeft}}_{{S}_{j}^{\u2033}},{\mathrm{roughRight}}_{{S}_{j}^{\u2033}})$=

Improve-Boundaries$({S}_{2i-1}^{\prime},{L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{S}_{j}^{\u2033},{L}_{{S}_{j}^{\u2033}},{R}_{{S}_{j}^{\u2033}},2L)$.

Let $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ be the output from Extract-Phase(${S}_{2i-1}^{\prime},{Z}_{2}$).

If $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ is not empty,

then go to the Voting part.

**Voting part:**

Return Voting-Phase(${G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033}$).

**End of Algorithm Recover-Motif .**

## 5. Deterministic Algorithm

In this section, we give a deterministic algorithm, which is a simplified version of the unified algorithm described before in Section 4.2. It is simpler than the randomized versions. The first phase of Algorithm Recover-Motif (.) finds the rough motif boundaries of all input sequences. It first detects the rough motif boundaries of one sequence via comparing two input sequences. Then, the rough boundaries of the first sequence are used to find the rough motif boundaries of other input sequences. We still let:

$$\begin{array}{c}\hfill {\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}=\beta .\end{array}$$

**Collision-Detection$({S}_{1},{S}_{2})$**

**Input:**a pair of $\Theta (n,G,\alpha )$-sequences, ${S}_{1}$ and ${S}_{2}$; ${U}_{i}$ is a set of locations in ${S}_{i}$ for $i=1,2$.

**Output:**the left and right rough boundaries of two sequences.

Let ${D}_{1}$ be all subsequences, ${S}_{1}[a,a+{d}_{0}logn-1]$, of ${S}_{1}$ of a length of ${d}_{0}logn$ with $a\in [1,|{S}_{1}|]$.

Let ${D}_{2}$ be all subsequences, ${S}_{2}[b,b+{d}_{0}logn-1]$, of ${S}_{2}$ of a length of ${d}_{0}logn$ with $b\in [1,|{S}_{2}|]$.

Find two subsequences, ${X}_{1}={S}_{1}[{a}_{1},{a}_{1}+{d}_{0}logn-1]\in {D}_{1}$ and

${X}_{2}={S}_{2}[{b}_{1},{b}_{1}+{d}_{0}logn-1]\in {D}_{2}$, such that ${a}_{1}$ is the least and $\mathrm{diff}({X}_{1},{X}_{2})\le {\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}$.

Find two subsequences, ${X}_{1}^{\prime}={S}_{1}[{a}_{1}^{\prime},{a}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{1}$ and

${X}_{2}^{\prime}={S}_{2}[{b}_{1}^{\prime},{b}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{2}$, such that ${a}_{1}^{\prime}$ is the largest and

$\mathrm{diff}({X}_{1}^{\prime},{X}_{2}^{\prime})\le {\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}$.

Find two subsequences, ${Y}_{1}={S}_{1}[{f}_{1},{f}_{1}+{d}_{0}logn-1]\in {D}_{1}$ and

${Y}_{2}={S}_{2}[{e}_{1},{e}_{1}+{d}_{0}logn-1]\in {D}_{2}$, such that ${e}_{1}$ is the least and

$\mathrm{diff}({Y}_{1},{Y}_{2})\le {\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}$.

Find two subsequences, ${Y}_{1}^{\prime}={S}_{1}[{f}_{1}^{\prime},{f}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{1}$ and

${Y}_{2}^{\prime}={S}_{2}[{e}_{1}^{\prime},{e}_{1}^{\prime}+{d}_{0}logn-1]\in {D}_{2}$, such that ${e}_{1}^{\prime}$ is the largest and

$\mathrm{diff}({Y}_{1}^{\prime},{Y}_{2}^{\prime})\le {\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}$.

Return $({a}_{1},{a}_{1}^{\prime},{e}_{1},{e}_{1}^{\prime})$.

**End of Collision-Detection.**

Function

**Point-Selection**$({S}_{1},{S}_{2},L)$ is not used in the deterministic algorithm.**Improve-Boundaries**$({S}_{1},{a}_{l},{a}_{r},{S}_{2},{f}_{l},{f}_{r},L)$ is the same as that in the randomized algorithms.

**Initial-Boundaries**$({S}_{1},{S}_{2})$

**Input:**a pair of $\Theta (n,G,\alpha )$-sequences, ${S}_{1}$ and ${S}_{2}$.

**Output:**rough left boundary ${\mathrm{roughLeft}}_{{S}_{1}}$ of ${S}_{1}$, right boundary ${\mathrm{roughRight}}_{{S}_{1}}$ of ${S}_{1}$, rough left boundary ${\mathrm{roughLeft}}_{{S}_{2}}$ of ${S}_{2}$ and right boundary ${\mathrm{roughRight}}_{{S}_{2}}$ of ${S}_{2}$.

**Steps:**

Let ${U}_{1}={U}_{2}=\varnothing $.

Let $L={n}^{2/5}$.

Repeat.

Let $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$Collision-Detection$({S}_{1},{S}_{2})$.

If (${L}_{{S}_{1}}\ne \varnothing $ and ${R}_{{S}_{1}}\ne \varnothing $),

then go to H.

Else, $L=L/2$,

until $(L<\frac{1}{2}\frac{{(logn)}^{3+\tau}}{100})$.

H: Return Improve-Boundaries$({S}_{1},{L}_{{S}_{l}},{R}_{{S}_{1}},{S}_{2},{L}_{{S}_{2}},{R}_{{S}_{2}},2L)$.

**End of Initial-Boundaries.**

**Motif-Length-And-Boundaries**(${Z}_{1}$) is the same as that before.

**Match**$({G}_{l},{G}_{r},{S}_{i})$ is the same as that for the randomized algorithm.

**Extract**$({G}_{l},{G}_{r},{Z}_{2}$) is the same as that for the randomized algorithm.

The following is Extract-Phase of algorithm Recover-Motif. It extracts the motif regions of another set, ${Z}_{2}$, of input sequences.

**Extract-Phase**(${S}^{\prime},{Z}_{2}$) is the same as that for the randomized algorithm.

**Voting-Phase**$({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ is the same as that for the randomized algorithm.

The entire deterministic algorithm is described below. We maintain the sizes of ${Z}_{1}$ and ${Z}_{2}$ to be roughly equal.

**Algorithm Recover-Motif (Z)**

**Input**: $Z={Z}_{1}\cup {Z}_{2}$, where ${Z}_{1}=\{{S}_{1}^{\prime},\cdots ,{S}_{2{k}_{1}}^{\prime}\}$ and ${Z}_{2}=\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ are two sets of input sequences.

**Steps:**

**Preprocessing part:**

For each $S\in {Z}_{1}\cup {Z}_{2}$, let ${\mathrm{roughLeft}}_{S}={\mathrm{roughRight}}_{S}=0$ (the two boundaries are unknown).

${l}_{motif}=$MotifLengthAndBoundaries(${Z}_{1}$).

Let $L={l}_{motif}/4$.

For $i=1$ to ${k}_{1}$,

for each ${S}_{j}^{\u2033}\in {Z}_{2}$,

let $({L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{L}_{{S}_{j}^{\u2033}},{R}_{{S}_{j}^{\u2033}})=$Collision-Detection$({S}_{2i-1}^{\prime},{S}_{j}^{\u2033})$.

Let $({L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{\mathrm{roughLeft}}_{{S}_{j}^{\u2033}},{\mathrm{roughRight}}_{{S}_{j}^{\u2033}})$=

Improve-Boundaries$({S}_{2i-1}^{\prime},{L}_{{S}_{2i-1}^{\prime}},{R}_{{S}_{2i-1}^{\prime}},{S}_{j}^{\u2033},{L}_{{S}_{j}^{\u2033}},{R}_{{S}_{j}^{\u2033}},2L)$.

Let $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ be the output from Extract-Phase(${S}_{2i-1}^{\prime},{Z}_{2}$).

If $({G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033})$ is not empty,

then go to the Voting part.

**Voting part:**

Return Voting-Phase(${G}_{1}^{\u2033},{G}_{2}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033}$).

**End of Algorithm Recover-Motif .**

## 6. Analysis of the Algorithm

The correctness of the algorithm will be proven via a series of lemmas in Section 6.2 and Section 6.3. Section 6.2 is for Boundary-Phase and Section 6.3 is for Extract-Phase. Furthermore, Section 6.3 gives some lemmas for the two randomized algorithms, and Section 6.4 gives the proof for the deterministic algorithm.

#### 6.1. Review of Some Classical Results in Probability

Some well-known results in classical probability theory are listed. The readers can skip this section if they understand them well. The inclusion of these results make the paper self-contained.

- For a list of events, ${A}_{1},\cdots ,{A}_{m}$, $\mathrm{Pr}[{A}_{1}\cup {A}_{2}\cup \cdots \cup {A}_{m}]\le \mathrm{Pr}[{A}_{1}]+\mathrm{Pr}[{A}_{2}]+\cdots +\mathrm{Pr}[{A}_{m}]$.
- For two independent events, A and B, $\mathrm{Pr}[A\cap B]=\mathrm{Pr}[A]\mathrm{Pr}[B]$.
- For a random variable, Y, $\mathrm{Pr}[Y\ge t]\le \frac{E[Y]}{t}$ for all positive real numbers, t. This is called Markov inequality.

The analysis of our algorithm employs the Chernoff bound [22] and Corollary 18 below, which can be derived from it (see [11]).

**Theorem**

**15**

**([22]).**Let ${X}_{1},\cdots ,{X}_{n}$ be n independent random 0–1 variables, where ${X}_{i}$ takes one with a probability of ${p}_{i}$. Let $X={\sum}_{i=1}^{n}{X}_{i}$, and $\mu =E[X]$. Then, for any $\delta >0$:

- i.
- $Pr(X<(1-\delta )\mu )<{e}^{-\frac{1}{2}\mu {\delta}^{2}}$ and
- ii.
- $Pr(X>(1+\delta )\mu )<{\left[\frac{{e}^{\delta}}{{(1+\delta )}^{(1+\delta )}}\right]}^{\mu}$.

We follow the proof of Theorem 15 to make the following version of the Chernoff bound, so that it can be used in our algorithm analysis.

**Theorem**

**16.**

Let ${X}_{1},\cdots ,{X}_{n}$ be n independent random 0–1 variables, where ${X}_{i}$ takes one with a probability of at most p. Let $X={\sum}_{i=1}^{n}{X}_{i}$. Then, for any $\delta >0$, $Pr(X>(1+\delta )pn)<{\left[\frac{{e}^{\delta}}{{(1+\delta )}^{(1+\delta )}}\right]}^{pn}$.

Define $g(\delta )=\frac{{e}^{\delta}}{{(1+\delta )}^{(1+\delta )}}$. We note that $g(\delta )$ is always strictly less than one for all $\delta >0$ and $g(\delta )$ is fixed if δ is a constant. This can be verified by checking that the function $f(x)=ln\frac{{e}^{x}}{{(1+x)}^{(1+x)}}=x-(1+x)ln(1+x)$ is decreasing and $f(0)=0$. This is because ${f}^{\prime}(x)=-ln(1+x)$, which is less than zero for all $x>0$.

**Theorem**

**17.**

Let ${X}_{1},\cdots ,{X}_{n}$ be n independent random 0–1 variables, where ${X}_{i}$ takes one with a probability of at most p. Let $X={\sum}_{i=1}^{n}{X}_{i}$. Then, for any $\delta >0$, $Pr(X<(1-\delta )pn)<{e}^{-{\frac{1}{2}}^{pn}{\delta}^{2}}$.

**Corollary**

**18**

**([11]).**Let ${X}_{1},\cdots ,{X}_{n}$ be n independent random 0–1 variables, and $X={\sum}_{i=1}^{n}{X}_{i}$.

i) If ${X}_{i}$ takes one with a probability of at most p, then for any $\frac{1}{3}>\u03f5>0$, $Pr(X>pn+\u03f5n)<{e}^{-\frac{1}{3}n{\u03f5}^{2}}$.

ii) If ${X}_{i}$ takes one with a probability of at least p, then for any $\u03f5>0$, $Pr(X<pn-\u03f5n)<{e}^{-\frac{1}{2}n{\u03f5}^{2}}$.

#### 6.2. Analysis of Boundary-Phase of Algorithm Recover-Motif

Lemma 19 shows that with only a small probability, a sequence can match a random sequence. It will be used to prove that when two substrings in two different $\Theta (n,G,\alpha )$-sequences are similar, they are unlikely not to coincide with the motif regions in the two $\Theta (n,G,\alpha )$-sequences, respectively.

**Lemma**

**19.**

Assume that ${X}_{1}$ and ${X}_{2}$ are two independent sequences of the same length and that every character of ${X}_{2}$ is a random character from Σ. Then:

- i.
- if $1\le |{X}_{1}|=|{X}_{2}|<v$, then the probability that ${X}_{1}$ and ${X}_{2}$ are matched is $\le \frac{1}{{t}^{|{X}_{1}|}}$ ($t=||\Sigma ||$); and
- ii.
- the probability for $\mathrm{diff}({X}_{1},{X}_{2})\le \beta $ is at most ${e}^{-\frac{{\u03f5}^{2}|{X}_{1}|}{3}}$.

**Proof:**

The two statements are proven as follows.

Statement i: For every character, ${X}_{2}[j]$, with $1\le j<v$, the probability is $\frac{1}{t}$ that ${X}_{2}[j]={X}_{1}[j]$.

Statement ii: For every character, ${X}_{2}[j]$, with $1\le j\le |{X}_{2}|$, the probability is $\frac{1}{t}$ for ${X}_{2}[j]$ to equal ${X}_{1}[j]$. If $\mathrm{diff}({X}_{1},{X}_{2})\le \beta $, the two sequences, ${X}_{1}$ and ${X}_{2}$, are identical in at least $(1-\beta )|{X}_{1}|$ positions, but the expected number of positions where the two sequences are identical is $\frac{1}{t}|{X}_{1}|$. The probability for $\mathrm{diff}({X}_{1},{X}_{2})\le \beta $ is at most ${e}^{-\frac{{(1-\beta -\frac{1}{t})}^{2}}{3}|{X}_{1}|}\le {e}^{-\frac{{\u03f5}^{2}}{3}|{X}_{1}|}$ by Corollary 18, Definition and 9, items (xiv) and xii, equation (8) and inequality (2) in Definition 8. ▮

Lemma 20 shows that with a small probability, an input $\Theta (n,G,\alpha )$ sequence contains a motif region that has many mutations.

**Lemma**

**20.**

- i.
- With a probability of at most ${c}^{t}$, a $\Theta (n,G,\alpha )$ sequence, S, changes more than $\frac{\beta}{2}t$ characters in its motif region, $\aleph (S)[i,i+t-1]$, with $1\le i\le i+t-1\le |G|$, where c is defined in item (v) in Definition 8.
- ii.
- With a probability of at most $\frac{{c}^{y}}{1-c}$, a $\Theta (n,G,\alpha )$ sequence, S, changes more than $\frac{\beta}{2}t$ characters in its left motif region, $\aleph (S)[1,t]$, for some t with $y\le t\le |G|$, where c is defined in item (v) in Definition 8.

**Proof:**

Statement i: Every character in the $\aleph (S)$ region has a probability of at most α to mutate. We know that $|\aleph (S)|=|G|\ge d$. By Corollary 18, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}}{3}t}$, $\aleph (S)[i,i+t-1]$ has more than $(\alpha +\u03f5)t$ mutations.

Statement ii: We know that $|\aleph (S)|=|G|\ge d$. By Corollary 18, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}}{3}t}$, a sequence, S, in ${Z}_{1}$ has more than $(\alpha +\u03f5)t$ mutations (recall the setting for β in Definition 9) among the first left t characters. The total probability is at most ${\sum}_{t=y}^{\infty}{e}^{-\frac{{\u03f5}^{2}}{3}t}=\frac{{c}^{y}}{1-c}$. ▮

Lemma 21 shows that Improve-Boundaries() has a good chance to improve the accuracy of rough motif boundaries. Note that $\mathrm{LB}(S)$ and $\mathrm{RB}(S)$ are the left and right motif boundaries of S, respectively (see Definition 11).

**Lemma**

**21.**

Assume that $\Theta (n,G,\alpha )$ sequence ${S}_{i}$ has ${L}_{{S}_{i}}\in [\mathrm{LB}({S}_{i})-L,\mathrm{LB}({S}_{i})+L]$ and ${R}_{{S}_{i}}\in [\mathrm{RB}({S}_{i})-L,\mathrm{RB}({S}_{i})+L]$ for $i=1,2$. Then, for $({\mathrm{roughLeft}}_{{S}_{1}},{\mathrm{roughRight}}_{{S}_{1}},{\mathrm{roughLeft}}_{{S}_{2}},$${\mathrm{roughRight}}_{{S}_{2}})$=Improve-Boundaries$({S}_{1},{L}_{{S}_{1}},{R}_{{S}_{1}},{S}_{2},{L}_{{S}_{2}},{R}_{{S}_{2}},L)$, we have the following two facts:

- i.
- with a probability of at most $\frac{2{c}^{v}}{1-c}+\frac{2(v+u){c}^{v+u}}{{(1-c)}^{2}}+\frac{1}{5\xb7{2}^{x}n}$; ${\mathrm{roughLeft}}_{{S}_{i}}$ is not in $[\mathrm{LB}({S}_{i})-(v+u),\mathrm{LB}({S}_{i})]$ for $i=1,2$.
- ii.
- with a probability of at most $\frac{2{c}^{v}}{1-c}+\frac{2(v+u){c}^{v+u}}{{(1-c)}^{2}}+\frac{1}{5\xb7{2}^{x}n}$, ${\mathrm{roughRight}}_{{S}_{i}}$ is not in $[\mathrm{RB}({S}_{i}),\mathrm{RB}({S}_{i})+(v+u)]$ for $i=1,2$.
- iii.
- Improve-Boundaries$({S}_{1},{L}_{{S}_{1}},{R}_{{S}_{1}},{S}_{2},{L}_{{S}_{2}},{R}_{{S}_{2}},L)$ runs in $O({L}^{2}logn)$ time.

**Proof:**

We need a bound for the following inequality:
Let $f(x)={\sum}_{i=j}^{\infty}{e}^{\theta ix}$. Compute the derivative ${f}^{\prime}(x)=\theta {\sum}_{i=j}^{\infty}i{e}^{\theta ix}$. We also have the closed form for the function $f(x)=\frac{{e}^{\theta jx}}{1-{e}^{\theta x}}$, which implies:

$$\begin{array}{c}\hfill \sum _{i=j}^{\infty}i{a}^{i}<\frac{j{a}^{j}}{{(1-a)}^{2}}\end{array}$$

$$\begin{array}{ccc}\hfill {f}^{\prime}(x)& =& \frac{\theta j{e}^{\theta jx}(1-{e}^{\theta x})-{e}^{\theta jx}(-\theta {e}^{\theta x})}{{(1-{e}^{\theta x})}^{2}}\hfill \end{array}$$

$$\begin{array}{ccc}& =& \frac{\theta j{e}^{\theta jx}-\theta (j-1){e}^{\theta (j+1)x}}{{(1-{e}^{\theta x})}^{2}}\hfill \end{array}$$

Let $\theta =lna$ and $x=1$. We have ${\sum}_{i=j}^{\infty}i{a}^{i}=\frac{j{a}^{j}-(j-1){a}^{j+1}}{{(1-a)}^{2}}<\frac{j{a}^{j}}{{(1-a)}^{2}}$.

Statement i. By Lemma 20, with a probability of at most $\frac{2{c}^{v}}{1-c}$, one of the left motif first y character region of ${S}_{i}$ will change $\frac{\beta}{2y}$ characters. Therefore, with a probability of at most ${P}_{1}=\frac{2{c}^{v}}{1-c}$, ${\mathrm{roughLeft}}_{{S}_{i}}>\mathrm{LB}({S}_{i})$.

For a pair of positions, p, in ${S}_{1}$, and q, in ${S}_{2}$, without loss of generality, assume that p has a larger distance to the left boundary $\mathrm{LB}({S}_{1})$ of ${S}_{1}$ than q to the left boundary $\mathrm{LB}({S}_{2})$ of ${S}_{2}$. Let $v+y$ be the distance from p to the left boundary $\mathrm{LB}({S}_{1})$ of ${S}_{1}$.

By Lemma 19, the probability is at most ${c}^{v+y}$ that there will be a match. There are at most $(v+y)$ cases for q. With a probability of at most ${P}_{2}=2{\sum}_{y=u}^{\infty}(v+y){c}^{v+y}<\frac{2(v+u){c}^{v+u}}{{(1-c)}^{2}}$, by inequality (20), ${\mathrm{roughLeft}}_{{S}_{1}}<LB({S}_{1})-(v+u)$.

For the cases that one position is in a random region and has a distance more than ${d}_{0}logn$ from the left boundary, the probability is at most ${P}_{3}={n}^{2}{c}^{{d}_{0}logn}<\frac{1}{5\xb7{2}^{x}n}$ by inequality (14).

Therefore, we have a total probability of at most ${P}_{1}+{P}_{2}+{P}_{3}$ that ${\mathrm{roughLeft}}_{{S}_{1}}$ is not in $[\mathrm{LB}({S}_{1})-(v+u),\mathrm{LB}({S}_{1})]$.

Statement ii. One can also provide a symmetric analogous proof for this statement.

Statement iii. The computation time easily follows from the implementation of Improve-Boundaries $({S}_{1},{L}_{{S}_{1}},{R}_{{S}_{1}},{S}_{2},{L}_{{S}_{2}},{R}_{{S}_{2}})$. ▮

**Lemma**

**22.**

Assume that for each L with $0<L\le \frac{|G|}{2}$, with a probability of at most $\varsigma (n)$, ${L}_{{S}_{i}}\notin [{\mathrm{LB}}_{{S}_{i}}-L,{\mathrm{LB}}_{{S}_{i}}+L]$ for $i=1,2$, where $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$ Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2})$,${U}_{1}=$ Point-Selection$({S}_{1},L)$ and ${U}_{2}=$ Point-Selection$({S}_{2},L)$. Then, with a probability of at most $\varsigma (n)+\frac{2(v+{u}_{1}){c}^{v+{u}_{1}}}{{(1-c)}^{2}}+\frac{{c}^{v}}{1-c}+\frac{1}{5\xb7{2}^{x}n}$, Initial-Boundary$({S}_{1},{S}_{2})$ returns $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})$ with ${L}_{{S}_{i}}\notin [\mathrm{LB}({S}_{i})-(v+{u}_{1}),\mathrm{LB}({S}_{i})]$ or ${R}_{{S}_{i}}\notin [\mathrm{RB}({S}_{i}),\mathrm{RB}({S}_{i})+(v+{u}_{1}))]$ for $i=1,2$.

**Proof:**

It follows from Lemma 21: ▮

**Lemma**

**23.**

Assume that with a probability of $p<0.5$, each ${S}_{2i-1}^{\prime}$ has its rough boundaries, ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{LB}({S}_{2i-1}^{\prime})-u,\mathrm{LB}({S}_{2i-1}^{\prime})]$ or ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+u]$; then, with a probability of at most ${e}^{-{(0.5-p-\u03f5)}^{2}{k}_{1}/3}$, ${l}_{motif}$ is not in $[|G|-2u,|G|+2u]$, where ${l}_{motif}$ is selected as the median of ${\cup}_{i=1}^{{k}_{1}}\{({\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}-{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}})\}$.

**Proof:**

If both ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\in [\mathrm{LB}({S}_{2i-1}^{\prime})-u,\mathrm{LB}({S}_{2i-1}^{\prime})]$ and ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\in [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+u]$, then $({\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}-{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}})$ is in $[|G|-2u,|G|+2u]$.

If the median of ${\cup}_{i=1}^{{k}_{1}}\{({\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}-{\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}})\}$ is not in $[|G|-2u,|G|+2u]$, then there are at least ${k}_{1}$ numbers, i, to have ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{LB}({S}_{2i-1}^{\prime})-u,\mathrm{LB}({S}_{2i-1}^{\prime})]$ or ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+u]$.

On the other hand, the probability is at most p, ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{LB}({S}_{2i-1}^{\prime})-u,\mathrm{LB}({S}_{2i-1}^{\prime})]$ or ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+u]$. Therefore, this lemma follows from Corollary 18. ▮

For a $\Theta (n,G,\alpha )$-sequence S, we often obtain its left rough boundary with ${\mathrm{roughLeft}}_{S}\le \mathrm{LB}(S)$. Sometimes, its exact left boundary may be missed in the algorithm.

**Definition**

**24.**

- A $\Theta (n,G,\alpha )$-sequence, S, misses its left boundary if ${\mathrm{roughLeft}}_{S}>\mathrm{LB}(S)$.
- A $\Theta (n,G,\alpha )$-sequence, S, misses its right boundary if ${\mathrm{roughRight}}_{S}<\mathrm{RB}(S)$.

**Definition**

**25.**

- i.
- A $\Theta (n,G,\alpha )$-sequence, S, contains a left half stable motif region, $\aleph (S)$, if $\mathrm{diff}({G}^{\prime}[1,h],G[1,h])\le \frac{\beta}{2}$ for all $h=v,v+1,\cdots ,m$, where ${G}^{\prime}=\aleph (S)$, and $m=|G|$, as defined in Definition 8 and Section 2, respectively.
- ii.
- A $\Theta (n,G,\alpha )$-sequence, S, contains a right half stable motif region, $\aleph (S)$, if $\mathrm{diff}({G}^{\prime}[m-h,m],G[m-h,m])\le \frac{\beta}{2}$ for $h=v-1,v+1,\cdots ,m-1$, where ${G}^{\prime}=\aleph (S)$ and $m=|G|$.
- iii.
- A $\Theta (n,G,\alpha )$-sequence, S, contains a stable motif region, $\aleph (S)$, satisfying the following conditions: (1) ${G}^{\prime}[i]=G[i]$ for $i=1,\cdots ,v-1$; (2) ${G}^{\prime}[m-i+1]=G[m-i+1]$ for $i=1,\cdots ,v-1$; and (3) the S motif region is both left and right half stable, where ${G}^{\prime}=\aleph (S)$ and $m=|G|$.

**Definition**

**26.**

Assume that:

- ${l}_{motif}\in [|G|-2(v+{u}_{1}),|G|+2(v+{u}_{1})]$;
- Scontains both a left half and a right half stable motif region and ${\mathrm{roughLeft}}_{S}\in [\mathrm{LB}(S)-(v+{u}_{1}),\mathrm{LB}(S)]$ and ${\mathrm{roughRight}}_{S}\in [\mathrm{RB}(S),\mathrm{RB}(S)+(v+{u}_{1})]$ (see Definition 8 for ${u}_{1}$ and v); and
- for each L with $(v+{u}_{1})<L\le \frac{|G|}{2}$, if ${S}_{1}$ has ${\mathrm{roughLeft}}_{{S}_{1}}\in [{\mathrm{LB}}_{{S}_{1}}-L,{\mathrm{LB}}_{{S}_{1}}+L]$ and ${\mathrm{roughRight}}_{{S}_{1}}\in [{\mathrm{RB}}_{{S}_{1}}-L,{\mathrm{RB}}_{{S}_{1}}+L]$, then with a probability of at most $\varsigma (n)$, ${L}_{{S}_{i}^{\u2033}}\notin [{\mathrm{LB}}_{{S}_{i}^{\u2033}}-2L,{\mathrm{LB}}_{{S}_{i}^{\u2033}}+2L]$ for $i=1,2$, where $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{i}^{\u2033}},{R}_{{S}_{i}^{\u2033}})=$ Collision-Detection(${S}_{1},{U}_{1},{S}_{i}^{\u2033},{U}_{2})$, ${U}_{1}=$ Point-Selection$({S}_{1},L,[{\mathrm{roughLeft}}_{{S}_{1}}-2L,{\mathrm{roughLeft}}_{{S}_{1}}+2L])\cup $ Point-Selection$({S}_{1},L,[{\mathrm{roughRight}}_{{S}_{1}}-2L,{\mathrm{roughRight}}_{{S}_{1}}+2L])$ and ${U}_{2}=$ Point-Selection$({S}_{i}^{\u2033},$$L,[1,|{S}_{i}^{\u2033}|])$.
- The rough boundaries for all sequences, ${S}_{i}^{\u2033}\in {Z}_{2}$, are computed via $({L}_{S},{R}_{S},{L}_{{S}_{i}^{\u2033}},{R}_{{S}_{i}^{\u2033}})=$ Collision-Detection$(S,{U}_{S},{S}_{i}^{\u2033},{U}_{{S}_{i}^{\u2033}})$ and $({L}_{S},{R}_{S},{\mathrm{roughLeft}}_{{S}_{i}^{\u2033}},{\mathrm{roughRight}}_{{S}_{i}^{\u2033}})$ = Improve-Boundaries$(S,$ ${L}_{S},{R}_{S},{S}_{i}^{\u2033},{L}_{{S}_{i}^{\u2033}},{R}_{{S}_{i}^{\u2033}},2L)$.

Then, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, there are more than $(2(\varsigma (n)+(v+{u}_{1})\frac{{c}^{v+u}}{1-c}+\frac{{c}^{v}}{1-c})+\u03f5){k}_{2}$ sequences ${S}_{i}^{\u2033}$ in $\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ with $\mathrm{roughLeft}({S}_{i}^{\u2033})\notin [\mathrm{LB}({S}_{i}^{\u2033})-(v+u),\mathrm{LB}({S}_{i}^{\u2033})]$ or $\mathrm{roughRight}({S}_{i}^{\u2033})\notin [\mathrm{RB}({S}_{i}^{\u2033}),\mathrm{RB}({S}_{i}^{\u2033})+(v+u)]$.

**Proof:**

According to the condition of this lemma, with a probability of at most ${P}_{1}=\varsigma (n)$, ${L}_{{S}_{i}^{\u2033}}\notin [{\mathrm{LB}}_{{S}_{i}^{\u2033}}-2L,{\mathrm{LB}}_{{S}_{i}^{\u2033}}+2L]$, where $({L}_{S},{R}_{S},{L}_{{S}_{i}^{\u2033}},{R}_{{S}_{i}^{\u2033}})=$ Collision-Detection($S,{U}_{1},{S}_{i}^{\u2033},{U}_{2})$ and $({U}_{1},{U}_{2})=$ Point-Selection$(S,{S}_{i}^{\u2033},L)$.

For a fixed pattern from S, by Lemma 19, with a probability of at most ${\sum}_{y=v+u}^{\infty}{c}^{y}=\frac{{c}^{v+u}}{1-c}$, it has a distance of more than $v+u$ to the true left boundary. As we need to deal with $v+{u}_{1}$ possible patterns from S, with a probability of at most ${P}_{2,l}=(v+{u}_{1})\xb7\frac{{c}^{v+u}}{1-c}$, ${\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}<\mathrm{LB}({S}_{i}^{\u2033})-(v+u)$.

Similarly, with a probability of at most ${P}_{2,r}=(v+{u}_{1})\frac{{c}^{v+u}}{1-c}$, ${\mathrm{roughRight}}_{{S}_{i}^{\u2033}}>\mathrm{RB}({S}_{i}^{\u2033})+(v+u)$. Let ${P}_{2}={P}_{2,l}+{P}_{2,r}$.

With a probability of at most ${P}_{3,l}=\frac{{c}^{v}}{1-c}$, ${S}_{i}^{\u2033}$ does not contain a left half stable motif region by Lemma 20. Similarly, with a probability of at most ${P}_{3,r}=\frac{{c}^{v}}{1-c}$, ${S}_{i}^{\u2033}$ does not contain a right half stable motif region. Let ${P}_{3}={P}_{3,l}+{P}_{3,r}$.

Although, S is involved in searching the left boundary with all other sequences. The non-missing condition is to let each sequence not change too many characters in the motif region. Therefore, this is an independent event for each sequence. It is safe to use the Chernoff bound to deal with it.

With a probability of at most $P={e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, there are more than $({P}_{1}+{P}_{2}+{P}_{3}+\u03f5){k}_{2}$ sequences, ${S}_{i}^{\u2033}$, in $\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ with $\mathrm{roughLeft}({S}_{i}^{\u2033})\notin [\mathrm{LB}({S}_{i}^{\u2033})-(v+u),\mathrm{LB}({S}_{i}^{\u2033})]$ or $\mathrm{roughRight}({S}_{i}^{\u2033})\notin [\mathrm{RB}({S}_{i}^{\u2033}),\mathrm{RB}({S}_{i}^{\u2033})+(v+u)]$. ▮

#### 6.3. Analysis of Extract-Phase and Voting-Phase of Algorithm Recover-Motif

Lemma 27 shows that with a high probability, the left and last parts of the motif region in a $\Theta (n,G,\alpha )$-sequence do not change much.

**Lemma**

**27.**

With a probability of at most ${Q}_{0}$ defined in Equation (13), a $\Theta (n,G,\alpha )$-sequence, S, does not contain a stable motif region.

**Proof:**

The probability is ${V}_{1}=2(v-1)\alpha $ not to satisfy conditions (1) and (2) of item (iii) in Definition 25. Consider condition (3) of item (iii) in Definition 25. Since every character of $\aleph (S)[1,m]$ (notice that $m=|G|$) has a probability of at most α to mutate, by Corollary 18, the probability is at most ${e}^{-\frac{1}{3}{\u03f5}^{2}r}$ that $\mathrm{diff}(G[1,h],{G}^{\prime}[1,h])>\frac{\beta}{2}=\alpha +\u03f5$. Let ${V}_{3}={\sum}_{r=v}^{\infty}{e}^{-\frac{1}{3}{\u03f5}^{2}r}=\frac{{c}^{v}}{1-c}$, where $c={e}^{-\frac{1}{3}{\u03f5}^{2}}$, as defined in Definition 8. Therefore, the probability is at most ${V}_{3}$ that $\mathrm{diff}(G[1,h],{G}^{\prime}[1,h])>\frac{\beta}{2}=\alpha +\u03f5$ for some $h\in \{v,v+1,\cdots ,m\}$. Similarly, we define ${V}_{4}={\sum}_{r=v}^{\infty}{e}^{-\frac{1}{3}{\u03f5}^{2}r}\le \frac{{c}^{v}}{1-c}$ for the probability on the right-hand side. The probability is at most ${V}_{4}$ that $\mathrm{diff}(G[m-h,m],{G}^{\prime}[m-h,m])>\frac{\beta}{2}=\alpha +\u03f5$ for some $h\in \{v,v+1,\cdots ,m\}$. The probability that S does not contain a stable motif region is at most ${V}_{1}+{V}_{3}+{V}_{4}={Q}_{0}$. ▮

**Definition**

**28.**

Assume that ${Z}_{1}=\{{S}_{1}^{\prime},\cdots ,{S}_{2{k}_{1}}^{\prime}\}$ contains ${S}_{2i-1}^{\prime}$, which contains a stable motif region. We fix such a ${S}_{2i-1}^{\prime}$.

- Define ${G}_{L}=\aleph ({S}_{2i-1}^{\prime})[1,{d}_{0}logn-1]$ to be the left part of the motif region, $\aleph ({S}_{2i-1}^{\prime})$.
- Define ${G}_{R}=\aleph ({S}_{2i-1}^{\prime})[|G|-({d}_{0}logn)+1,|G|]$ to be the right part of the motif region, $\aleph ({S}_{2i-1}^{\prime})$.

Lemma 29 shows that with a high probability, Extract-Phase of algorithm Recover-Motif extracts the correct motif regions from the sequences in ${Z}_{1}$. It uses ${G}^{\u2033}$ to match $\aleph (S)$ in another sequences, S. The parameter, R, gives a small probability that the matched region between ${G}^{\u2033}$ and S is not in $\aleph (S)$.

**Lemma**

**29.**

- i.
- Assume that ${G}_{l}$ and ${G}_{r}$ are fixed sequences of length ${d}_{0}logn$. Let S be a $\Theta (n,G,\alpha )$-sequence with $M=\mathrm{Match}({G}_{l},{G}_{r},S)$, and let ${w}_{0}$ be the number of characters of M that are not in the region of $\aleph (S)$. Then, the probability is at most R that ${w}_{0}\ge 1$, where R is defined in (xv) of Definition 8.
- ii.
- The probability is at most ${Q}_{0}$ that given a $\Theta (n,G,\alpha )$-sequence S, $\mathrm{Match}({G}_{L},{G}_{R},S)=\varnothing $.

**Proof:**

Assume that ${w}_{0}\ge 1$. Let w be the number of characters outside of $\aleph (S)$ on the left of M, and let ${w}^{\prime}$ be the number of characters outside of $\aleph (S)$ on the right of M. Clearly, ${w}_{0}=w+{w}^{\prime}$. Since ${w}_{0}\ge 1$, either $w\ge 1$ or ${w}^{\prime}\ge 1$. See Figure 1. Without loss of generality, we assume $w\ge 1$.

Statement i: There are two cases.

Case (a): $1\le w<v$. By Lemma 19, the probability for this case is at most $\frac{1}{t}$ for a fixed w. The total probability for this case for $1\le w<v$ is at most ${\sum}_{i=1}^{v-1}\frac{1}{{t}^{i}}\le {\sum}_{i=1}^{\infty}\frac{1}{{t}^{i}}=\frac{1}{t-1}$.

Case (b): $v\le w$. By Lemma 19, the probability is at most ${e}^{-\frac{{\u03f5}^{2}}{3}w}$ for a fixed w. The total probability for $v\le w$ is at most ${\sum}_{w=v}^{\infty}{e}^{-\frac{{\u03f5}^{2}}{3}w}=\frac{{c}^{v}}{1-c}$.

The probability analysis is similar when ${w}^{\prime}\ge 1$. Therefore, the probability for this case is at most $R=(\frac{1}{t-1}+\frac{{c}^{v}}{1-c})$ for ${w}_{0}\ge 1$.

Statement ii: By Lemma 27, with a probability of at most ${Q}_{0}$, S does not contain a stable motif region. Therefore, we have a probability of at most ${Q}_{0}$ that given a random $\Theta (n,G,\alpha )$-sequence, S, $\mathrm{Match}({G}_{L},{G}_{R},S)=\varnothing $. ▮

Lemma 30 shows that we can use ${G}_{l}$ and ${G}_{r}$ to extract most of the motif regions for the sequences in ${Z}_{2}$ if ${G}^{\prime}={G}_{L}$ (recall that ${G}_{L}$ is defined right after Lemma 27).

**Lemma**

**30.**

Assume that ${G}_{l}$ and ${G}_{r}$ are two sequences of a length of ${d}_{0}logn$, and ${G}_{i}=\mathrm{Match}({G}_{l},{G}_{r},{S}_{i}^{\u2033})$ for ${S}_{i}^{\u2033}\in {Z}_{2}=\{{S}_{1}^{\u2033},\cdots ,{S}_{{k}_{2}}^{\u2033}\}$ and $i=1,\cdots ,{k}_{2}$ (recall that each sequence, ${G}_{i}$, is either an empty sequence or a sequence of the length of $|{G}_{l}|$).

- i.
- If ${G}_{l}={G}_{L}$, ${G}_{r}={G}_{R}$ and there are no more than $y{k}_{2}$ ($y\in [0,1]$) sequences, ${S}_{i}^{\u2033}$, with ${\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}\notin [\mathrm{LB}({S}_{i}^{\u2033})-(v+{u}_{2}),\mathrm{LB}({S}_{i}^{\u2033})]$ or ${\mathrm{roughRight}}_{{S}_{i}^{\u2033}}\notin [\mathrm{RB}({S}_{i}^{\u2033}),\mathrm{RB}({S}_{i}^{\u2033})+(v+{u}_{2})]$, then the probability is at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$ that there are more than $({Q}_{0}+y+\u03f5){k}_{2}$ sequences, ${G}_{i}$, with ${G}_{i}=\varnothing $.
- ii.
- For arbitrary ${G}_{l}$ and ${G}_{r}$, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, $|\{i|{G}_{i}\ne \varnothing \phantom{\rule{4pt}{0ex}}\mathrm{and}\phantom{\rule{4pt}{0ex}}{G}_{i}\ne \aleph ({S}_{i}^{\u2033}),i=1,\cdots ,{k}_{2}\}|>(R+\u03f5){k}_{2}$, where R is defined in Definition 8.

**Proof:**

Recall that sequence ${G}_{1L}$ is selected right after Lemma 27.

Statement i: By Lemma 29, for every ${S}_{i}^{\u2033}\in {Z}_{2}$, the probability is at most ${Q}_{0}$ that ${S}_{i}^{\u2033}$ does not contain a stable motif region, $\aleph ({S}_{i}^{\u2033})$. By Corollary 18, we have a probability of at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$ that there are more than $({Q}_{0}+y+\u03f5){k}_{2}$ sequences, ${G}_{i}$, with ${G}_{i}=\varnothing $.

Statement ii: By Lemma 29, the probability is at most R that ${G}_{i}\ne \aleph ({S}_{i}^{\u2033})$. By Corollary 18, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, $|\{i|{G}_{i}\ne \aleph ({S}_{i}^{\u2033}),i=1,\cdots ,{k}_{2}\}|>(R+\u03f5){k}_{2}$. ▮

**Definition**

**31.**

- Given two sequences, ${G}_{r}$ and ${G}_{r}$, define:$M({G}_{r},{G}_{r})=\{{G}_{i}^{\u2033}:{G}_{i}^{\u2033}=$Match$({G}_{l},{G}_{r},{\mathrm{roughLeft}}_{{S}_{i}^{\u2033}},{\mathrm{roughRight}}_{{S}_{i}^{\u2033}},{S}_{i}^{\u2033})$$i=1,\cdots ,{k}_{2}\}$.
- For a $\Theta (n,G,\alpha )$ sequence, S, define ${G}_{S,L}$ to be the $\aleph (S)[1,{d}_{0}logn]$, which is the leftmost subsequence of a length of ${d}_{0}logn$ in the motif region of S.
- For a $\Theta (n,G,\alpha )$ sequence, S, define ${G}_{S,R}$ to be the $\aleph (S)[m-{d}_{0}logn+1,m]$, which is the rightmost subsequence of a length of ${d}_{0}logn$ in the motif region of S, where $m=|G|=|\aleph (S)|$;

**Lemma**

**32.**

Assume that we have the following conditions:

- i.
- For each L with $0<L\le \frac{|G|}{2}$, with a probability of at most ${\varsigma}_{1}(n)$, ${L}_{{S}_{i}}\notin [{\mathrm{LB}}_{{S}_{i}}-2L,{\mathrm{LB}}_{{S}_{i}}+2L]$ or ${R}_{{S}_{i}}\notin [{\mathrm{RB}}_{{S}_{i}}-2L,{\mathrm{RB}}_{{S}_{i}}+2L]$ for $i=1,2$, where $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2})$, ${U}_{1}=$Point-Selection$({S}_{1},L,[1,|{S}_{1}|])$ and ${U}_{2}=$Point-Selection$({S}_{2},L,[1,|{S}_{2}|])$.
- ii.
- For each L with $0<L\le \frac{|G|}{2}$, if ${S}_{1}$ has ${\mathrm{roughLeft}}_{{S}_{1}}\in [{\mathrm{LB}}_{{S}_{1}}-L,{\mathrm{LB}}_{{S}_{1}}+L]$ and ${\mathrm{roughRight}}_{{S}_{1}}\in [{\mathrm{RB}}_{{S}_{1}}-L,{\mathrm{RB}}_{{S}_{1}}+L]$, then with a probability of at most ${\varsigma}_{2}(n)$, ${L}_{{S}_{i}^{\u2033}}\notin [{\mathrm{LB}}_{{S}_{i}^{\u2033}}-2L,{\mathrm{LB}}_{{S}_{i}^{\u2033}}+2L]$ for $i=1$ or $i=2$, where $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{i}^{\u2033}},{R}_{{S}_{i}^{\u2033}})=$ Collision-Detection(${S}_{1},{U}_{1},{S}_{i}^{\u2033},{U}_{2})$, ${U}_{1}=$ Point-Selection$({S}_{1},L,[{\mathrm{roughLeft}}_{{S}_{1}}-2L,{\mathrm{roughLeft}}_{{S}_{1}}+2L])\cup $ Point-Selection$({S}_{1},L,[{\mathrm{roughRight}}_{{S}_{1}}-2L,{\mathrm{roughRight}}_{{S}_{1}}+2L])$ and ${U}_{2}=$ Point-Selection $({S}_{i}^{\u2033},L,[1,|{S}_{i}^{\u2033}|])$.
- iii.
- The inequality $({P}_{0}+{Q}_{0})<{c}_{0}$ holds for some constant ${c}_{0}<1$, where ${Q}_{0}$ is defined in Equation (13) and ${P}_{0}={\varsigma}_{1}(n)+\frac{2(v+{u}_{1}){c}^{v+{u}_{1}}}{{(1-c)}^{2}}+\frac{{c}^{v}}{1-c}+\frac{1}{5\xb7{2}^{x}n}$.
- iv.
- The inequality $1-2({Q}_{0}+{V}_{0}+(R+2\u03f5))-(\alpha +\u03f5)>0$ holds, where ${V}_{0}=(2({\varsigma}_{2}(n)+(v+{u}_{1})\frac{{c}^{v+{u}_{2}}}{1-c}+\frac{{c}^{v}}{1-c})+\u03f5)$.

Then, the algorithm generates a set of at most ${k}_{2}$ subsequences for voting and votes for a sequence, ${G}^{\prime}$, such that:

(1) with a probability of at most ${e}^{-\Omega ({k}_{1})}+{e}^{-\Omega ({k}_{2})}$, $|{G}^{\prime}|\ne |G|$; and

(2) for each $1\le i\le |G|$, with a probability of at most ${e}^{-\Omega ({k}_{1})}+{e}^{-\Omega ({k}_{2})}$, ${G}^{\prime}[i]\ne G[i]$.

Before proving Lemma 32, we note that both ${\varsigma}_{1}(n)$ and ${\varsigma}_{2}(n)$ are at most $\frac{1}{{2}^{x}{n}^{3}}$ for all of the three algorithms. They will be proven by Lemma 47 and Lemma 46 for the case algorithm-type=RANDOMIZED-SUBLINEAR, Lemma 41 and Lemma 40 for the case algorithm-type=RANDOMIZED-SUBQUADRATIC, and Lemma 35 for the case algorithm-type=DETERMINISTIC-SUPERQUADRATIC.

**Proof:**

By Lemmas 22, with a probability of at most ${P}_{0}={\varsigma}_{1}(n)+\frac{2(v+{u}_{1}){c}^{v+{u}_{1}}}{{(1-c)}^{2}}+\frac{{c}^{v}}{1-c}+\frac{1}{5\xb7{2}^{x}n}$, ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{LB}({S}_{2i-1}^{\prime})-(v+{u}_{1}),\mathrm{LB}({S}_{2i-1}^{\prime})]$ or ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\notin [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+(v+{u}_{1})]$.

By Lemma 23, with a probability of at most ${P}_{a}={e}^{-{(0.5-{P}_{0}-\u03f5)}^{2}{k}_{1}/3}={e}^{-\Omega ({k}_{1})}$, the approximate motif length, ${l}_{motif}$, is not in the range $[|G|-2(v+{u}_{1}),|G|+2(v+{u}_{1})]$. Assume ${l}_{motif}\in [|G|-2(v+{u}_{1}),|G|+2(v+{u}_{1})]$ in the rest of the proof of this lemma.

By Lemma 27, with a probability of at most ${Q}_{0}$, a $\Theta (n,G,\alpha )$ sequence does not contain a stable motif region. Therefore, with a probability of at most ${P}_{1}={({P}_{0}+{Q}_{0})}^{{k}_{1}}$, the following statement is false:

(i) One of ${S}_{2i-1}^{\prime}$ for $i=1,\cdots ,{k}_{1}$ has ${\mathrm{roughLeft}}_{{S}_{2i-1}^{\prime}}\in [\mathrm{LB}({S}_{2i-1}^{\prime})-(v+{u}_{1}),\mathrm{LB}({S}_{2i-1}^{\prime})]$, ${\mathrm{roughRight}}_{{S}_{2i-1}^{\prime}}\in [\mathrm{RB}({S}_{2i-1}^{\prime}),\mathrm{RB}({S}_{2i-1}^{\prime})+(v+{u}_{1})]$ and has a stable motif region.

By Lemma 26, with a probability of at most ${P}_{2}={e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, there are more than $(2({\varsigma}_{2}(n)+(v+{u}_{1})\frac{{c}^{v+{u}_{2}}}{1-c}+\frac{{c}^{v}}{1-c})+\u03f5){k}_{2}$ sequences ${S}_{i}^{\u2033}$ with ${\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}\notin [\mathrm{LB}({S}_{i}^{\u2033})-(v+{u}_{2}),\mathrm{LB}({S}_{i}^{\u2033})]$ or ${\mathrm{roughRight}}_{{S}_{i}^{\u2033}}\notin [\mathrm{RB}({S}_{i}^{\u2033}),\mathrm{LB}({S}_{i}^{\u2033})+(v+{u}_{2})]$. In other words, with a probability of at most ${P}_{2}$, the following statement is false:

(ii) There are no more than ${V}_{0}{k}_{2}$ sequences ${S}_{i}^{\u2033}$ with ${\mathrm{roughLeft}}_{{S}_{i}^{\u2033}}\notin [\mathrm{LB}({S}_{i}^{\u2033})-(v+{u}_{2}),\mathrm{LB}({S}_{i}^{\u2033})]$ or ${\mathrm{roughRight}}_{{S}_{i}^{\u2033}}\notin [\mathrm{RB}({S}_{i}^{\u2033}),\mathrm{RB}({S}_{i}^{\u2033})+(v+{u}_{2})]$, where ${V}_{0}=(2({\varsigma}_{2}(n)+(v+{u}_{1})\frac{{c}^{v+{u}_{2}}}{1-c}+\frac{{c}^{v}}{1-c})+\u03f5)$.

Assume that Statement (ii) is true. By Lemma 30, with a probability of at most ${P}_{3}={c}^{{k}_{2}}$, the following statement is false:

(iii) $M({G}_{L},{G}_{R})$ contains at most $({Q}_{0}+{V}_{0}+\u03f5){k}_{2}$ empty sequences.

We start from the rough left boundary, ${\mathrm{roughLeft}}_{1}$, of ${S}_{1}$ to match the other left boundaries of ${S}_{i}^{\u2033}$ for $i=1,\cdots ,{k}_{2}$. There are in total at most $2(v+{u}_{1})$ candidates to consider.

By Lemma 30, if $M({G}_{l},{G}_{r})$, which consists of ${k}_{2}$ matched regions, has at most $({Q}_{0}+{V}_{0}+\u03f5){k}_{2}$ empty sequences, then it has more than $(R+\u03f5){k}_{2}$ from non-motif regions with a probability of at most${P}_{4}=2(v+{u}_{1}){e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$. After the pattern is fixed, those events in the matching are considered to be independent of each other. This is why we can apply the Chernoff bound to deal with them. Therefore, the probability is at most ${P}_{4}$; the following statement is false:

(iv) If $M({G}_{l},{G}_{r})$ contains at most $({Q}_{0}+{V}_{0}+\u03f5){k}_{2}$ empty sequences, then $M({G}_{l},{G}_{r})$ contains at most $({Q}_{0}+{V}_{0}+\u03f5+(R+\u03f5)){k}_{2}=({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements not from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$.

Therefore, with a probability of at most ${P}_{a}+{P}_{1}+{P}_{2}+{P}_{3}+{P}_{4}={e}^{-\Omega ({k}_{1})}+{e}^{-\Omega ({k}_{2})}$, the sequences are not ready for voting in the next phase, which means the following two conditions are satisfied:

(a) There exists ${G}_{l}$ and ${G}_{r}$ generated by the algorithm, such that $M({G}_{l},{G}_{r})$ contains at most $({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements not from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$.

(b) For every ${G}_{l}$ and ${G}_{r}$ that $M({G}_{l},{G}_{r})$ contains at most $({Q}_{0}+{V}_{0}+\u03f5){k}_{2}$ empty sequences generated by the algorithm, $M({G}_{l},{G}_{r})$ contains at most $({Q}_{0}+{V}_{0}+\u03f5+(R+\u03f5)){k}_{2}=({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements not from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$.

Statement (1): For a $M({G}_{l},{G}_{r})$ with at most $({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements not from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$, we still have ${k}_{2}-({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements in $M({G}_{l},{G}_{r})$ from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$. By the condition (iv) in this lemma, we have ${k}_{2}-({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}>({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$. Therefore, $|{G}^{\prime}|$ is selected to be the length of G in the Voting-Phase().

Statement (2): For a $M({G}_{l},{G}_{r})=\{{G}_{1}^{\u2033},\cdots ,{G}_{{k}_{2}}^{\u2033}\}$ with at most $({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements not from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$, we still have ${k}_{2}-({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ elements in $M({G}_{l},{G}_{r})$ from motif regions $\{\aleph ({S}_{i}^{\u2033}):1\le i\le {k}_{2}\}$. By Corollary 18, with a probability of at most ${e}^{-\frac{{\u03f5}^{2}{k}_{2}}{3}}$, there are more than $(\alpha +\u03f5){k}_{2}$ characters that are mutated in the same position among all ${k}_{2}$ motif regions for the sequences in ${Z}_{2}$. We have that ${k}_{2}-({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}-(\alpha +\u03f5){k}_{2}>({Q}_{0}+{V}_{0}+(R+2\u03f5)){k}_{2}$ by the condition (iv) in this lemma. We let ${G}^{\prime}[j]$ be the most frequent character among ${G}_{1}^{\u2033}[j],\cdots ,{G}_{{k}_{2}}^{\u2033}[j]$ in Voting-Phase. Therefore, with a probability of at most ${e}^{-\Omega ({k}_{1})}+{e}^{-\Omega ({k}_{2})}$, ${G}^{\prime}[j]\ne G[j]$. ▮

We will use multiple variable functions to characterize the computational time for three algorithms. In order to unify the complexity analysis of three algorithms, we introduce the following notation.

**Definition**

**33.**

A function, $T(x,y):N\times N\to N$, is nondecreasing if it is nondecreasing on both variables. If for arbitrary positive constants, ${c}_{1}$ and ${c}_{2}$, $T({c}_{1}x,{c}_{2}y)\le cT(x,y)$ for some positive constant, c, then $T(x,y)$ is slow.

**Lemma**

**34.**

Assume that $t(x,y)$, $s(n,L)$ and $g(n,l)$ are non-decreasing slow functions.Assume that Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2}$) returns the result in $t(n,||{U}_{1}||+||{U}_{2}||)$ time and the Point-Selection(${S}_{1},{S}_{2},L)$) selects $s(n,L)$ positions in $g(n,L)$ time. Assume that with a probability of at most $\phi (n)$, the function Initial-Boundaries() does not stop when $L\le |G|/4$, and $||{U}_{{S}_{2i-1}^{\prime}}||+||{U}_{{S}_{j}^{\u2033}}||$ in the algorithm Recover-Motif is no more than $f(n,|G|)$.

Then, with a probability of at most ${k}_{1}\phi (n)$, the entire algorithm Recover-Motif does not stop in the time complexity $(O({k}_{1}({\sum}_{i=1}^{{i}_{0}}(t(n,s(n,\frac{n}{{2}^{i}{n}^{2/5}}))+g(n,\frac{n}{{2}^{{i}_{0}}{n}^{2/5}})))+{k}_{1}{h}^{2}logn+{k}_{1}{k}_{2}t(n,f(n,|G|))+{h}^{2}logn)+{k}_{1}{k}_{2}(logn)(loglogn)),O({k}_{2}))$, where ${i}_{0}$ is the largest j, such that $\frac{n}{{2}^{j}{n}^{2/5}}\le min({n}^{2/5},|G|)$ and $h=min({n}^{2/5},|G|)$.

**Proof:**

The function Initial-Boundaries()is executed ${k}_{1}$ times. According to the condition that with a probability of at most $\phi (n)$, the function Initial-Boundaries(.) does not stop when $L\le |G|/4$, we have the fact that with a probability of at most ${k}_{1}\phi (n)$, one of those executions of Initial-Boundaries(.) does not stop when $L\le |G|/4$.

In the rest of the proof, we assume that all executions of Initial-Boundaries(.) stops when $L\le |G|/4$.

When $L=O(h)$, we detect rough left and right motif boundaries and run Improve-Boundaries(), which takes $O({h}^{2}logn)$ time by Lemma 21. It takes $O({\sum}_{i=1}^{{i}_{0}}(t(n,s(n,\frac{n}{{2}^{i}{n}^{2/5}}))+g(n,\frac{n}{{2}^{i}{n}^{2/5}})+{h}^{2}logn)$ time to run Initial-Boundaries(${S}_{2i-1}^{\prime},{S}_{2i}^{\prime}$) one time for one pair (${S}_{2i-1}^{\prime},{S}_{2i}^{\prime}$) in ${Z}_{1}$. It takes $O({k}_{1}({\sum}_{i=1}^{{i}_{0}}(t(n,s(n,\frac{n}{{2}^{i}{n}^{2/5}}))+g(n,\frac{n}{{2}^{i}{n}^{2/5}})+{k}_{1}{h}^{2}logn)$ time to run Initial-Boundaries(${S}_{2i-1}^{\prime},{S}_{2i}^{\prime}$) one time for all pairs (${S}_{2i-1}^{\prime},{S}_{2i}^{\prime}$) in ${Z}_{1}$.

It takes ${k}_{2}(t(n,f(n,|G|))+{h}^{2}logn)$ time to find the rough boundaries for all sequences in ${Z}_{2}$ with a fixed sequence, S, from ${Z}_{1}$ by executing for the loop “For each ${S}_{j}^{\u2033}\in {Z}_{2}$” in the algorithm Recover-Motif. It takes ${k}_{1}{k}_{2}(t(n,f(n,|G|))+{h}^{2}logn)$ time to find the rough boundaries for all sequences in ${Z}_{2}$ via all sequences, ${S}_{2i-1}^{\prime}$, from ${Z}_{1}$ through the loop “For each ${S}_{j}^{\u2033}\in {Z}_{2}$” in the algorithm Recover-Motif.

Recall that parameters v and ${u}_{1}$ are constants, and ${u}_{2}$ is $O(loglogn)$. Calling Match(${G}_{l},{G}_{r},{S}_{i}^{\u2033}$) takes $O((v+{u}_{2})logn)$ time for each ${S}_{i}^{\u2033}\in {Z}_{2}$. The total times for calling Match(${G}_{l},{G}_{r},{S}_{i}^{\u2033}$) is $O({k}_{1}{k}_{2}(v+{u}_{1})(v+{u}_{2})logn)=O({k}_{1}{k}_{2}(logn)(loglogn))$.

The voting part takes $O({k}_{2})$ time for executing voting for recovering one character in the motif. ▮

#### 6.4. Deterministic Algorithm for an $\Omega (1)$ Mutation Rate

In this section, we give a deterministic algorithm for the case with an $\Omega (1)$ mutation rate. The performance of the algorithm is stated in Theorem 6.

**Lemma**

**35.**

Let algorithm-type=DETERMINISTIC-SUPERQUADRATIC. Assume that ${d}_{0}logn\le L\le |G|/2$ and ${c}_{0}logn\le |G|$. Let ${I}_{1}$ be a set of intervals of the positions of ${S}_{1}$ that satisfies $[\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]\cup [\mathrm{RB}({S}_{1})-L,\mathrm{RB}({S}_{1})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{1}}{I}^{\prime}$. Let ${I}_{2}$ be a set of intervals of the positions of ${S}_{2}$ that satisfies $[\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]\cup [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{2}}{I}^{\prime}$. Let ${U}_{1}=$ Point-Selection$({S}_{1},L,{I}_{1})$, ${U}_{2}=$ Point-Selection$({S}_{2},L,{I}_{2})$ and $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$ Collision-Detection$({S}_{1},{U}_{1},{S}_{2},,{U}_{2})$. Then:

- i.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the left rough boundary, ${L}_{{S}_{1}}$, has at most ${d}_{0}logn$ distance from $\mathrm{LB}({S}_{1})$ and the left rough boundary ${L}_{{S}_{2}}$ has at most ${d}_{0}logn$ distance from $\mathrm{LB}({S}_{2})$.
- ii.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the right rough boundary, ${R}_{{S}_{1}}$, has at most ${d}_{0}logn$ distance from $\mathrm{RB}({S}_{1})$ and the right boundary of ${R}_{{S}_{2}}$ has at most ${d}_{0}logn$ distance from $\mathrm{RB}({S}_{2})$.

**Proof:**

For two sequences, ${S}_{1}$ and ${S}_{2}$, let $\aleph ({S}_{a})$ be the subsequence, ${S}_{a}[{i}_{a},{j}_{a}]$, for $a=1,2$. By Corollary 18, with a probability of at most ${P}_{l}=2{c}^{{d}_{0}logn}\le \frac{2}{5\xb7{2}^{x}{n}^{3}}$ (see inequality (8) in Definition 14), there are more than $(\alpha +\u03f5){d}_{0}logn$ mutations in ${S}_{a}[{i}_{a},{i}_{a}+{d}_{0}logn-1]$ for $a=1,2$.

With a probability of at most ${P}_{l}$, the left boundary position is missed during the matching. We have similar ${P}_{r}={P}_{l}$ to miss the right boundary.

Assume that ${p}_{1}$ and ${p}_{2}$ are two positions of ${S}_{1}$ and ${S}_{2}$, respectively. If one of two positions is outside the motif region and has more than ${d}_{0}logn$ distance to the motif boundary, with a probability of at most ${c}^{-{d}_{0}logn}\le \frac{1}{5\xb7{2}^{x}{n}^{3}}$ (see inequality (8) in Definition 14), for them to match requires $\mathrm{diff}({Y}_{1},{Y}_{2})\le \beta $ by Lemma 19, where ${Y}_{a}$ is a subsequence ${S}_{a}[{p}_{a},{p}_{a}+{d}_{0}logn-1]$ for $a=1,2$. ▮

**Lemma**

**36.**

For the case algorithm-type=DETERMINISTIC-SUPERQUADRATIC, we have:

- i.
- Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2}$) takes $t(n,||{U}_{1}||+||{U}_{2}||)=O((||{U}_{1}||+||{U}_{2}{||)}^{2}logn)$ time.
- ii.
- Point-Selection(${S}_{1},L,[1,|{S}_{1}|]$) selects $s(n,L)=O(n)$ positions in $g(n,L)=O(n)$ time.
- iii.
- $||{U}_{{S}_{2i-1}^{\prime}}||+||{U}_{{S}_{j}^{\u2033}}||$ in the algorithm Recover-Motif is no more than $f(n,|G|)=O(|G|+n)$.
- iv.
- With a probability of at most $\frac{k}{{2}^{x}{n}^{3}}$, the algorithm Recover-Motif does not run in computational complexity $(O(k({n}^{2}{(logn)}^{O(1)}+{h}^{2}logn)),O(k))$.

**Proof:**

Statement i. The parameter, ${\omega}_{\mathrm{DETERMINISTIC}-\mathrm{SUPERQUADRATIC}}$, is set to be β in Collision-Detection. It follows from the time complexity of the brute force method.

Statement ii. It follows from the implementation of Point-Selection().

Statement iii. It follows from the choice of Point-Selection(.) for the sublinear time algorithm at Recover-Motif(.).

Statement iv. It follows from Lemma 34 and Statements i, ii and iii. ▮

We give the proof for Theorem 6.

**Proof:**

[Theorem 6] The computational time part of this theorem follows from Lemma 36.

By Lemma 35, we let ${\varsigma}_{1}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{1}(n)$, in the condition (i) of Lemma 32.

By Lemma 35, we can let ${\varsigma}_{2}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{2}(n)$, in the condition (i) of Lemma 32

By inequality (12), the condition (iii) of Lemma 32 is satisfied.

By inequality (11), we know that the condition (iv) of Lemma 32 can be satisfied.

The failure probability part of this theorem follows from Lemma 21 and Lemma 32 by using the fact that ${k}_{1},{k}_{2}$ and k are of the same order (see equation (18)). ▮

#### 6.5. Randomized Algorithms for Motif Detection

In this section, we present two randomized algorithms for motif detection. The first one is a sublinear time algorithm that can handle $\frac{1}{{(logn)}^{2+\mu}}$ mutation, and the second one is a super-linear time algorithm that can handle $\Omega (1)$ mutation. They also share some common functions.

**Lemma**

**37.**

Let ${c}_{1}$ be a constant in $(0,1)$. Assume m and n are two non-negative integers with $m\le n$. Then, for every integer, ${m}_{1}$, with $0\le {m}_{1}\le \frac{{\delta}_{{c}_{1}}m}{lnn}$, $\left(\genfrac{}{}{0pt}{}{n}{{m}_{1}}\right){c}_{1}^{m}\le {e}^{(mln{c}_{1})/2}$, where constant ${\delta}_{{c}_{1}}=\frac{-ln{c}_{1}}{2}$ as defined in Definition 8.

**Proof:**

We have the inequalities:
▮

$$\begin{array}{ccc}\hfill \left(\genfrac{}{}{0pt}{}{n}{{m}_{1}}\right){c}_{1}^{m}& \le & {n}^{{m}_{1}}{c}_{1}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& =& {e}^{{m}_{1}lnn}{c}_{1}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {e}^{\frac{{\delta}_{{c}_{1}}m}{lnn}lnn}{c}_{1}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& =& {e}^{{\delta}_{{c}_{1}}m}{e}^{mln{c}_{1}}\hfill \end{array}$$

$$\begin{array}{ccc}& =& {e}^{(mln{c}_{1})/2}\hfill \end{array}$$

**Lemma**

**38.**

Let $S=U\cup V$ be a set of n elements with $U\cap V=\varnothing $. Assume that ${x}_{1},\cdots ,{x}_{m}$ are m random elements in S. Then, with a probability of at most $\left(\genfrac{}{}{0pt}{}{||U||}{{m}_{1}}\right){(\frac{||V||+{m}_{1}}{n})}^{m}$, the list, ${x}_{1},\cdots ,{x}_{m}$, contains at most ${m}_{1}$ different elements from U (in other words, $||\{\phantom{\rule{4pt}{0ex}}{x}_{1},\cdots ,{x}_{m}\}\cap U||\le {m}_{1}$).

**Proof:**

For a subset, ${S}^{\prime}\subseteq S$, with $||{S}^{\prime}||={m}_{0}$ for some integer, ${m}_{0}\ge 0$, the probability is at most ${(\frac{{m}_{0}}{n})}^{m}$ that all elements, ${x}_{1},\cdots ,{x}_{m}$, are in ${S}^{\prime}$. For every subset, $X\subseteq S$, with $||X||\le {m}_{1}$, there exists another subset, ${S}^{\prime}\subseteq S$, such that $||{S}^{\prime}||={m}_{1}$ and $X\subseteq {S}^{\prime}$. We have that $\mathrm{Pr}[||\{\phantom{\rule{4pt}{0ex}}{x}_{1},\cdots ,{x}_{m}\}\cap U||\le {m}_{1}]\le \mathrm{Pr}[\{{x}_{1},\cdots ,{x}_{m}\}\cap U\subseteq {U}^{\prime}\phantom{\rule{4pt}{0ex}}\mathrm{for}\phantom{\rule{4pt}{0ex}}\mathrm{some}\phantom{\rule{4pt}{0ex}}{U}^{\prime}\subseteq U\phantom{\rule{4pt}{0ex}}\mathrm{with}\phantom{\rule{4pt}{0ex}}||{U}^{\prime}||={m}_{1}]$. There are $\left(\genfrac{}{}{0pt}{}{||U||}{{m}_{1}}\right)$ subsets of U with a size of ${m}_{1}$. We have the probability of at most $\left(\genfrac{}{}{0pt}{}{||U||}{{m}_{1}}\right){(\frac{||V||+{m}_{1}}{n})}^{m}$ that ${x}_{1},\cdots ,{x}_{m}$ contains at most ${m}_{1}$ different elements in U. ▮

**Lemma**

**39.**

Let β be a constant in $(0,1)$ and ${c}_{1}=1-\frac{\beta}{2}$. Let ${m}_{1}\le \frac{{\delta}_{{c}_{1}}m}{ln\beta n}$ and $m\le {n}^{1-\u03f5}$ for some fixed $\u03f5>0$. Let ${S}_{1}$ and ${S}_{2}$ be two sets of n elements with $||{S}_{1}\cap {S}_{2}||\ge \beta n$ and C be a set of the size $||C||\le \gamma {m}_{1}$ for some constant $\gamma \in (0,1)$. Then, for all large n, with a probability of at most $2{e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}$, we have $(A-C)\cap (B-C)=\varnothing $, where $A=\{{x}_{1},\cdots ,{x}_{m}\}$ and $B=\{{y}_{1},\cdots ,{y}_{m}\}$ are two sets, which may have multiplicities, of m random elements from ${S}_{1}$ and ${S}_{2}$, respectively.

**Proof:**

In the entire proof of this lemma, we always assume that n is sufficiently large. We are going to give an upper bound about the probability that B does not contain any element in $A--C$. For each element, ${y}_{i}\in B$, with a probability of at most $1-\frac{||A||-||C||}{n}$, ${y}_{i}$ is not in $A--C$. Therefore, the probability is at most ${(1-\frac{||A||-||C||}{n})}^{m}$ that B does not contain any element in $A--C$.

By Lemma 38, the probability is at most $\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(\frac{(1-\beta )n+{m}_{1}}{n})}^{m}$ that $||A\cap ({S}_{1}\cap {S}_{2})||\le {m}_{1}$. We have the inequalities:
The inequality, ${(1-\frac{(1-\gamma ){m}_{1}}{n})}^{m}\le {e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}$, which is used from Equation (34) to Equation (35), follows from the fact that $1-x\le {e}^{-x}$. The transition from (35) to (36) follows from the fact that $\frac{{m}_{1}}{n}\le \frac{\beta}{2}$, since ${m}_{1}=o(n)$, according to the conditions of the lemma.

$$\begin{array}{ccc}& & \mathrm{Pr}[(A-C)\cap (B-C)=\varnothing ]\hfill \end{array}$$

$$\begin{array}{ccc}& =& \mathrm{Pr}[(A-C)\cap (B-C)=\varnothing |\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}||A\cap ({S}_{1}\cap {S}_{2})||\ge {m}_{1}]\xb7\mathrm{Pr}[||A\cap ({S}_{1}\cap {S}_{2})||\ge {m}_{1}]+\hfill \end{array}$$

$$\begin{array}{ccc}& & \mathrm{Pr}[(A-C)\cap (B-C)=\varnothing |\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}||A\cap ({S}_{1}\cap {S}_{2})||<{m}_{1}]\xb7\mathrm{Pr}[|A\cap ({S}_{1}\cap {S}_{2})|<{m}_{1}]\hfill \end{array}$$

$$\begin{array}{ccc}& \le & \mathrm{Pr}[(A-C)\cap (B-C)=\varnothing |\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}||A\cap ({S}_{1}\cap {S}_{2})||\ge {m}_{1}]+\mathrm{Pr}[||A\cap ({S}_{1}\cap {S}_{2})||<{m}_{1}]\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {(1-\frac{||A||-||C||}{n})}^{m}+\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(\frac{(1-\beta )n+{m}_{1}}{n})}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {(1-\frac{||(A\cap {S}_{1}\cap {S}_{2})||-||C||}{n})}^{m}+\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(\frac{(1-\beta )n+{m}_{1}}{n})}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {(1-\frac{(1-\gamma ){m}_{1}}{n})}^{m}+\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(\frac{(1-\beta )n+{m}_{1}}{n})}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}+\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(\frac{(1-\beta )n+{m}_{1}}{n})}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}+\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(1-\frac{\beta}{2})}^{m}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & {e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}+{e}^{(mln{c}_{1})/2}\hfill \end{array}$$

$$\begin{array}{ccc}& \le & 2{e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}\hfill \end{array}$$

It is easy to see that $\frac{2(1-\gamma ){m}_{1}m}{-mln{c}_{1}}=\frac{2(1-\gamma ){m}_{1}}{-ln{c}_{1}}\le n$ for all large n. Thus, $\frac{(1-\gamma ){m}_{1}m}{n}\ge (mln{c}_{1})/2$ (note that $ln{c}_{1}<0$ as ${c}_{1}\in (0,1)$). Thus, by Lemma 37, $\left(\genfrac{}{}{0pt}{}{\beta n}{{m}_{1}}\right){(1-\frac{\beta}{2})}^{m}\le {e}^{mln{c}_{1}/2}\le {e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}$. This is why we have the transition from Equation (37) to Equation (38). Therefore, $\mathrm{Pr}[(A-C)\cap (B-C)=\varnothing ]\le 2{e}^{-\frac{(1-\gamma ){m}_{1}m}{n}}$. ▮

#### 6.5.1.. Randomized Algorithm for an $\Omega (1)$ Mutation Rate

In this section, we give an algorithm for the case with an $\Omega (1)$ mutation rate. The performance of the algorithm is stated in Theorem 4.

**Lemma**

**40.**

Let algorithm-type=RANDOMIZED-SUBQUADRATIC. Assume that ${d}_{0}logn\le L\le |G|/2$ and ${c}_{0}logn\le |G|<\frac{{(logn)}^{3+\tau}}{100}$. Let ${I}_{1}$ be a set of intervals of the positions of ${S}_{1}$ that satisfy $[\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]\cup [\mathrm{RB}({S}_{1})-L,\mathrm{RB}({S}_{1})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{1}}{I}^{\prime}$. Let ${I}_{2}$ be a set of intervals of the positions of ${S}_{2}$ that satisfy $[\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]\cup [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{2}}{I}^{\prime}$. Let ${U}_{1}=$ Point-Selection$({S}_{1},L,{I}_{1})$, ${U}_{2}=$ Point-Selection$({S}_{2},L,{I}_{2})$ and $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$ Collision-Detection$({S}_{1},{U}_{1},{S}_{2},,{U}_{2})$. Then:

- i.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the left rough boundary, ${L}_{{S}_{1}}$, has at most ${d}_{0}logn$ distance from $\mathrm{LB}({S}_{1})$ and the left rough boundary, ${L}_{{S}_{2}}$, has at most ${d}_{0}logn$ distance from $\mathrm{LB}({S}_{2})$;
- ii.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the right rough boundary, ${R}_{{S}_{1}}$, has at most ${d}_{0}logn$ distance from $\mathrm{RB}({S}_{1})$ and the right boundary of ${R}_{{S}_{2}}$ has at most ${d}_{0}logn$ distance from $\mathrm{RB}({S}_{2})$.

**Proof:**

The proof is the same as Lemma 35 for the algorithm with algorithm-type=DETERMINISTIC-SUPERQUADRATIC. For two sequences, ${S}_{1}$ and ${S}_{2}$, let $\aleph ({S}_{a})$ be the subsequence ${S}_{a}[{i}_{a},{j}_{a}]$ for $a=1,2$. By Corollary 18, with a probability of at most ${P}_{l}=2{c}^{{d}_{0}logn}\le \frac{2}{5\xb7{2}^{x}{n}^{3}}$ (see inequality (8) in Definition 14), there are more than $(\alpha +\u03f5){d}_{0}logn$ mutations in ${S}_{a}[{i}_{a},{i}_{a}+{d}_{0}logn-1]$ for $a=1,2$.

With a probability of at most ${P}_{l}$, the left boundary position is missed during the matching. We have similar ${P}_{r}={P}_{l}$ to miss the right boundary.

Assume that ${p}_{1}$ and ${p}_{2}$ are two positions of ${S}_{1}$ and ${S}_{2}$, respectively. If one of the two positions is outside the motif region and has more than ${d}_{0}logn$ distance to the motif boundary, with a probability of at most ${c}^{-{d}_{0}logn}\le \frac{1}{5\xb7{2}^{x}{n}^{3}}$ (see inequality (8) in Definition 14), for them to match requires $\mathrm{diff}({Y}_{1},{Y}_{2})\le \beta $ by Lemma 19, where ${Y}_{a}$ is a subsequence ${S}_{a}[{p}_{a},{p}_{a}+{d}_{0}logn-1]$ for $a=1,2$. ▮

**Lemma**

**41.**

Let algorithm-type=RANDOMIZED-SUBQUADRATIC. Assume that ${d}_{0}logn\le L\le |G|/2$ and $|G|\ge \frac{{(logn)}^{3+\tau}}{100}$. Let ${I}_{1}$ be a set of intervals of the positions of ${S}_{1}$ that satisfy $[\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]\cup [\mathrm{RB}({S}_{1})-L,\mathrm{RB}({S}_{1})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{1}}{I}^{\prime}$. Let ${I}_{2}$ be a set of intervals of the positions of ${S}_{2}$ that satisfy $[\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]\cup [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{2}}{I}^{\prime}$. Let ${U}_{1}=$ Point-Selection$({S}_{1},L,{I}_{1})$, ${U}_{2}=$ Point-Selection$({S}_{2},L,{I}_{2}])$ and $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$ Collision-Detection$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$. Then:

- i.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the left rough boundary, ${L}_{{S}_{1}}$, has at most a $2L$ distance from $\mathrm{LB}({S}_{1})$ and the left rough boundary ${L}_{{S}_{2}}$ has at most a $2L$ distance from $\mathrm{LB}({S}_{2})$;
- ii.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the right rough boundary, ${R}_{{S}_{1}}$, has at most a $2L$ distance from $\mathrm{RB}({S}_{1})$ and the right boundary of ${R}_{{S}_{2}}$ has at most a $2L$ distance from $\mathrm{RB}({S}_{2})$.

**Proof:**

We prove the following two statements which imply the lemma.

- i.
- With a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, there are no intervals, ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$, such that: (1) $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||$ is at least $\frac{L}{2}$; (2) the left boundary of ${S}_{1}$ has at most a $2L$ distance from ${A}_{i}$; (3) the left boundary of ${S}_{2}$ has at most a $2L$ distance from ${B}_{j}$; and (4) there is a collision between the sampled positions in ${A}_{i}$ and ${B}_{j}$.
- ii.
- With a probability pf at most $\frac{1}{{2}^{x}{n}^{3}}$, there are no intervals, ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$, such that: (1) $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||$ is at least $\frac{L}{2}$; (2) the right boundary of ${S}_{1}$ has at most a $2L$ distance from ${A}_{i}$; (3) the right boundary of ${S}_{2}$ has at most a $2L$ distance from ${B}_{j}$; and (4) there is a collision between the sampled positions in ${A}_{i}$ and ${B}_{j}$.

We only prove statement i. The proof for statement ii is similar.

Select ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$ to be the first pair of intervals with $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||\ge \frac{L}{2}$. It is easy to see that such a pair exists, and both have a distance from the left boundary with a distance of at most $2L$. This is because when a leftmost interval of a length pf L is fully inside the motif region of the first sequence, we can always find the second interval from the second sequence with an intersection of a length of at least $\frac{L}{2}$.

Replace m by $M(L)$, ${m}_{1}$ by ${M}_{1}(L)$ (see Definition 10) and n by L to apply Lemma 39. We do not consider any damaged position in this algorithm; therefore, let C be empty.

With a probability of at most $o(\frac{1}{{2}^{x}{n}^{3}})$, there is a point in $({A}_{i}({S}_{1},\aleph ({S}_{1}))-C)\cap ({B}_{j}({S}_{2},\aleph ({S}_{2}))-C)$. The subsequences of a length of ${d}_{0}logn$ starting at the point from ${S}_{1}$ and ${S}_{2}$ fail to have the difference bounded by β with a probability of at most $o(\frac{1}{{2}^{x}{n}^{3}})$ by Lemma 20. With a probability of at most $o(\frac{1}{{2}^{x}{n}^{3}})$, we do not have that the rough boundaries are detected with a distance of at most $2L$ to exact motif boundaries. ▮

**Lemma**

**42.**

For the case algorithm-type=RANDOMIZED-SUBQUADRATIC, we have:

- i.
- Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2}$) takes $t(n,||{U}_{1}||+||{U}_{2}||)=O((||{U}_{1}||+||{U}_{2}{||)}^{2}logn)$ time.
- ii.
- Point-Selection(${S}_{1},L,[1,|{S}_{1}|]$) selects $s(n,L)=O((\frac{n}{L})M(L))$ positions in $g(n,L)=O(s(n,L))$ time if $L\ge \frac{{(logn)}^{3+\tau}}{100}$.
- iii.
- Point-Selection(${S}_{1},L,[1,|{S}_{1}|]$) selects $s(n,L)=O(n)$ positions in $g(n,L)=O(n)$ time if $L<\frac{{(logn)}^{3+\tau}}{100}$.
- iv.
- $||{U}_{{S}_{2i-1}^{\prime}}||+||{U}_{{S}_{j}^{\u2033}}||$ in the algorithm Recover-Motif is no more than $f(n,|G|)=O(M(|G|)+\frac{n}{|G|}M(|G|))$.
- v.
- With a probability of at most $\frac{k}{{2}^{x}{n}^{3}}$, the algorithm Recover-Motif does not stop in $(O(k(\frac{{n}^{2}}{|G|}{(logn)}^{O(1)}+{h}^{2}logn)),O(k))$ time.

**Proof:**

Statement i. The parameter, ${\omega}_{\mathrm{RANDOMIZED}-\mathrm{SUBLINEAR}}$, is set to be β in Collision-Detection. It follows from the time complexity of the brute force method.

Statements ii and iii. They follow from the implementation of Point-Selection().

Statement iv. It follows from the choice of Point-Selection(.) for the sublinear time algorithm at Recover-Motif(.).

Statement iv. It follows from Lemma 40, Lemma 34 and Statements i, ii and iii. ▮

We give the proof for Theorem 6.

**Proof:**

[Theorem 4] The computational time part of this theorem follows from Lemma 42.

By Lemma 40, we can let ${\varsigma}_{1}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{1}(n)$, in the condition (i) of Lemma 32.

By Lemma 41, we can let ${\varsigma}_{2}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{2}(n)$, in the condition (ii) of Lemma 32.

By inequality (12), the condition (iii) of Lemma 32 is satisfied.

By inequality (11), we know that the condition (iii) of Lemma 32 can be satisfied.

The failure probability part of this theorem follows from Lemma 21 and Lemma 32 by using the fact that ${k}_{1},{k}_{2}$ and k are of the same order (see Equation (18)). ▮

#### 6.5.2.. Sublinear Time Algorithm for a $\frac{1}{{(logn)}^{2+\mu}}$ Mutation Rate

In this section, we give an algorithm for the case with at most $\alpha =\frac{1}{{(logn)}^{2+\mu}}$ mutation rate. The performance of the algorithm is stated in Theorem 2.

**Definition**

**43.**

A position, p, in the motif region, $\aleph (S)$, of an input sequence, S, is damaged if there exists at least one mutation in $S[p,p+{d}_{0}logn-1]$, where ${d}_{0}$ is defined in item (xvii) in Definition 8.

**Lemma**

**44.**

Assume that $\alpha L={(logn)}^{1+\Omega (1)}$. With a probability of at most ${e}^{-{(logn)}^{1+\Omega (1)}}$, there are more than $\frac{{M}_{1}(L)}{{(logn)}^{\Omega (1)}}$ positions that are from the $M(L)$ (see Definition 10 for $M(.)$ and ${M}_{1}(.)$) sampled positions that are damaged in an interval of a length pf L.

**Proof:**

By Theorem 16, with a probability of at most ${P}_{1}={2}^{-\alpha L}$ (let $\delta =2$), there are more than $3\alpha L$ mutations in an interval of a length of L. Therefore, with a probability of at most ${2}^{-\alpha L}={e}^{-{(logn)}^{1+\Omega (1)}}$, there are more than $3\alpha Llogn$ positions that are damaged. Therefore, each random position in an interval of a length of L has at most a probability of $\frac{3\alpha Llogn}{L}=3\alpha logn$ to be damaged.

Since $\alpha =(\frac{1}{{(logn)}^{2+\Omega (1)}})$ and $M(L)$ positions are sampled, by Theorem 16, with a probability of at most ${P}_{2}={2}^{-(3\alpha logn)M(L)}={e}^{-{(logn)}^{1+\Omega (1)}}$ (let $\delta =2$), the number of damaged positions sampled in an interval of a length of L is more than $((1+\delta )3\alpha logn)M=(9\alpha logn)M(L)=\frac{{M}_{1}(L)}{{(logn)}^{\Omega (1)}}$. Thus, with a total probability of at most ${P}_{1}+{P}_{2}={e}^{-{(logn)}^{1+\Omega (1)}}$, there are more than $\frac{{M}_{1}(L)}{{(logn)}^{\Omega (1)}}$ damaged positions that are from the $M(L)$ sampled positions in an interval of a length of L. ▮

**Definition**

**45.**

Let A be a set of positions in an input sequence, S, with $\aleph (S)=S[i,j]$. Let $A(S,\aleph (S))=\{x-i+1|x\in A\cap [i,j]\}$. In other words, $A(S,\aleph (S))$ contains all the positions of A in $\aleph (S)$.

**Lemma**

**46. Let**

Let algorithm-type=RANDOMIZED-SUBLINEAR. Assume that$|G|<\frac{{(logn)}^{3+\tau}}{100}$ and L is an integer with ${d}_{0}logn\le L\le |G|/2$. Let ${I}_{1}$ be a set of intervals of the positions of ${S}_{1}$ that satisfy $[\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]\cup [\mathrm{RB}({S}_{1})-L,\mathrm{RB}({S}_{1})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{1}}{I}^{\prime}$. Let ${I}_{2}$ be a set of intervals of the positions of ${S}_{2}$ that satisfy $[\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]\cup [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{2}}{I}^{\prime}$. Let ${U}_{1}=$ Point-Selection$({S}_{1},L,{I}_{1})$, ${U}_{2}=$ Point-Selection$({S}_{2},L,{I}_{2}])$ and $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$ Collision-Detection$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$. Then:

- i.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the left rough boundary, ${L}_{{S}_{1}}$, has at most a $|G|/4$ distance from $\mathrm{LB}({S}_{1})$ and the left rough boundary, ${L}_{{S}_{2}}$, has at most a $|G|/4$ distance from $\mathrm{LB}({S}_{2})$.
- ii.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the right rough boundary, ${R}_{{S}_{1}}$, has at most a $|G|/4$ distance from $\mathrm{RB}({S}_{1})$ and the right boundary of ${R}_{{S}_{2}}$ has at most a $|G|/4$ distance from $\mathrm{RB}({S}_{2})$.

**Proof:**

For two sequences, ${S}_{1}$ and ${S}_{2}$, it is easy to see that there is a common position in both motif regions of the two sequences, such that there is no mutation in the next ${d}_{0}logn$ characters with a high probability. This is because that mutation probability is small.

By Theorem 16, with a probability of at most ${P}_{l}={2}^{-\alpha |G|/4}$ (let $\delta =2$), there are more than $3\alpha \frac{|G|}{4}$ mutated characters in the interval $\aleph ({S}_{i})[1,\frac{|G|}{4}]$ for $i=1,2$. Since the mutation probability is $\alpha =(\frac{1}{{(logn)}^{2+\Omega (1)}})$, with a probability of at most ${2}^{-\alpha |G|/4}={e}^{-{(logn)}^{1+\Omega (1)}}$, there are more than $3\alpha \xb7\frac{|G|}{4}{d}_{0}logn$ positions to be damaged in $\aleph ({S}_{i})[1,\frac{|G|}{4}]$.

Similarly, we have a probability of at most ${P}_{r}={e}^{-{(logn)}^{1+\Omega (1)}}$ that there are more than $((3\alpha {d}_{0}logn)\xb7\frac{|G|}{4})=\frac{|G|}{{(logn)}^{\Omega (1)}}$ damaged positions in $\aleph ({S}_{i})[\frac{3|G|}{4}-1,|G|]$.

Now, we assume that left side has more than $((3\alpha {d}_{0}logn)\xb7\frac{|G|}{4})=\frac{|G|}{{(logn)}^{\Omega (1)}}$ damaged positions and the right side, more than $((3\alpha {d}_{0}logn)\xb7\frac{|G|}{4})=\frac{|G|}{{(logn)}^{\Omega (1)}}$ damaged positions in $\aleph ({S}_{i})[\frac{3|G|}{4}-1,|G|]$. Since each position in each interval of a length of L is selected in Point-Selection$({S}_{1},{S}_{2},L)$, it is easy to verify the conclusions of this lemma. ▮

**Lemma**

**47.**

Let algorithm-type=RANDOMIZED-SUBLINEAR. Assume that $|G|\ge \frac{{(logn)}^{3+\tau}}{100}$ and ${d}_{0}logn\le L\le |G|/2$. Let ${I}_{1}$ be a set of intervals of the positions of ${S}_{1}$ that satisfy $[\mathrm{LB}({S}_{1})-L,\mathrm{LB}({S}_{1})+L]\cup [\mathrm{RB}({S}_{1})-L,\mathrm{RB}({S}_{1})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{1}}{I}^{\prime}$. Let ${I}_{2}$ be a set of intervals of the positions of ${S}_{2}$ that satisfy $[\mathrm{LB}({S}_{2})-L,\mathrm{LB}({S}_{2})+L]\cup [\mathrm{RB}({S}_{2})-L,\mathrm{RB}({S}_{2})+L]\subseteq {\cup}_{{I}^{\prime}\in {I}_{2}}{I}^{\prime}$. Let ${U}_{1}=$Point-Selection$({S}_{1},L,{I}_{1})$, ${U}_{2}=$Point-Selection$({S}_{2},L,{I}_{2}])$ and $({L}_{{S}_{1}},{R}_{{S}_{1}},{L}_{{S}_{2}},{R}_{{S}_{2}})=$Collision-Detection$({S}_{1},{U}_{1},{S}_{2},{U}_{2})$. Then:

- i.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the left rough boundary, ${L}_{{S}_{1}}$, has at most a $2L$ distance from $\mathrm{LB}({S}_{1})$ and the left rough boundary, ${L}_{{S}_{2}}$, has at most a $2L$ distance from $\mathrm{LB}({S}_{2})$.
- ii.
- With a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, the right rough boundary, ${R}_{{S}_{1}}$, has at most a $2L$ distance from $\mathrm{RB}({S}_{1})$ and the right boundary of ${R}_{{S}_{2}}$ has at most a $2L$ distance from $\mathrm{RB}({S}_{2})$.

**Proof:**

We prove the following two statements, which imply the lemma.

- i.
- With a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, there are no intervals, ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$, such that: (1) $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||$ is at least $\frac{L}{2}$; (2) the left boundary of ${S}_{1}$ has at most a $2L$ distance from ${A}_{i}$; (3) the left boundary of ${S}_{2}$ has at most a $2L$ distance from ${B}_{j}$; and (4) there is a collision between the sampled positions in ${A}_{i}$ and ${B}_{j}$.
- ii.
- with a probability of at most $\frac{1}{{2}^{x}{n}^{3}}$, there are no intervals, ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$, such that: (1) $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||$ is at least $\frac{L}{2}$; (2) the right boundary of ${S}_{1}$ has at most a $2L$ distance from ${A}_{i}$; (3) the right boundary of ${S}_{2}$ has at most a $2L$ distance from ${B}_{j}$; and (4) there is a collision between the sampled positions in ${A}_{i}$ and ${B}_{j}$.

We only prove statement i. The proof for statement ii is similar to that for statement i. Assume that L satisfies the condition of this lemma. Select ${A}_{i}$ from ${S}_{1}$ and ${B}_{j}$ from ${S}_{2}$ to be the first pair of intervals of a size of L with $||{A}_{i}({S}_{1},\aleph ({S}_{1}))\cap {B}_{j}({S}_{2},\aleph ({S}_{2}))||\ge \frac{L}{2}$. This is because when a leftmost interval of a length of L is fully inside the motif region of the first sequence, we can always find the second interval from the second sequence with an intersection of a length of at least $\frac{L}{2}$.

Replace m by $M(L)$, ${m}_{1}$ by ${M}_{1}(L)$ (see Definition 10) and n by L to apply Lemma 39. We also let C be the set of damaged positions in $\aleph ({S}_{1})$ and $\aleph ({S}_{2})$ caused by the mutated positions. With a probability of at most $o(\frac{1}{{2}^{x}{n}^{3}})$, C has a size of $o({M}_{1}(L))$ by Lemma 44. With a probability of at most $o(\frac{1}{{2}^{x}{n}^{3}})$, there is point in $({A}_{i}({S}_{1},\aleph ({S}_{1}))-C)\cap ({B}_{j}({S}_{2},\aleph ({S}_{2}))-C)$. The existence of such a point makes ${L}_{{S}_{1}}$ and ${L}_{{S}_{2}}$ have a distance of at most $2L$ to $\mathrm{LB}({S}_{1})$ and $\mathrm{LB}({S}_{2})$, respectively. ▮

**Lemma**

**48.**

For the case algorithm-type=RANDOMIZED-SUBLINEAR, we have:

- i.
- Collision-Detection(${S}_{1},{U}_{1},{S}_{2},{U}_{2}$) takes $t(n,||{U}_{1}||+||{U}_{2}||)=O((||{U}_{1}||+||{U}_{2}||)logn)$ time.
- ii.
- Point-Selection(${S}_{1},L,[1,|{S}_{1}|]$) selects $s(n,L)=O((\frac{n}{L})M(L))$ positions in $g(n,L)=O(s(n,L))$ time if $L\ge \frac{{(logn)}^{3+\tau}}{100}$.
- iii.
- Point-Selection(${S}_{1},L,[1,|{S}_{1}|]$) selects $s(n,L)=O(n)$ positions in $g(n,L)=O(n)$ time if $L<\frac{{(logn)}^{3+\tau}}{100}$.
- iv.
- $||{U}_{{S}_{2i-1}^{\prime}}||+||{U}_{{S}_{j}^{\u2033}}||$ in the algorithm Recover-Motif is no more than $f(n,|G|)=O(M(|G|)+\frac{n}{|G|}M(|G|))$.
- v.
- With a probability of at most $\frac{k}{{2}^{x}{n}^{3}}$, the algorithm Recover-Motif does not stop in $(O(k(\frac{n}{\sqrt{h}}{(logn)}^{\frac{5}{2}}+{h}^{2}logn)),O(k))$ time.

**Proof:**

Statement i. The parameter, ${\omega}_{\mathrm{RANDOMIZED}-\mathrm{SUBLINEAR}}$, is set to be zero in Collision-Detection. It follows from the time complexity of bucket sorting, which is described in standard algorithm textbooks.

Statements ii and iii. They follow from the implementation of Point-Selection().

Statement iv. It follows from the choice of Point-Selection(.) for the sublinear time algorithm at Recover-Motif(.).

Statement v. It follows from Lemma 46, Lemma 47 and Lemma 34 and Statements i, ii iii and iv. ▮

We give the proof for Theorem 2.

**Proof:**

[Theorem 2] The computational time part of this theorem follows from Lemma 48.

By Lemma 46, we can let ${\varsigma}_{1}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{1}(n)$, in the condition (i) of Lemma 32.

By Lemma 47, we can let ${\varsigma}_{2}(n)=\frac{1}{{2}^{x}{n}^{3}}\le {\varsigma}_{0}$ for the probability bound, ${\varsigma}_{1}(n)$, in the condition (ii) of Lemma 32.

By inequality (12), the condition (iii) of Lemma 32 is satisfied.

By inequality (11), we know that the condition (iv) of Lemma 32 can be satisfied.

The failure probability part of this theorem follows from Lemma 21 and Lemma 32 by using the fact that ${k}_{1},{k}_{2}$ and k are of the same order (see Equation (18)). ▮

#### 6.6. Experiments on Simulated Datasets

Aiming at solving the motif discovery problem, we implemented our algorithm in Java. Our tests were all done on a laptop with an Intel Dual Core 1.5 G CPU and 3.0 G Memory. In the first experiment, we tested our algorithm on several simulated datasets, which are all generated from our probability model with a small mutation rate. Each input set contains 20 or 15 sequences, which are of a length of 600 or 500 base pairs. Additionally, each bp of all the simulated gene sequences was generated independently with the same occurrence probability. A motif with a fixed length was randomly planted into each input sequence. The minimum Hamming distances between the results and consensus are recorded.

#### 6.7. Experiments

There are many other tools for detecting and analyzing the motifs, like the EMmethod [23], MEME [24], Gibbs [25], Compo [26], MochiView [27], PhyME [28], HeliCis [29] and WebMotif [30], among others. Each of them has their advantages and disadvantages.

Table 1 shows the results on simulated datasets. From the table, we could find that the results of our algorithm for finding the motif on simulated datasets are satisfied. Our algorithm could find all the motifs from each sequence and get the consensus with an accuracy rate of 100%. If the dataset has a high mutation rate, we could increase the number of repetitions, so that the result on the datasets will be more accurate. We also recorded the total time cost for each test, which mainly depends on the number of test repetitions. In the experimental tables, the parameter, N, represents the number of sequences, parameter M represents the length of motifs, parameter M is the maximum length of sequences and R is the number of iterations. GCR1 is a famous DNA binding protein, whose ability to bind DNA is dependent on the CTTCC sequence motif [31]. Several other popular data sets are also used in the experiments of our motif detection and its comparisons to the other methods.

Set 1 | 20 | 600 | 15 | 60 | 100 | 98 |

Set 2 | 15 | 600 | 15 | 10 | 100 | 18 |

Set 3 | 20 | 600 | 12 | 15 | 100 | 22 |

In the second experiment, we tested our algorithm on a real sequence set, which was obtained from SCPD. SCPD contains a large number of gene data and transcription factors of yeast. Sequences in the same set are all regulated by a common motif. We chose 1,000 bp as the length of the input sequences. In order to show the advantages of our algorithm, we also compared the result of our algorithm with the results of several other existing motif finding methods on the same dataset, such as Gibbs, MEME, Info-Gibbs and Consensus. Table 2 shows the details of the data set we used in the experiment.

N | 6 | 9 | 6 | 15 | 5 |

Table 3 shows the results of the five algorithms on biological data sets. Table 4 and Figure 2 give the average mismatch numbers of each algorithm. We choose four well-known motif-detecting softwares to make the comparisons. From Table 3 and Table 4, we see that the average mismatch numbers of our algorithm on data sets GCN4 and GCR1 are significantly lower than other four well-known methods. On the data sets Bas1,Rap1Ebf1 and HSE-HTSF, our algorithms also shows satisfied performance compared to other methods.

In addition, our algorithm also shows its high speed in computations compared to other four motif finding methods. Because the starting pattern of algorithms are represented by a string, so our algorithm can avoid some extra time consuming computations unlike Gibbs sampling and EM methods, such as computations of likelihoods. According to this feature, we use the consensus string of the voting operation obtained from the last iteration as a new starting pattern in program, and continue doing voting operations repeatedly until there is no further improvement. Experimental results show that if we set the number of iterations to be a large integer, the programs could give more accurate results within a reasonable time.

Our Algorithm | 10 | 8 | 4 | 45 | 5 |

Gibbs | 8 | 51 | 5 | 202 | 7 |

MEME | 8 | 15 | 10 | 32 | 3 |

InfoGibbs | 9 | 21 | 5 | 46 | 9 |

Our Algorithm | 1.67 | 0.89 | 0.67 | 3 | 1 |

Gibbs | 1.33 | 5.6 | 0.83 | 13.46 | 1.4 |

MEME | 1.33 | 1.67 | 1.67 | 2.13 | 0.6 |

InfoGibbs | 1.5 | 2.33 | 0.83 | 3.06 | 1.8 |

#### 6.8. Conclusions

We develop algorithms under the probabilistic model. One of them finds the implanted motif with a high probability if the alphabet size is at least four, the motif length is in $[{(logn)}^{7+\mu},\frac{n}{{(logn)}^{1+\mu}}]$ and each character in the motif region has a probability of at most $\frac{1}{{(logn)}^{2+\mu}}$ of mutation. The motif region can be detected, and each motif character can be recovered in sublinear time. A sub-quadratic randomized algorithm is developed to recover the motif with an $\Omega (1)$ mutation rate. A quadratic deterministic algorithm is developed to recover the motif with an $\Omega (1)$ mutation rate. It is an interesting problem if there is an algorithm to handle the case for an alphabet of a size of three. A more interesting problem is to extend the algorithm to handle larger mutation probability.

#### 6.9. Future Works

Compared with other motif finding methods, our algorithm shows its great advantages. However, there are still some improvements that could be done on this algorithm. For example, though a sequence set has the consensus, the motif in each sequence may have high mutation rates; in addition, the length of each motif could also be different. Therefore, these two factors increase the difficulty for finding motifs, and currently, there is still no effective algorithm that could solve these problems. In the future, we plan to improve the efficiency of our algorithm by combining other motif finding methods, such as MEME; a combination may be made to make our algorithm have better performance in finding motifs from highly mutated sequences.

## Acknowledgments

We thank Ming-Yang Kao for introducing us to this topic. We also thank Lusheng Wang and Xiaowen Liu for some discussions. We would like to thank Eugenio De Hayos for his helpful comments. We would like to thank the reviewers, whose comments greatly improved the presentation of this paper.

This research is supported in part by the NSF Early Career Award 0845376, and NSF HRD-1137764.

## Conflicts of Interest

The authors declare no conflict of interest.

## References

- Frances, M.; Litman, A. On covering problems of codes. Theor. Comput. Sci.
**1997**, 30, 113–119. [Google Scholar] [CrossRef] - Ga̧sieniec, L.; Jansson, J.; Lingas, A. Efficient Approximation Algorithms for the Hamming Center Problem. In Proceedings of the 10th Annual ACM-SIAM Symposium on Discrete Algorithms, Baltimore, MD, USA, 17–19 January 1999; pp. S905–S906.
- Stormo, G.; Hartzell, G., III. Identifying protein-binding sites from unaligned DNA fragments. Proc. Natl. Acad. Sci. USA
**1991**, 88, 5699–5703. [Google Scholar] [CrossRef] [PubMed] - Lawrence, C.; Reilly, A. An expectation maximization (EM) algorithm for the identification and characterization of common sites in unaligned biopolymer sequences. Proteins
**1990**, 7, 41–51. [Google Scholar] [CrossRef] [PubMed] - Hertz, G.; Stormo, G. Identification of Consensus Patterns in Unaligned DNA and Protein Sequences: A Large-Deviation Statistical Basis for Penalizing Gaps. In Proceedings of the 3rd International Conference on Bioinformatics and Genome Research, Tallahassee, USA, 1–4 June 1994; pp. 201–216.
- Stormo, G. Consensus patterns in DNA. In Molecular Evolution: Computer Analysis of Protein and Nucleic Acid Sequences; Doolitle, R.F., Ed.. Methods Enzymol.
**1990**, 183, 211–221. [Google Scholar] - Lanctot, J.K.; Li, M.; Ma, B.; Wang, L.; Zhang, L. Distinguishing string selection problems. Inf. Comput.
**2003**, 185, 41–55. [Google Scholar] [CrossRef] - Lucas, K.; Busch, M.; Mossinger, S.; Thompson, J. An improved microcomputer program for finding gene- or gene family-specific oligonucleotides suitable as primers for polymerase chain reactions or as probes. Comput. Appl. Biosci.
**1991**, 7, 525–529. [Google Scholar] [CrossRef] [PubMed] - Dopazo, J.; Rodríguez, A.; Sáiz, J.C.; Sobrino, F. Design of primers for PCR amplification of highly variable genomes. Comput. Appl. Biosci.
**1993**, 9, 123–125. [Google Scholar] [PubMed] - Proutski, V.; Holme, E.C. Primer master: A new program for the design and analysis of PCR primers. Comput. Appl. Biosci.
**1996**, 12, 253–255. [Google Scholar] [CrossRef] [PubMed] - Li, M.; Ma, B.; Wang, L. On The Closest String and Substring Problems. J. ACM
**2002**, 49, 157–171. [Google Scholar] [CrossRef] - Li, M.; Ma, B.; Wang, L. Finding Similar Regions in Many Strings. In Proceedings of the 31st Annual ACM Symposium on Theory of Computing, Atlanta, GA, USA, 1–4 May 1999; pp. 473–482.
- Pevzner, P.; Sze, S. Combinatorial Approaches to Finding Subtle Signals in DNA Sequences. In Proceedings of the 8th International Conference on Intelligent Systems for Molecular Biology, Toronto, ON, Canada, 19–23 July 2000; pp. 269–278.
- Keich, U.; Pevzner, P. Finding motifs in the twilight zone. Bioinformatics
**2002**, 18, 1374–1381. [Google Scholar] [CrossRef] [PubMed] - Keich, U.; Pevzner, P. Subtle motifs: Defining the limits of motif finding algorithms. Bioinformatics
**2002**, 18, 1382–1390. [Google Scholar] [CrossRef] [PubMed] - Wang, L.; Dong, L. Randomized algorithms for motif detection. J. Bioinform. Comput. Biol.
**2005**, 3, 1039–1052. [Google Scholar] [CrossRef] [PubMed] - Chin, F.; Leung, H. Voting Algorithms for Discovering Long Motifs. In Proceedings of the 3rd Asia-Pacific Bioinformatics Conference, Singapore, 17–21 January 2005; pp. 261–272.
- Gusfield, D. Algorithms on Strings, Trees, and Sequences; Cambridge University Press: Cambridge, UK, 1997. [Google Scholar]
- Fu, B.; Kao, M.Y.; Wang, L. Probabilistic analysis of a motif discovery algorithm for multiple sequences. SIAM J. Discret. Math.
**2009**, 23, 1715–173. [Google Scholar] [CrossRef] - Fu, B.; Kao, M.Y.; Wang, L. Discovering almost any hidden motif from multiple sequences. ACM Transactions on Algorithms
**2011**, 7(2), 26. [Google Scholar] [CrossRef] - Liu, X.; Ma, B.; Wang, L. Voting Algorithms for the Motif Problem. In Proceedings of Computational Systems Bioinformatics Conference, (CSB’08), Stanford, CA, USA, 26–29 August 2008; pp. 37–47.
- Motwani, R.; Raghavan, P. Randomized Algorithms; Cambridge University Press: Cambridge, UK, 2000. [Google Scholar]
- Dempster, A.P.; Laird, N.M.; Rubin, D.B. Maximum likelihood from complete data vis the EM algorithm. J. R. Stat. Soc.
**1977**, 39, 1–38. [Google Scholar] - D’haesler, P. How does DNA sequence motif discovery work? Nat. Biotechnol.
**2006**, 24, 959–961. [Google Scholar] [CrossRef] [PubMed] - Lawrence, C.; Altschul, S.; Boguski, M.; Liu, J.; Neuwald, A.; Wootton, J. Detecting subtle sequence signals: A gibbs sampling strategy for multiple alignment. Science
**1993**, 262, 262–5131. [Google Scholar] [CrossRef] - Sandve, G.K.K.; Abul, O.; Drabløs, F. Compo: Composite motif discovery using discrete models. BMC Bioinform.
**2008**, 9. [Google Scholar] [CrossRef] [PubMed][Green Version] - Homann, O.; Johnson, A. MochiView: Versatile software for genome browsing and DNA motif analysis. BMC Biol.
**2010**, 8. [Google Scholar] [CrossRef] [PubMed] - Sinha, S.; Blanchette, M.; Tompa, M. PhyME: A probabilistic algorithm for finding motifs in sets of orthologous sequences. BMC Bioinform.
**2004**, 5. [Google Scholar] [CrossRef][Green Version] - Larsson, E.; Lindahl, P.; Mostad, P. HeliCis: A DNA motif discovery tool for colocalized motif pairs with periodic spacing. BMC Bioinform.
**2007**, 8. [Google Scholar] [CrossRef] [PubMed] - Romer, K.; Kayombya, G.R.; Fraenkel, E. WebMOTIFS: Automated discovery, filtering and scoring of DNA sequence motifs using multiple programs and Bayesian approaches. Nucleic Acids Res.
**2007**, 35, W217–W220. [Google Scholar] [CrossRef] [PubMed] - Baker, H. GCR1 of Saccharomyces cerevisiae encodes a DNA binding protein whose binding is abolished by mutations in the CTTCC sequence motif. Proc. Natl. Acad. Sci. USA
**1991**, 88, 9443–9447. [Google Scholar] [CrossRef] [PubMed]

© 2013 by the authors licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution license ( http://creativecommons.org/licenses/by/3.0/).