aboutsummaryrefslogtreecommitdiff
path: root/files/dna-sequence/algorithms.tex
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2019-01-10 02:28:42 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2019-01-10 02:28:42 +0100
commit3e50d7f7bff5980754a34d803733306b2c9e5a63 (patch)
treec1dd0dd24296bd23c5e1c5a67d84241f85f6ea6c /files/dna-sequence/algorithms.tex
parent6ec6042366c0885bfeb2d645df6a207b498e6c4b (diff)
downloadmitjafelicijan.com-3e50d7f7bff5980754a34d803733306b2c9e5a63.tar.gz
new post
Diffstat (limited to 'files/dna-sequence/algorithms.tex')
-rw-r--r--files/dna-sequence/algorithms.tex53
1 files changed, 0 insertions, 53 deletions
diff --git a/files/dna-sequence/algorithms.tex b/files/dna-sequence/algorithms.tex
deleted file mode 100644
index de26f13..0000000
--- a/files/dna-sequence/algorithms.tex
+++ /dev/null
@@ -1,53 +0,0 @@
1\documentclass{article}
2\usepackage{algorithm}% http://ctan.org/pkg/algorithms
3\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
4\begin{document}
5
6% https://tex.stackexchange.com/questions/229355/algorithm-algorithmic-algorithmicx-algorithm2e-algpseudocode-confused
7% https://en.wikibooks.org/wiki/LaTeX/Algorithms
8
9\begin{algorithm}
10\caption{Naive byte array to DNA encode}
11\begin{algorithmic}[1]
12\Procedure{EncodeToDNASequence}{$name$}
13 \State $fp\gets open(name)$
14 \State $en\gets null$
15 \While{$fp\not=EOF$}
16 \State $c\gets buf[0]$\Comment{Read 1 byte from buffer}
17 \State $b\gets sprintf("08b", c)$\Comment{Convert to string binary}
18 \For{\texttt{e in range[0,2,4,6]}}
19 \If {$e[0] = 48$ $1$ and $e[1] = 48$}\Comment{0x00 - A (Adenine)}
20 \State $en\gets en + `A`$
21 \EndIf
22 \If {$e[0] = 48$ $1$ and $e[1] = 49$}\Comment{0x01 - G (Guanine)}
23 \State $en\gets en + `G`$
24 \EndIf
25 \If {$e[0] = 49$ $1$ and $e[1] = 48$}\Comment{0x10 - C (Cytosine)}
26 \State $en\gets en + `C`$
27 \EndIf
28 \If {$e[0] = 49$ $1$ and $e[1] = 49$}\Comment{0x11 - T (Thymine)}
29 \State $en\gets en + `T`$
30 \EndIf
31 \EndFor
32 \EndWhile
33 \State \textbf{return} $en$\Comment{Return string DNA sequence}
34\EndProcedure
35\end{algorithmic}
36\end{algorithm}
37
38%\begin{algorithm}
39%\caption{Euclid’s algorithm}\label{euclid}
40%\begin{algorithmic}[1]
41%\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
42% \State $r\gets a\bmod b$
43% \While{$r\not=0$}\Comment{We have the answer if r is 0}
44% \State $a\gets b$
45% \State $b\gets r$
46% \State $r\gets a\bmod b$
47% \EndWhile\label{euclidendwhile}
48% \State \textbf{return} $b$\Comment{The gcd is b}
49%\EndProcedure
50%\end{algorithmic}
51%\end{algorithm}
52
53\end{document}