| 1 |
|
| 2 |
|
| 3 |
\Easel\ is a C code library for computational analysis of biological |
| 4 |
sequences using probabilistic models. \Easel\ is used by \HMMER\ |
| 5 |
\citep{hmmer,Eddy98}, the profile hidden Markov model software that |
| 6 |
underlies the \Pfam\ protein family database |
| 7 |
\citep{Finn06,Sonnhammer97} and several other protein family |
| 8 |
databases. \Easel\ is also used by \Infernal\ |
| 9 |
\citep{infernal,NawrockiEddy07}, the covariance model software that |
| 10 |
underlies the \Rfam\ RNA family database |
| 11 |
\citep{Griffiths-Jones05}. |
| 12 |
|
| 13 |
There are other biosequence analysis libraries out there, in a variety |
| 14 |
of languages |
| 15 |
\citep{Vahrson96,Pitt01,Mangalam02,Butt05,Dutheil06,Giancarlo07,Doring08}; |
| 16 |
but this is ours. \Easel\ is not meant to be comprehensive. \Easel |
| 17 |
is for supporting what's needed in our group's work on probabilistic |
| 18 |
modeling of biological sequences, in applications like \HMMER\ and |
| 19 |
\Infernal. It includes code for generative probabilistic models of |
| 20 |
sequences, phylogenetic models of evolution, bioinformatics tools for |
| 21 |
sequence manipulation and annotation, numerical computing, and some |
| 22 |
basic utilities. |
| 23 |
|
| 24 |
\Easel\ is written in ANSI/ISO C because its primary goals are high |
| 25 |
performance and portability. Additionally, \Easel\ aims to provide an |
| 26 |
ease of use reasonably close to Perl or Python code. |
| 27 |
|
| 28 |
\Easel\ is designed to be reused, but not only as a black box. I might |
| 29 |
use a black box library for routine functions that are tangential to |
| 30 |
my research, but for anything research-critical, I want to understand |
| 31 |
and control the source code. It's rational to treat reusing other |
| 32 |
people's code like using their toothbrush, because god only knows what |
| 33 |
they've done to it. For me, code reuse more often means acting like a |
| 34 |
magpie, studying and stealing shiny bits of other people's source |
| 35 |
code, and weaving them into one's own nest. \Easel\ is designed so you |
| 36 |
can easily pull useful baubles from it. |
| 37 |
|
| 38 |
\Easel\ is also designed to enable us to publish reproducible and |
| 39 |
extensible research results as supplementary material for our research |
| 40 |
papers. We put work into documenting \Easel\ as carefully as any other |
| 41 |
research data we distribute. |
| 42 |
|
| 43 |
These considerations are reflected in \Easel design decisions. |
| 44 |
\Easel's documentation includes tutorial examples to make it easy to |
| 45 |
understand and get started using any given \Easel\ module, independent |
| 46 |
of other parts of \Easel. \Easel\ is modular, in a way that should |
| 47 |
enable you to extract individual files or functions for use in your |
| 48 |
own code, with minimum disentanglement work. \Easel\ uses some |
| 49 |
precepts of object-oriented design, but its objects are just C |
| 50 |
structures with visible, documented contents. \Easel's source code is |
| 51 |
consciously designed to be read as a reference work. It reflects, in a |
| 52 |
modest way, principles of ``literate programming'' espoused by Donald |
| 53 |
Knuth. \Easel\ code and documentation are interwoven. Most of this |
| 54 |
book is automatically generated from \Easel's source code. |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
\section{Quick start} |
| 59 |
|
| 60 |
Let's start with a quick tour. If you have any experience with the |
| 61 |
variable quality of bioinformatics software, the first thing you want |
| 62 |
to know is you can get Easel compiled -- without having to install a |
| 63 |
million dependencies first. The next thing you'll want to know is |
| 64 |
whether \Easel\ is going to be useful to you or not. We'll start with |
| 65 |
compiling it. You can compile \Easel\ and try it out without |
| 66 |
permanently installing it. |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
\subsection{Downloading and compiling Easel for the first time} |
| 71 |
|
| 72 |
Easel is self-sufficient, with no dependencies other than what's |
| 73 |
already on your system, provided you have an ANSI C99 compiler |
| 74 |
installed. You can obtain an \Easel\ source tarball and compile it |
| 75 |
cleanly on any UNIX, Linux, or Mac OS/X operating system with an |
| 76 |
incantation like the following (where \ccode{xxx} will be the current |
| 77 |
version number): |
| 78 |
|
| 79 |
\begin{cchunk} |
| 80 |
% wget http://eddylab.org/easel/easel.tar.gz |
| 81 |
% tar zxf easel.tar.gz |
| 82 |
% cd easel-xxx |
| 83 |
% ./configure |
| 84 |
% make |
| 85 |
% make check |
| 86 |
\end{cchunk} |
| 87 |
|
| 88 |
The \ccode{make check} command is optional. It runs a battery of |
| 89 |
quality control tests. All of these should pass. You should now see |
| 90 |
\ccode{libeasel.a} in the directory. If you look in the directory |
| 91 |
\ccode{miniapps}, you'll also see a bunch of small utility programs, |
| 92 |
the \Easel\ ``miniapps''. |
| 93 |
|
| 94 |
There are more complicated things you can do to customize the |
| 95 |
\ccode{./configure} step for your needs. That includes customizing the |
| 96 |
installation locations. If you decide you want to install |
| 97 |
\Easel\ permanently, see the full installation instructions in |
| 98 |
chapter~\ref{chapter:installation}. |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
\subsection{Cribbing from code examples} |
| 103 |
|
| 104 |
Every source code module (that is, each \ccode{.c} file) ends with one |
| 105 |
or more \esldef{driver programs}, including programs for unit tests |
| 106 |
and benchmarks. These are \ccode{main()} functions that can be |
| 107 |
conditionally included when the module is compiled. The very end of |
| 108 |
each module is always at least one \esldef{example driver} that shows |
| 109 |
you how to use the module. You can find the example code in a module |
| 110 |
\eslmod{foo} by searching the \ccode{esl\_foo.c} file for the tag |
| 111 |
\ccode{eslFOO\_EXAMPLE}, or just navigating to the end of the file. To |
| 112 |
compile the example for module \eslmod{foo} as a working program, do: |
| 113 |
|
| 114 |
\begin{cchunk} |
| 115 |
% cc -o example -L. -I. -DeslFOO_EXAMPLE esl_foo.c -leasel -lm |
| 116 |
\end{cchunk} |
| 117 |
|
| 118 |
You may need to replace the standard C compiler \ccode{cc} with a |
| 119 |
different compiler name, depending on your system. Linking to the |
| 120 |
standard math library (\ccode{-lm}) may not be necessary, depending on |
| 121 |
what module you're compiling, but it won't hurt. Replace \ccode{foo} |
| 122 |
with the name of a module you want to play with, and you can compile |
| 123 |
any of Easel's example drivers this way. |
| 124 |
|
| 125 |
To run it, read the source code (or the corresponding section in this |
| 126 |
book) to see if it needs any command line arguments, like the name of |
| 127 |
a file to open, then: |
| 128 |
|
| 129 |
\begin{cchunk} |
| 130 |
% ./example <any args needed> |
| 131 |
\end{cchunk} |
| 132 |
|
| 133 |
You can edit the example driver to play around with it, if you like, |
| 134 |
but it's better to make a copy of it in your own file (say, |
| 135 |
\ccode{foo\_example.c}) so you're not changing \Easel's code. When you |
| 136 |
extract the code into a file, copy what's between the \ccode{\#ifdef |
| 137 |
eslFOO\_EXAMPLE} and \ccode{\#endif /*eslFOO\_EXAMPLE*/} flags that |
| 138 |
conditionally include the example driver (don't copy the flags |
| 139 |
themselves). Then compile your example code and link to \Easel\ like |
| 140 |
this: |
| 141 |
|
| 142 |
\begin{cchunk} |
| 143 |
% cc -o foo_example -L. -I. foo_example.c -leasel -lm |
| 144 |
\end{cchunk} |
| 145 |
|
| 146 |
\subsection{Cribbing from Easel miniapplications} |
| 147 |
|
| 148 |
The \ccode{miniapps} directory contains \Easel's |
| 149 |
\esldef{miniapplications}: several utility programs that \Easel\ |
| 150 |
installs, in addition to the library \ccode{libeasel.a} and its header |
| 151 |
files. |
| 152 |
|
| 153 |
The miniapplications are described in more detail later, but for the |
| 154 |
purpose of getting used to how \Easel\ is used, they provide you some |
| 155 |
more useful examples of small \Easel-based applications that are a |
| 156 |
little more complicated than individual module example drivers. |
| 157 |
|
| 158 |
You can probably get a long way into \Easel\ just by browsing the |
| 159 |
source code of the modules' examples and the miniapplications. If |
| 160 |
you're the type (like me) that prefers to learn by example, you're |
| 161 |
done, you can close this book now. |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
\section{Overview of Easel's modules} |
| 166 |
|
| 167 |
Possibly your next question is, does \Easel\ provide any functionality |
| 168 |
you're interested in? |
| 169 |
|
| 170 |
Each \ccode{.c} file in \Easel\ corresponds to one \Easel\ |
| 171 |
\esldef{module}. A module consists of a group of functions for some |
| 172 |
task. For example, the \eslmod{sqio} module can automatically parse |
| 173 |
many common unaligned sequence formats, and the \eslmod{msa} module |
| 174 |
can parse many common multiple alignment formats. |
| 175 |
|
| 176 |
There are modules concerned with manipulating biological sequences and |
| 177 |
sequence files (including a full-fledged parser for Stockholm multiple |
| 178 |
alignment format and all its complex and powerful annotation markup): |
| 179 |
|
| 180 |
\begin{center} |
| 181 |
\begin{tabular}{p{1in}p{3.7in}} |
| 182 |
\eslmod{sq} & Single biological sequences \\ |
| 183 |
\eslmod{msa} & Multiple sequence alignments and i/o \\ |
| 184 |
\eslmod{alphabet} & Digitized biosequence alphabets \\ |
| 185 |
\eslmod{randomseq}& Sampling random sequences \\ |
| 186 |
\eslmod{sqio} & Sequence file i/o \\ |
| 187 |
\eslmod{ssi} & Indexing large sequence files for rapid random access \\ |
| 188 |
\end{tabular} |
| 189 |
\end{center} |
| 190 |
|
| 191 |
There are modules implementing common operations on multiple sequence |
| 192 |
alignments (including many published sequence weighting algorithms, |
| 193 |
and a memory-efficient single linkage sequence clustering algorithm): |
| 194 |
|
| 195 |
\begin{center} |
| 196 |
\begin{tabular}{p{1in}p{3.7in}} |
| 197 |
\eslmod{msacluster} & Efficient single linkage clustering of aligned sequences by \% identity\\ |
| 198 |
\eslmod{msaweight} & Sequence weighting algorithms \\ |
| 199 |
\end{tabular} |
| 200 |
\end{center} |
| 201 |
|
| 202 |
There are modules for probabilistic modeling of sequence residue |
| 203 |
alignment scores (including routines for solving for the implicit |
| 204 |
probabilistic basis of arbitrary score matrices): |
| 205 |
|
| 206 |
\begin{center} |
| 207 |
\begin{tabular}{p{1in}p{3.7in}} |
| 208 |
\eslmod{scorematrix} & Pairwise residue alignment scoring systems\\ |
| 209 |
\eslmod{ratematrix} & Standard continuous-time Markov models of residue evolution\\ |
| 210 |
\eslmod{paml} & Reading PAML data files (including rate matrices)\\ |
| 211 |
\end{tabular} |
| 212 |
\end{center} |
| 213 |
|
| 214 |
There is a module for sequence annotation: |
| 215 |
|
| 216 |
\begin{center} |
| 217 |
\begin{tabular}{p{1in}p{3.7in}} |
| 218 |
\eslmod{wuss} & ASCII RNA secondary structure annotation strings\\ |
| 219 |
\end{tabular} |
| 220 |
\end{center} |
| 221 |
|
| 222 |
There are modules implementing some standard scientific numerical |
| 223 |
computing concepts (including a free, fast implementation of conjugate |
| 224 |
gradient optimization): |
| 225 |
|
| 226 |
\begin{center} |
| 227 |
\begin{tabular}{p{1in}p{3.7in}} |
| 228 |
\eslmod{vectorops} & Vector operations\\ |
| 229 |
\eslmod{dmatrix} & 2D matrix operations\\ |
| 230 |
\eslmod{minimizer} & Numerical optimization by conjugate gradient descent\\ |
| 231 |
\eslmod{rootfinder}& One-dimensional root finding (Newton/Raphson)\\ |
| 232 |
\end{tabular} |
| 233 |
\end{center} |
| 234 |
|
| 235 |
There are modules implementing phylogenetic trees and evolutionary |
| 236 |
distance calculations: |
| 237 |
|
| 238 |
\begin{center} |
| 239 |
\begin{tabular}{p{1in}p{3.7in}} |
| 240 |
\eslmod{tree} & Manipulating phylogenetic trees\\ |
| 241 |
\eslmod{distance} & Pairwise evolutionary sequence distance calculations\\ |
| 242 |
\end{tabular} |
| 243 |
\end{center} |
| 244 |
|
| 245 |
There are a number of modules that implement routines for many common |
| 246 |
probability distributions (including maximum likelihood fitting |
| 247 |
routines): |
| 248 |
|
| 249 |
\begin{center} |
| 250 |
\begin{tabular}{p{1in}p{3.7in}} |
| 251 |
\eslmod{stats} & Basic routines and special statistics functions\\ |
| 252 |
\eslmod{histogram} & Collecting and displaying histograms\\ |
| 253 |
\eslmod{dirichlet} & Beta, Gamma, and Dirichlet distributions\\ |
| 254 |
\eslmod{exponential} & Exponential distributions\\ |
| 255 |
\eslmod{gamma} & Gamma distributions\\ |
| 256 |
\eslmod{gev} & Generalized extreme value distributions\\ |
| 257 |
\eslmod{gumbel} & Gumbel (Type I extreme value) distributions\\ |
| 258 |
\eslmod{hyperexp} & Hyperexponential distributions\\ |
| 259 |
\eslmod{mixdchlet} & Mixture Dirichlet distributions and priors\\ |
| 260 |
\eslmod{mixgev} & Mixture generalized extreme value distributions\\ |
| 261 |
\eslmod{normal} & Normal (Gaussian) distributions\\ |
| 262 |
\eslmod{stretchexp} & Stretched exponential distributions\\ |
| 263 |
\eslmod{weibull} & Weibull distributions\\ |
| 264 |
\end{tabular} |
| 265 |
\end{center} |
| 266 |
|
| 267 |
There are several modules implementing some common utilities |
| 268 |
(including a good portable random number generator and a powerful |
| 269 |
command line parser): |
| 270 |
|
| 271 |
\begin{center} |
| 272 |
\begin{tabular}{p{1in}p{3.7in}} |
| 273 |
\eslmod{cluster} & Efficient single linkage clustering\\ |
| 274 |
\eslmod{fileparser} & Parsing simple token-based (tab/space-delimited) files\\ |
| 275 |
\eslmod{getopts} & Parsing command line arguments and options.\\ |
| 276 |
\eslmod{keyhash} & Hash tables for emulating Perl associative arrays\\ |
| 277 |
\eslmod{random} & Pseudorandom number generation and sampling\\ |
| 278 |
\eslmod{regexp} & Regular expression matching\\ |
| 279 |
\eslmod{stack} & Pushdown stacks for integers, chars, pointers\\ |
| 280 |
\eslmod{stopwatch} & Timing parts of programs\\ |
| 281 |
\end{tabular} |
| 282 |
\end{center} |
| 283 |
|
| 284 |
There are some specialized modules in support of accelerated and/or parallel computing: |
| 285 |
|
| 286 |
\begin{center} |
| 287 |
\begin{tabular}{p{1in}p{3.7in}} |
| 288 |
\eslmod{sse} & Routines for SSE (Streaming SIMD Intrinsics) vector computation support on Intel/AMD platforms\\ |
| 289 |
\eslmod{vmx} & Routines for Altivec/VMX vector computation support on PowerPC platforms\\ |
| 290 |
\eslmod{mpi} & Routines for MPI (message passing interface) support\\ |
| 291 |
\end{tabular} |
| 292 |
\end{center} |
| 293 |
|
| 294 |
\section{Navigating documentation and source code} |
| 295 |
|
| 296 |
The quickest way to learn about what each module provides is to go to |
| 297 |
the corresponding chapter in this document. Each chapter starts with a |
| 298 |
brief introduction of what the module does, and highlights anything |
| 299 |
that \Easel's implementation does that we think is particularly |
| 300 |
useful, unique, or powerful. That's followed by a table describing |
| 301 |
each function provided by the module, and at least one example code |
| 302 |
listing of how the module can be used. The chapter might then go into |
| 303 |
more detail about the module's functionality, though many chapters do |
| 304 |
not, because the functionality is straightforward or self-explanatory. |
| 305 |
Finally, each chapter ends with detailed documentation on each |
| 306 |
function. |
| 307 |
|
| 308 |
\Easel's source code is designed to be read. Indeed, most of this |
| 309 |
documentation is generated automatically from the source code itself |
| 310 |
-- in particular, the table listing the available functions, the |
| 311 |
example code snippets, and the documentation of the individual |
| 312 |
functions. |
| 313 |
|
| 314 |
Each module \ccode{.c} file starts with a table of contents to help |
| 315 |
you navigate.\footnote{\Easel\ source files are designed as complete |
| 316 |
free-standing documents, so they tend to be larger than most people's |
| 317 |
\ccode{.c} files; the more usual practice in C programming is to have |
| 318 |
a smaller number of functions per file.} The first section will often |
| 319 |
define how to create one or more \esldef{objects} (C structures) that |
| 320 |
the module uses. The next section will typically define the rest of |
| 321 |
the module's exposed API. Following that are any private (internal) |
| 322 |
functions used in the module. Last are the drivers, including |
| 323 |
benchmarks, unit tests, and one or more examples. |
| 324 |
|
| 325 |
Each function has a structured comment header that describes how it is |
| 326 |
called and used, including what arguments it takes, what it returns, |
| 327 |
and what error conditions it may raise. These structured comments are |
| 328 |
extracted for inclusion in this document, so what you read here for |
| 329 |
each function's documentation is identical to what is in the source |
| 330 |
code. |
| 331 |
|
| 332 |
|
| 333 |
|