diff --git a/content/chapters/include.tex b/content/chapters/include.tex index 173bbbf..b59250b 100755 --- a/content/chapters/include.tex +++ b/content/chapters/include.tex @@ -11,7 +11,7 @@ } } -\includechapters{part1}{2} +\includechapters{part1}{3} % \includechapters{part2}{2} diff --git a/content/chapters/part1/0.tex b/content/chapters/part1/0.tex index 9e69b2a..8a6fa1d 100755 --- a/content/chapters/part1/0.tex +++ b/content/chapters/part1/0.tex @@ -58,6 +58,6 @@ \EndIf \EndFor \State \Return $c$ - \EndFunction + \EndFunction \end{algorithmic} \end{algorithm} diff --git a/content/chapters/part1/2.tex b/content/chapters/part1/2.tex index de516cc..f4f558d 100644 --- a/content/chapters/part1/2.tex +++ b/content/chapters/part1/2.tex @@ -51,8 +51,8 @@ Let $S = $ ACGUUACGUU. Let's write the comparison matrix. \State \Return $M$ \EndFunction \end{algorithmic} - \end{algorithm} + \begin{algorithm} \caption{Construct the top half of a comparison matrix} \begin{algorithmic}[1] @@ -259,7 +259,7 @@ The suffix language of $S$ is $\{S, ACTACT, CTACT, TACT, ACT, CT, T\}$. \end{figure} \begin{algorithm} - \caption{Check if a sequences matches a motif, from a suffix automaton $\mathcal{O}(m)$} + \caption{Check if a sequences matches a motif, from a suffix automaton $\mathcal{O}(m)$, built from the automaton} \begin{algorithmic}[1] \Function{CheckMotifInSuffixAutomaton}{$W$: Array($m$), $A$: $\langle S, s_{0}, T, \Sigma,f \rangle$} \Returns{Boolean valued to \True{} if the motif is in the sequence} diff --git a/content/chapters/part1/3.tex b/content/chapters/part1/3.tex new file mode 100644 index 0000000..1bd7525 --- /dev/null +++ b/content/chapters/part1/3.tex @@ -0,0 +1,84 @@ +\chapter{Automata for motif search} + +Let $M$ be a motif $M = $ ACAT. + +\begin{figure} + \centering + \includegraphics{figures/part1/motif_search_automaton.pdf} + \caption{Motif search automaton for $M = $ ACAT} +\end{figure} + +The alphabet of motif is the same as the alphabet of the sequence. +The search automaton is complete. +If the there exists a letter $c$ in the sequence that is not +in the motif alphabet, we can make a virtual transition from +each state to the initial state whenever we encounter an unknown letter. + +\begin{algorithm} + \caption{Search a motif in a sequence with an automaton} + \begin{algorithmic}[1] + \Function{SearchMotif}{$S$: Array($n$), $A$: $\langle S, s_{0}, T, \Sigma, f \rangle$, $P$: Array($m$)} + \Returns{A set of positions where the motif has been found} + \State $s \gets s_0$ + \State $i \gets 0$ + \State $pos \gets \{\}$ + \While {$i < n$} % $\exists f(s, S[i])$ We assume $S$ and $P$ are formed on the same alphabet, so we could remove the second check, as $A$ is complete + \If {$s \in T$} + \State $pos \gets pos \cup \{ i - m \}$ + \EndIf + \State $s \gets f(s, S[i])$ + \State $i++$ + \EndWhile + \State \Return $pos$ + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Check if the a motif automaton recognizes only the prefix of size $m-1$ of a motif $P$ of size $m$ } + \begin{algorithmic}[1] + \Function{SearchMotifLastPrefix}{$S$: Array($n$), $A$: $\langle S, s_{0}, T, \Sigma, f \rangle$, $P$: Array($m$)} + \Returns{A set of positions where the motif has been found} + \State $s \gets s_0$ + \State $i \gets 0$ + \State $T_{new} \gets \{\}$ + \For {$s \in S$} + \For {$a \in \Sigma$} + \For {$t \in T$} + \If {$\exists f(s, a)$ and $f(s, a) = t$} + \State $T_{new} \gets T_{new} \cup s$ + \EndIf + \EndFor + \EndFor + \EndFor + \While {$i < n$} + \If {$s \in T_{new}$} + \State \Return \True + \EndIf + \State $s \gets f(s, S[i])$ + \State $i++$ + \EndWhile + \State \Return \False + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Check if the a motif automaton recognizes only the prefix of size $m-1$ of a motif $P$ of size $m$, knowing the sequence of the motif} + \begin{algorithmic}[1] + \Function{SearchMotifLastPrefix}{$S$: Array($n$), $A$: $\langle S, s_{0}, T, \Sigma, f \rangle$, $P$: Array($m$)} + \Returns{A set of positions where the motif has been found} + \State $s \gets s_0$ + \State $i \gets 0$ + \While {$i < n$ and $f(s, P[m-1]) \notin T$} + \State $s \gets f(s, S[i])$ + \State $i++$ + \EndWhile + \If{$f(s, P[m-1]) \in T$} + \State \Return \True + \Else + \State \Return \False + \EndIf + \EndFunction + \end{algorithmic} +\end{algorithm} \ No newline at end of file diff --git a/main.pdf b/main.pdf index c2428f1..37a5a01 100644 --- a/main.pdf +++ b/main.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:05a8df7c52c74678b9c1749d55d444d80a68fa2e4f53ac83721990eb2896e064 -size 250664 +oid sha256:f7d399a14f4887c141303c27212572571690acfe832b36202fb3758bf5f76992 +size 279254 diff --git a/tmp.pdf b/tmp.pdf index 130f8e5..1f58660 100644 --- a/tmp.pdf +++ b/tmp.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94c2912fea2b02c615c3534646b4496fc2f622a9af88a4f87602c7e6c772ad2e -size 49570 +oid sha256:a4ca0430df97538f18dd19ee77273b26e99f7e1ef07cc5b353cba53d88994dff +size 63306 diff --git a/tmp.tex b/tmp.tex index 0907187..47a449a 100644 --- a/tmp.tex +++ b/tmp.tex @@ -14,3 +14,5 @@ \end{document} + +\end{document} \ No newline at end of file