| 1 |
The \eslmod{randomseq} module contains routines for generating, |
| 2 |
shuffling, and randomizing sequences. |
| 3 |
|
| 4 |
``Generating'' means sampling a sequence from a given statistical |
| 5 |
distribution. ``Shuffling'' means taking a given sequence and |
| 6 |
randomizing it in some way that preserves at least the exact residue |
| 7 |
composition of that sequence, and possibly other higher-order |
| 8 |
statistics. ``Randomizing'' means sampling a sequence from a |
| 9 |
statistical distribution estimated from a given sequence. |
| 10 |
|
| 11 |
Routines like this are useful in testing sequence analysis algorithms; |
| 12 |
for example, calculating expected score statistics under simple null |
| 13 |
models. |
| 14 |
|
| 15 |
% ``essentially'' qualifier below, because our RNG is limited to 2^31 states, |
| 16 |
% and that limits the number of distinct permutations we can sample. |
| 17 |
|
| 18 |
When shuffling sequences, it is desirable to sample uniformly among |
| 19 |
possible permutations. Many shuffling algorithms (even some published |
| 20 |
ones \citep{Fitch83}) are not correct in this sense. Easel's |
| 21 |
monoresidue sequence shuffling implements the so-called Fisher/Yates |
| 22 |
algorithm (Knuth's ``Algorithm P'') \citep{Durstenfeld64,Knu-81a}. A |
| 23 |
nontrivial additional power of the module is the ability to shuffle |
| 24 |
sequences while preserving exact diresidue composition; the |
| 25 |
\ccode{esl\_rsq\_CShuffleDP()} and \ccode{esl\_rsq\_XShuffleDP()} |
| 26 |
routines implement the Altschul/Erickson method |
| 27 |
\citep{AltschulErickson86}. \footnote{A more efficient method than |
| 28 |
Altschul/Erickson is known \citep{KandelWinkler96,Coward99} but it has |
| 29 |
not yet been implemented for Easel.} |
| 30 |
|
| 31 |
The routines in the module are listed in |
| 32 |
Table~\ref{tbl:randomseq_api}. |
| 33 |
|
| 34 |
The base routines work on any alphabetic text string. Augmentation |
| 35 |
with the \eslmod{alphabet} module adds routines for shuffling |
| 36 |
digitized sequences. |
| 37 |
|
| 38 |
|
| 39 |
% Table generated by autodoc -t esl_randomseq.c (so don't edit here, edit esl_randomseq.c:) |
| 40 |
\begin{table}[hbp] |
| 41 |
\begin{center} |
| 42 |
{\small |
| 43 |
\begin{tabular}{|ll|}\hline |
| 44 |
\apisubhead{Generating iid sequences.}\\ |
| 45 |
\hyperlink{func:esl_rsq_IID()}{\ccode{esl\_rsq\_IID()}} & Generate an iid random text sequence.\\ |
| 46 |
\apisubhead{Shuffling sequences.}\\ |
| 47 |
\hyperlink{func:esl_rsq_CShuffle()}{\ccode{esl\_rsq\_CShuffle()}} & Shuffle a text sequence.\\ |
| 48 |
\hyperlink{func:esl_rsq_CShuffleDP()}{\ccode{esl\_rsq\_CShuffleDP()}} & Shuffle a text sequence, preserving diresidue composition.\\ |
| 49 |
\hyperlink{func:esl_rsq_CReverse()}{\ccode{esl\_rsq\_CReverse()}} & Reverse a string.\\ |
| 50 |
\hyperlink{func:esl_rsq_CShuffleWindows()}{\ccode{esl\_rsq\_CShuffleWindows()}} & Shuffle local windows of a text string.\\ |
| 51 |
\apisubhead{Randomizing sequences}\\ |
| 52 |
\hyperlink{func:esl_rsq_CMarkov0()}{\ccode{esl\_rsq\_CMarkov0()}} & Generate new text string of same 0th order Markov properties.\\ |
| 53 |
\hyperlink{func:esl_rsq_CMarkov1()}{\ccode{esl\_rsq\_CMarkov1()}} & Generate new text string of same 1st order Markov properties.\\ |
| 54 |
\hyperlink{func:esl_rsq_xIID()}{\ccode{esl\_rsq\_xIID()}} & Generate an iid random digital sequence.\\ |
| 55 |
\apisubhead{Shuffling sequences (digital mode)}\\ |
| 56 |
\hyperlink{func:esl_rsq_XShuffle()}{\ccode{esl\_rsq\_XShuffle()}} & Shuffle a digital sequence.\\ |
| 57 |
\hyperlink{func:esl_rsq_XShuffleDP()}{\ccode{esl\_rsq\_XShuffleDP()}} & Shuffle a digital sequence, preserving diresidue composition.\\ |
| 58 |
\hyperlink{func:esl_rsq_XReverse()}{\ccode{esl\_rsq\_XReverse()}} & Reverse a digital sequence.\\ |
| 59 |
\hyperlink{func:esl_rsq_XShuffleWindows()}{\ccode{esl\_rsq\_XShuffleWindows()}} & Shuffle local windows of a digital sequence.\\ |
| 60 |
\apisubhead{Randomizing sequences (digital mode)}\\ |
| 61 |
\hyperlink{func:esl_rsq_XMarkov0()}{\ccode{esl\_rsq\_XMarkov0()}} & Generate new digital sequence of same 0th order Markov properties.\\ |
| 62 |
\hyperlink{func:esl_rsq_XMarkov1()}{\ccode{esl\_rsq\_XMarkov1()}} & Generate new digital sequence of same 1st order Markov properties.\\ |
| 63 |
\hline |
| 64 |
\end{tabular} |
| 65 |
} |
| 66 |
\end{center} |
| 67 |
\caption{The \eslmod{randomseq} API.} |
| 68 |
\label{tbl:randomseq_api} |
| 69 |
\end{table} |
| 70 |
|
| 71 |
|
| 72 |
\subsection{Example of using randomseq} |
| 73 |
|
| 74 |
Here's an example: |
| 75 |
|
| 76 |
\input{cexcerpts/randomseq_example} |
| 77 |
|
| 78 |
|
| 79 |
|