| 1 |
\documentclass[twoside, twocolumn, 10pt]{article} |
| 2 |
\usepackage{amsmath,amssymb} |
| 3 |
\usepackage{moreverb} |
| 4 |
\usepackage{fancyheadings} |
| 5 |
\usepackage{ulem} |
| 6 |
\usepackage{parskip} |
| 7 |
\usepackage{calc,ifthen,epsfig} |
| 8 |
\sloppy |
| 9 |
|
| 10 |
% A few float parameters |
| 11 |
% |
| 12 |
\renewcommand{\dbltopfraction}{0.9} |
| 13 |
\renewcommand{\dblfloatpagefraction}{0.9} |
| 14 |
%\renewcommand{\textfraction}{0.05} |
| 15 |
|
| 16 |
|
| 17 |
\begin{document} |
| 18 |
|
| 19 |
% See page 63-64, LaTeX Companion |
| 20 |
% |
| 21 |
% leftmargin controls the left margin for EVERYTHING in the list! |
| 22 |
% |
| 23 |
\newcommand{\entrylabel}[1]{\mbox{\texttt{#1:}}\hfil} |
| 24 |
\newenvironment{entry} |
| 25 |
{\begin{list}{}% |
| 26 |
{\renewcommand{\makelabel}{\entrylabel}% |
| 27 |
%\setlength{\leftmargin}{1.5in}% |
| 28 |
}} |
| 29 |
{\end{list}} |
| 30 |
|
| 31 |
% The first parbox width controls the indent on the first text line |
| 32 |
% The makebox width seems to do nothing. |
| 33 |
\newcommand{\Lentrylabel}[1]{% |
| 34 |
{\parbox[b]{0pt}{\makebox[0pt][l]{\texttt{#1:}}\\}}\hfil\relax} |
| 35 |
\newenvironment{Lentry} |
| 36 |
{\renewcommand{\entrylabel}{\Lentrylabel}\begin{entry}} |
| 37 |
{\end{entry}} |
| 38 |
|
| 39 |
\title{ESTmapper documentation} |
| 40 |
\author{ |
| 41 |
Liliana Florea\thanks{[email protected]}, |
| 42 |
Brian P. Walenz\thanks{[email protected]}} |
| 43 |
|
| 44 |
\maketitle |
| 45 |
|
| 46 |
\pagestyle{fancy} |
| 47 |
|
| 48 |
\rhead[]{} |
| 49 |
\chead[ESTmapper]{ESTmapper} |
| 50 |
\lhead[\today]{\today} |
| 51 |
|
| 52 |
\normalem |
| 53 |
|
| 54 |
\newcommand{\ESTmapper}{{\sc ESTmapper\ }} |
| 55 |
|
| 56 |
\begin{abstract} |
| 57 |
The gory details of the \ESTmapper process is described. |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
\subsection{Hash Function Definitions} |
| 65 |
|
| 66 |
In the discussion that follows, let $A$ be an encoded mer, $H$ be the |
| 67 |
hashed value of the mer, and $C$ be the check value. $A$ is $m$ bits |
| 68 |
wide, $H$ is $h$ bits wide and $C$ is $m-h$ bits wide. |
| 69 |
|
| 70 |
Our hash and check functions must satisfy the following properties: |
| 71 |
\begin{align*} |
| 72 |
f_H &: m \rightarrow h \\ |
| 73 |
f_C &: m \rightarrow c \\ |
| 74 |
f_R &: h \times c \rightarrow m |
| 75 |
\end{align*} |
| 76 |
such that $f_R(f_H(A), f_C(A)) = A$. |
| 77 |
|
| 78 |
Furthermore, $f_H$ should be a good hash function, {\bf whatever that means}. |
| 79 |
The functions are explained in Section~\ref{sec:hashfcn}. |
| 80 |
|
| 81 |
\subsection{existDB} |
| 82 |
|
| 83 |
The {\tt existDB} will tell us if a mer exists in a sequence. |
| 84 |
|
| 85 |
We can build the structure in Figure~\ref{fig:hashstruct} in five |
| 86 |
steps, using $\theta(2 \cdot 2^h + 2 \cdot n)$ time and no temporary |
| 87 |
space. |
| 88 |
|
| 89 |
\begin{enumerate} |
| 90 |
\item |
| 91 |
Allocate and zero $2^h$ integers for the hash table. |
| 92 |
\item |
| 93 |
Count the size of each bucket: hash each mer, increment the size of |
| 94 |
that bucket. This can be done using the space for the hash table. |
| 95 |
Also count the number of mers. |
| 96 |
\item |
| 97 |
Allocate $n$ bucket entries, one for each mer. There is no need to |
| 98 |
initialize these. |
| 99 |
\item |
| 100 |
Make the hash table entry $i$ point to the start of bucket $i$. Note |
| 101 |
that the hash table entry $i+1$ can be used to find the end of bucket |
| 102 |
$i$. |
| 103 |
\item |
| 104 |
Rehash each mer, inserting the check value into the next available |
| 105 |
bucket entry (use the hash table to keep track of the next available |
| 106 |
entry). The buckets contain all the mers after this step, and the |
| 107 |
hash table is off by one -- entry $i$ points to the start of bucket |
| 108 |
$i+1$. If we offset the start of the table, we can fix this in $O(1)$ |
| 109 |
time. |
| 110 |
\end{enumerate} |
| 111 |
|
| 112 |
We assume that the input sequence does not contain duplicate mers. If |
| 113 |
it does, we should remove them from the table. |
| 114 |
|
| 115 |
\subsection{positionDB} |
| 116 |
|
| 117 |
We can extend the {\tt existDB} to store position information by |
| 118 |
storing, in the bucket entry, either the position of the mer (if there |
| 119 |
is exactly one copy) or a pointer to a list of positions. |
| 120 |
|
| 121 |
Unlike the {\tt existDB} we now need to remove duplicate mers from the |
| 122 |
table. |
| 123 |
|
| 124 |
\begin{enumerate} |
| 125 |
\item |
| 126 |
count bucket size - this overcounts the true size; it counts |
| 127 |
duplicates |
| 128 |
\item |
| 129 |
allocate counting buckets - build a list of hashed mers and the position |
| 130 |
that they occur. |
| 131 |
\item |
| 132 |
sort each bucket |
| 133 |
\item |
| 134 |
allocate the final hash table, buckets and position lists |
| 135 |
{\bf XXX} can we reuse the hash table and bucket space?? |
| 136 |
\item |
| 137 |
copy the counting buckets into the final structure. mers that occur |
| 138 |
exactly once have their position stored in the bucket entry. mers |
| 139 |
that occur more than once have a pointer to the position list |
| 140 |
placed in the bucket entry. |
| 141 |
\end{enumerate} |
| 142 |
|
| 143 |
\subsection{A Good Hash Function} |
| 144 |
\label{sec:hashfcn} |
| 145 |
|
| 146 |
A simple hash function would be to use the highest $h$ bits of the |
| 147 |
encoded mer as the hash, and use the lowest $m-h$ bits of the mer |
| 148 |
as the check. Unfortunately, this is a very poor hash function --- |
| 149 |
the hash function is strongly correlated with the input mer. {\bf needs more blah blah} |
| 150 |
|
| 151 |
A better hash function would first ``scramble'' the bits in the mer to |
| 152 |
break the correlation between the input and the output. |
| 153 |
|
| 154 |
In the discussion that follows, let $A$ be an encoded mer, $H$ be the |
| 155 |
hashed value of the mer, and $C$ be the collision resolution value. |
| 156 |
$A$ is $m$ bits wide, $H$ is $h$ bits wide and $C$ is $m-h$ bits wide. |
| 157 |
|
| 158 |
We want to find functions |
| 159 |
$f_H : m \rightarrow h$, |
| 160 |
$f_C : m \rightarrow c$, |
| 161 |
$f_R : h \times c \rightarrow m$ |
| 162 |
such that |
| 163 |
\begin{align*} |
| 164 |
f_H(A) =& H \\ |
| 165 |
f_C(A) =& C \\ |
| 166 |
f_R(H,C) =& A |
| 167 |
\end{align*} |
| 168 |
Furthermore, $f_H$ should be a good hash function. |
| 169 |
|
| 170 |
We specify $f_H$ and $f_C$ by specifying each bit in the output. |
| 171 |
\begin{align*} |
| 172 |
H_i &= A_{i} \oplus A_{i-\frac{m-h}{2}} \oplus A_{i+m-h}, \text{ for } 1 \le i \le h \\ |
| 173 |
C_i &= A_{i}, \text{ for } 1 \le i \le m-h |
| 174 |
\end{align*} |
| 175 |
Likewise, $f_R$ can be expressed as |
| 176 |
\begin{align*} |
| 177 |
A_i &= |
| 178 |
\begin{cases} |
| 179 |
C_i & 1 \le i \le m-h \\ |
| 180 |
A_{i-m+h} \oplus A_{i-\frac{m+h}{2}} \oplus H_{i-m+h} & m-h < i \le m |
| 181 |
\end{cases} |
| 182 |
\end{align*} |
| 183 |
In C code |
| 184 |
\begin{verbatim} |
| 185 |
u64bit fH(u64bit A) { |
| 186 |
return(((A) ^ |
| 187 |
(A >> (m-h)/2) ^ |
| 188 |
(A >> (m-h))) & MASK(h)); |
| 189 |
} |
| 190 |
|
| 191 |
u64bit fC(u64bit A) { |
| 192 |
return(A & MASK(m-h)); |
| 193 |
} |
| 194 |
\end{verbatim} |
| 195 |
where {\tt u64bit} is a 64-bit unsigned integer type. The code for |
| 196 |
$f_R$ is non-trivial, and is not needed. |
| 197 |
|
| 198 |
|
| 199 |
\end{document} |
| 200 |
|