Debian Codegraph @

documentation/userguide/tutorial.tex

raw
1 % EPN, Mon Oct 21 12:57:38 2013
2 % EPN, Mon Jun 27 12:32:24 2016 [1.1.2 release]
3 % EPN, Sat Nov 16 19:29:20 2019 [1.1.3 release]
4 % Actual commands run on:
5 % cbbdev13
6 % $ uname -a
7 % Linux cbbdev13 2.6.32-573.18.1.el6.x86_64 #1 SMP Tue Feb 9 22:46:17 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
8
9 \section{Tutorial}
10 \label{section:tutorial}
11 \setcounter{footnote}{0}
12
13 Here's a tutorial walk-through of some small projects with
14 Infernal. This should suffice to get you started on work of your own,
15 and you can (at least temporarily) skip the rest of the Guide,
16 such as all the nitty-gritty details of available command line
17 options.
18
19 \subsection {The programs in Infernal}
20
21
22 \begin{tabular}{ll}
23 \multicolumn{2}{c}{\textbf{Core programs}}\\
24 & \\
25 \textbf{cmbuild} & Build a covariance model from an input multiple alignment.\\
26 \textbf{cmcalibrate} & Calibrate E-value parameters for a covariance model.\\
27 \textbf{cmsearch} & Search a covariance model against a sequence database.\\
28 \textbf{cmscan} & Search a sequence against a covariance model database.\\
29 \textbf{cmalign} & Make a multiple alignment of many sequences to a common covariance model.\\
30 & \\
31 \multicolumn{2}{c}{\textbf{Other utilities}}\\
32 & \\
33 \textbf{cmconvert} & Convert CM formats to/from Infernal v1.1 format.\\
34 \textbf{cmemit} & Generate (sample) sequences from a covariance model.\\
35 \textbf{cmfetch} & Get a covariance model by name or accession from a CM database.\\
36 \textbf{cmpress} & Format a CM database into a binary format for \prog{cmscan}.\\
37 \textbf{cmstat} & Show summary statistics for each model in a CM database.\\
38 \end{tabular} \\
39 \\
40
41 In this section, we'll show examples of running each of these
42 programs, using examples in the \otext{tutorial/} subdirectory of the
43 distribution.
44
45 \subsection{Files used in the tutorial}
46
47 The subdirectory \otext{/tutorial} in the Infernal distribution contains the
48 files used in the tutorial, as well as a number of examples of various
49 file formats that Infernal reads. The important files for the tutorial
50 are:
51
52 \begin{sreitems}{\emprog{minifam.i1\{m,i,f,p\}}}
53 \item[\otext{tRNA5.sto}] A multiple alignment of five tRNA
54 sequences. This file is a simple example of \emph{Stockholm
55 format} that Infernal uses for structurally-annotated alignments.
56 %
57 \item[\otext{tRNA5.c.cm}] An example CM file. Built with
58 \prog{cmbuild} from \otext{tRNA5.sto} and calibrated using
59 \prog{cmcalibrate}. Included so you don't need to calibrate your own
60 model file, which takes about 20 minutes.
61 %
62 \item[\otext{mrum-genome.fa}] The 3 Mb genome of the methanogenic archeaon
63 \emph{Methanobrevibacter ruminantium}, in
64 FASTA format, downloaded from the NCBI Nucleotide database
65 (accession: NC\_13790.1).
66 %
67 \item[\otext{tRNA5-mrum.out}] An example \prog{cmsearch} output file,
68 obtained by searching \otext{tRNA5.c.cm} against \otext{mrum-genome.fa}.
69 %
70 \item[\otext{5S\_rRNA.sto}] The Rfam 10.1 5S ribosomal RNA (RF00001)
71 ``seed'' alignment.
72 %
73 \item[\otext{5S\_rRNA.c.cm}] A CM file built from
74 \otext{5S\_rRNA.sto} using \prog{cmbuild}
75 and calibrated using \prog{cmcalibrate}.
76 %
77 \item[\otext{Cobalamin.sto}] The Rfam 10.1 Cobalamin riboswitch (RF00174)
78 ``seed'' alignment.
79 %
80 \item[\otext{Cobalamin.c.cm}] A CM file built from
81 \otext{Cobalamin.sto} using \prog{cmbuild}
82 and calibrated using \prog{cmcalibrate}.
83 %
84 \item[\otext{minifam.cm}] A CM file including three calibrated CMs.
85 This is actually just a concatenation
86 of the files \otext{tRNA5.c.cm}, \otext{5S\_rRNA.c.cm} and
87 \otext{Cobalamin.c.cm}.
88 %
89 \item[\otext{minifam.i1\{m,i,f,p\}}] Binary compressed files
90 corresponding to \otext{minifam.cm}, produced by \prog{cmpress}.
91 %
92 \item[\otext{metag-example.fa}] A FASTA sequence file containing 3
93 sequences hand-selected from a metagenomics dataset \citep{Tringe05},
94 used for demonstrating \prog{cmscan}.
95 %
96 \item[\otext{minifam-metag.out}] An example \prog{cmscan} output file,
97 obtained by searching \otext{minifam.cm} against \otext{metag-example.fa}.
98 %
99 \item[\otext{mrum-tRNAs10.fa}] A FASTA sequence file containing 10
100 tRNAs predicted using \prog{cmsearch} in the \emph{M. ruminantium} genome.
101 %
102 \item[\otext{mrum-tRNAs10.out}] An example \prog{cmalign} output
103 alignment, obtained by aligning the sequences in
104 \otext{mrum-tRNAs10.fa} to the model in \otext{tRNA5.c.cm} with \prog{cmalign}.
105 %
106 \item[\otext{Cobalamin.fa}] A FASTA sequence file containing 1
107 \prog{cmscan}-predicted Cobalamin riboswitch extracted from \otext{metag-example.fa}.
108 %
109 \item[\otext{tRNA5-noss.sto}] A Stockholm alignment file identical
110 to \otext{tRNA5.sto} except without secondary structure annotation.
111 Used to demonstrate HMM searches for models without secondary
112 structure.
113 %
114 \item[\otext{tRNA5-hand.sto}] A Stockholm alignment file identical
115 to \otext{tRNA5.sto} except it includes column reference annotation.
116 Used to demonstrate expert annotation of model positions with
117 \otext{cmbuild --hand}.
118 %
119 \item[\otext{tRNA5-hand.frag.sto}] A Stockholm alignment file similar
120 to \otext{tRNA5-hand.sto} but with some sequence data at the
121 beginning and end of sequences removed and replaced with gaps. Used
122 to demonstrate model building with fragmentary sequence information.
123 %
124 \item[\otext{tRNA5-hand.frag2.sto}] Same as
125 \otext{tRNA5-hand.frag2.sto} except with the partial sequence
126 annotated as fragments. Used to demonstrate model building with
127 fragmentary sequence information.
128 %
129 \item[\otext{tRNA5-hand.fraggiven.sto}] Same as
130 \otext{tRNA5-hand.frag2.sto} except with the partial sequence
131 annotated as fragments. Used to demonstrate model building with
132 fragmentary sequence information.
133 %
134 \item[\otext{tRNA5-hand.c.cm}] A CM file built from
135 \otext{tRNA5-hand.sto} with \prog{cmbuild} and calibrated with
136 \prog{cmcalibrate}.
137 \end{sreitems}
138
139 \subsection{Searching a sequence database with a single covariance model}
140
141 \subsubsection{Step 1: build a covariance model with cmbuild}
142
143 Infernal starts with a multiple sequence alignment file that you
144 provide. It must be in Stockholm format and must include consensus
145 secondary structure annotation. The file \otext{tutorial/tRNA5.sto} is
146 an example of a simple Stockholm file. It is shown below, with a
147 secondary structure of the first sequence shown to the right for
148 reference (yeast Phe tRNA, labeled as ``tRNA1'' in the file):
149
150 \vspace{1em}
151 \begin{minipage}{4.0in}
152 \begin{sreoutput}[xleftmargin=0em]
153 # STOCKHOLM 1.0
154
155 tRNA1 GCGGAUUUAGCUCAGUUGGG.AGAGCGCCAGACUGAAGAUCUGGAGGUCC
156 tRNA2 UCCGAUAUAGUGUAAC.GGCUAUCACAUCACGCUUUCACCGUGGAGA.CC
157 tRNA3 UCCGUGAUAGUUUAAU.GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA.UC
158 tRNA4 GCUCGUAUGGCGCAGU.GGU.AGCGCAGCAGAUUGCAAAUCUGUUGGUCC
159 tRNA5 GGGCACAUGGCGCAGUUGGU.AGCGCGCUUCCCUUGCAAGGAAGAGGUCA
160 #=GC SS_cons <<<<<<<..<<<<.........>>>>.<<<<<.......>>>>>.....<
161
162 tRNA1 UGUGUUCGAUCCACAGAAUUCGCA
163 tRNA2 GGGGUUCGACUCCCCGUAUCGGAG
164 tRNA3 GGGGUUCAAUUCCCCGUCGCGGAG
165 tRNA4 UUAGUUCGAUCCUGAGUGCGAGCU
166 tRNA5 UCGGUUCGAUUCCGGUUGCGUCCA
167 #=GC SS_cons <<<<.......>>>>>>>>>>>>.
168 //
169 \end{sreoutput}
170 \end{minipage}
171 \begin{minipage}{1.5in}
172 \includegraphics[scale=0.4]{Figures/trna1-DF6280}
173 \end{minipage}
174 \vspace{1em}
175
176 This is a simple example of a multiple RNA sequence alignment with
177 secondary structure annotation, in \emph{Stockholm format}. Stockholm
178 format, the native alignment format used by HMMER and Infernal and the
179 Pfam and Rfam databases, is documented in detail later in the guide in
180 section~\ref{section:formats}.
181
182 For now, what you need to know about the key features of the input file is:
183 \begin{itemize}
184 \item The alignment is in an interleaved format.
185 Lines consist of a name, followed by an aligned sequence;
186 long alignments are split into blocks separated by blank lines.
187 \item Each sequence must have a unique name that has zero spaces in it. (This is important!)
188 \item For residues, any one-letter IUPAC nucleotide code is accepted,
189 including ambiguous nucleotides. Case is ignored; residues
190 may be either upper or lower case.
191 \item Gaps are indicated by the characters \otext{.}, \otext{\_}, -, or \verb+~+.
192 (Blank space is not allowed.)
193 \item A special line starting with \otext{\#=GC SS\_cons} indicates
194 the secondary structure consensus. Gap characters annotate
195 unpaired (single-stranded) columns. Base pairs are indicated
196 by any of the following pairs: \otext{<>}, \otext{()}, \otext{[]},
197 or \otext{\{\}}. No pseudoknots are allowed; the
198 open/close-brackets notation is only unambiguous for strictly
199 nested base-pairing interactions.
200 For more on secondary structure annotation see the WUSS format
201 description in section~\ref{section:formats}.
202 \item The alignment begins with the special tag line
203 \otext{\# STOCKHOLM 1.0}, and ends with \otext{//}.
204 Stockholm alignments
205 can be concatenated to create an alignment database flatfile
206 containing many alignments.
207 \end{itemize}
208
209 The \prog{cmbuild} command builds a covariance model from an alignment (or
210 CMs for each of many alignments in a Stockholm file), and saves the
211 CM(s) in a file. For example, type:
212
213 \user{cmbuild tRNA5.cm tutorial/tRNA5.sto}
214
215 and you'll see some output that looks like:
216
217 \begin{sreoutput}
218 # cmbuild :: covariance model construction from multiple sequence alignments
219 # INFERNAL 1.1.5 (Sep 2023)
220 # Copyright (C) 2023 Howard Hughes Medical Institute.
221 # Freely distributed under the BSD open source license.
222 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
223 # CM file: tRNA5.cm
224 # alignment file: tutorial/tRNA5.sto
225 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226 # rel entropy
227 # -----------
228 # idx name nseq eff_nseq alen clen bps bifs CM HMM description
229 # ------ -------------------- -------- -------- ------ ----- ---- ---- ----- ----- -----------
230 1 tRNA5 5 3.73 74 72 21 2 0.783 0.489
231 #
232 # CPU time: 0.09u 0.00s 00:00:00.09 Elapsed: 00:00:00.10
233 \end{sreoutput}
234
235 If your input file had contained more than one alignment, you'd get
236 one line of output for each model. The information on these lines is
237 almost self-explanatory. The \otext{tRNA5} alignment consisted of 5
238 % VERIFY WHEN UPDATING ^
239 sequences with 74 aligned columns. Infernal turned it into a model of
240 % ^^
241 72 consensus positions, which means it defined 2 gap-containing
242 %^ ^
243 alignment columns to be insertions relative to consensus. The 5
244 % ^
245 sequences were only counted as an ``effective'' total sequence number
246 (\otext{eff\_nseq}) of 3.73. The model includes 21 basepairs and 2
247 % ^^^^ ^^ ^
248 bifurcations. The model ended up with a relative entropy per position
249 (\otext{rel entropy, CM}; information content) of 0.783 bits. If the
250 % ^^^^^
251 secondary structure information of the model were ignored the relative
252 entropy per position (\otext{rel entropy, HMM}) would be 0.489 bits.
253 % ^^^^^
254 This output format is rudimentary. Infernal knows quite a bit more
255 information about what it's done to build this CM, but it's not
256 displaying it. You don't need to know more to be able to use the
257 model, so we can press on here. Model construction is described in
258 more detail in section~\ref{section:cmbuild}.
259
260 The new CM was saved to \otext{tRNA5.cm}. You can look at it
261 (e.g. \otext{> more tRNA5.cm}) if you like, but it isn't really designed
262 to be human-interpretable. You can treat \otext{.cm} files as compiled
263 models of your RNA alignment. The Infernal ASCII save file format is
264 defined in Section~\ref{section:formats}.
265
266 \subsubsection{Step 2: calibrate the model with cmcalibrate}
267
268 The next step is to ``calibrate'' the model. This step must be
269 performed prior to using your model for database searches with
270 \prog{cmsearch} or \prog{cmscan}. In this step, statistical parameters
271 necessary for reporting E-values (expectation values) are estimated
272 and stored in the CM file. When \prog{cmsearch} or \prog{cmscan} is
273 later used for a database search and a hit with score $x$ is found,
274 the E-value of that hit is the number of hits expected to score $x$ or
275 more just by chance (given the size of the search you're performing).
276
277 \emph{Importantly, if you're not going to use a model for database
278 search, there is no need to calibrate it.} For example, if you are
279 only going to use a model to create structurally annotated multiple
280 alignments of a large family like small subunit ribosomal RNA, don't
281 waste time calibrating it. \prog{cmsearch} and \prog{cmscan} are the
282 only Infernal programs that use E-values, so if you're not going to
283 use them then don't calibrate your model.
284
285 Unfortunately, CM calibration takes a long time because fairly long
286 random sequences must be searched to determine the expected
287 distribution of hit scores against nonhomologous sequences, and none
288 of the search acceleration heuristics described in
289 section~\ref{section:pipeline} can be used because they rely on
290 primary sequence similarity which is absent in random sequence.
291
292 The amount of time required for calibration varies widely, but
293 depends mainly on the size of the RNA family being modeled.
294 So you can know what kind of a wait you're in for, the
295 \prog{cmcalibrate} has a \otext{--forecast} option which reports an
296 estimate of the running time. To get an estimate for the tRNA model, do:
297
298 \user{cmcalibrate --forecast tRNA5.cm}\\
299
300 You should see something like this:
301
302 \begin{sreoutput}
303 # cmcalibrate :: fit exponential tails for CM E-values
304 # INFERNAL 1.1.5 (Sep 2023)
305 # Copyright (C) 2023 Howard Hughes Medical Institute.
306 # Freely distributed under the BSD open source license.
307 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
308 # CM file: tRNA5.cm
309 # forecast mode (no calibration): on
310 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
311 #
312 # Forecasting running time for CM calibration(s) on 4 cpus:
313 #
314 # predicted
315 # running time
316 # model name (hr:min:sec)
317 # -------------------- ------------
318 tRNA5 00:03:26
319 #
320 # CPU time: 0.09u 0.00s 00:00:00.09 Elapsed: 00:00:00.09
321 [ok]
322 \end{sreoutput}
323
324 The header comes first, telling you what program you ran, on what file
325 and with what options. This calibration will use 4 CPUs which is the
326 default number for Infernal's multithreaded programs, but you can
327 modify this to \otext{<n>} CPUs with the \otext{--nforecast <n>}
328 option if you want to use a different number of CPUs or are planning
329 on using MPI to parallelize the calibrate (see the Installation
330 section). Using 4 CPUs, \prog{cmcalibrate}
331 estimates the time required for calibration on the machine I'm using
332 at about three and a half minutes.
333
334 Feel free to perform the calibration yourself if you'd like (with the
335 command \otext{cmcalibrate tRNA5.cm}). However, we've included the file
336 \otext{tRNA5.c.cm}, an already calibrated version of \otext{tRNA5.cm},
337 for you to use if you don't want to wait. To use this calibrated
338 model, copy over the \otext{tRNA5.cm} file you just made with the
339 calibrated version:
340
341 \user{cp tutorial/tRNA5.c.cm tRNA5.cm}\\
342
343 \subsubsection{Step 3: search a sequence database with cmsearch}
344
345 You can now use your tRNA model to search for tRNA homologs in a
346 database. The file \otext{mrum-genome.fa} is the genome sequence of the
347 archaeon \emph{Methanobrevibacter rumanitium} (accession:
348 \otext{NC\_13790.1}). We'll use this file as our database. To perform
349 the search:
350
351 \user{cmsearch tRNA5.cm tutorial/mrum-genome.fa}\\
352
353 As before, the first section is the header, telling you what program
354 your ran, on what, and with what options:
355
356 \begin{sreoutput}
357 # cmsearch :: search CM(s) against a sequence database
358 # INFERNAL 1.1.5 (Sep 2023)
359 # Copyright (C) 2023 Howard Hughes Medical Institute.
360 # Freely distributed under the BSD open source license.
361 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
362 # query CM file: tRNA5.cm
363 # target sequence database: tutorial/mrum-genome.fa
364 # number of worker threads: 4
365 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
366 \end{sreoutput}
367
368 The second section is a list of ranked top hits (sorted by E-value,
369 most significant hit first):
370
371 \begin{sreoutput}
372 Query: tRNA5 [CLEN=72]
373 Hit scores:
374 rank E-value score bias sequence start end mdl trunc gc description
375 ---- --------- ------ ----- ----------- ------- ------- --- ----- ---- -----------
376 (1) ! 1.4e-18 71.4 0.0 NC_013790.1 362026 361955 - cm no 0.50 Methanobrevibacter rumi ...
377 (2) ! 3.3e-18 70.2 0.0 NC_013790.1 2585265 2585193 - cm no 0.60 Methanobrevibacter rumi ...
378 (3) ! 9.5e-18 68.7 0.0 NC_013790.1 762490 762562 + cm no 0.67 Methanobrevibacter rumi ...
379 (4) ! 9.5e-18 68.7 0.0 NC_013790.1 2041704 2041632 - cm no 0.67 Methanobrevibacter rumi ...
380 (5) ! 2.4e-17 67.5 0.0 NC_013790.1 2351254 2351181 - cm no 0.62 Methanobrevibacter rumi ...
381 (6) ! 3e-17 67.2 0.0 NC_013790.1 735136 735208 + cm no 0.59 Methanobrevibacter rumi ...
382 (7) ! 5.3e-17 66.4 0.0 NC_013790.1 2186013 2185941 - cm no 0.53 Methanobrevibacter rumi ...
383 (8) ! 1.7e-16 64.8 0.0 NC_013790.1 2350593 2350520 - cm no 0.66 Methanobrevibacter rumi ...
384 (9) ! 2.9e-16 64.1 0.0 NC_013790.1 2585187 2585114 - cm no 0.59 Methanobrevibacter rumi ...
385 (10) ! 9.3e-16 62.5 0.0 NC_013790.1 662185 662259 + cm no 0.61 Methanobrevibacter rumi ...
386 (11) ! 1.3e-15 62.0 0.0 NC_013790.1 360887 360815 - cm no 0.55 Methanobrevibacter rumi ...
387 (12) ! 1.7e-15 61.7 0.0 NC_013790.1 2350984 2350911 - cm no 0.53 Methanobrevibacter rumi ...
388 (13) ! 3.3e-15 60.7 0.0 NC_013790.1 2186090 2186019 - cm no 0.54 Methanobrevibacter rumi ...
389 (14) ! 4.3e-15 60.4 0.0 NC_013790.1 2680159 2680233 + cm no 0.67 Methanobrevibacter rumi ...
390 (15) ! 8.1e-15 59.5 0.0 NC_013790.1 2749839 2749768 - cm no 0.53 Methanobrevibacter rumi ...
391 (16) ! 8.1e-15 59.5 0.0 NC_013790.1 2749945 2749874 - cm no 0.53 Methanobrevibacter rumi ...
392 (17) ! 1e-14 59.2 0.0 NC_013790.1 361676 361604 - cm no 0.51 Methanobrevibacter rumi ...
393 (18) ! 1e-14 59.2 0.0 NC_013790.1 2585073 2584999 - cm no 0.60 Methanobrevibacter rumi ...
394 (19) ! 1.2e-14 59.0 0.0 NC_013790.1 2130422 2130349 - cm no 0.59 Methanobrevibacter rumi ...
395 (20) ! 1.3e-14 58.9 0.0 NC_013790.1 546056 545947 - cm no 0.61 Methanobrevibacter rumi ...
396 (21) ! 4.1e-14 57.3 0.0 NC_013790.1 361915 361844 - cm no 0.42 Methanobrevibacter rumi ...
397 (22) ! 5.2e-14 56.9 0.0 NC_013790.1 97724 97795 + cm no 0.49 Methanobrevibacter rumi ...
398 (23) ! 6.3e-14 56.7 0.0 NC_013790.1 2350717 2350646 - cm no 0.68 Methanobrevibacter rumi ...
399 (24) ! 8.3e-14 56.3 0.0 NC_013790.1 1873887 1873815 - cm no 0.64 Methanobrevibacter rumi ...
400 (25) ! 1.5e-13 55.5 0.0 NC_013790.1 360730 360659 - cm no 0.40 Methanobrevibacter rumi ...
401 (26) ! 3.6e-13 54.3 0.0 NC_013790.1 2680310 2680384 + cm no 0.52 Methanobrevibacter rumi ...
402 (27) ! 3.6e-13 54.3 0.0 NC_013790.1 2664806 2664732 - cm no 0.60 Methanobrevibacter rumi ...
403 (28) ! 3.8e-13 54.2 0.0 NC_013790.1 361061 360989 - cm no 0.41 Methanobrevibacter rumi ...
404 (29) ! 7.7e-13 53.3 0.0 NC_013790.1 2130335 2130262 - cm no 0.55 Methanobrevibacter rumi ...
405 (30) ! 7.7e-13 53.3 0.0 NC_013790.1 2151672 2151745 + cm no 0.65 Methanobrevibacter rumi ...
406 (31) ! 2.9e-12 51.4 0.0 NC_013790.1 319297 319370 + cm no 0.62 Methanobrevibacter rumi ...
407 (32) ! 3.9e-12 51.1 0.0 NC_013790.1 361753 361679 - cm no 0.55 Methanobrevibacter rumi ...
408 (33) ! 4e-12 51.0 0.0 NC_013790.1 360983 360912 - cm no 0.50 Methanobrevibacter rumi ...
409 (34) ! 6.1e-12 50.4 0.0 NC_013790.1 361456 361383 - cm no 0.50 Methanobrevibacter rumi ...
410 (35) ! 7.6e-12 50.1 0.0 NC_013790.1 362798 362727 - cm no 0.51 Methanobrevibacter rumi ...
411 (36) ! 9e-12 49.9 0.0 NC_013790.1 917722 917793 + cm no 0.61 Methanobrevibacter rumi ...
412 (37) ! 1e-11 49.7 0.0 NC_013790.1 2583869 2583798 - cm no 0.51 Methanobrevibacter rumi ...
413 (38) ! 1.4e-11 49.3 0.0 NC_013790.1 360811 360740 - cm no 0.42 Methanobrevibacter rumi ...
414 (39) ! 1.4e-11 49.3 0.0 NC_013790.1 362324 362252 - cm no 0.51 Methanobrevibacter rumi ...
415 (40) ! 4.3e-11 47.8 0.0 NC_013790.1 1160526 1160609 + cm no 0.60 Methanobrevibacter rumi ...
416 (41) ! 1e-10 46.6 0.0 NC_013790.1 362403 362331 - cm no 0.49 Methanobrevibacter rumi ...
417 (42) ! 1.1e-10 46.5 0.0 NC_013790.1 2327124 2327042 - cm no 0.63 Methanobrevibacter rumi ...
418 (43) ! 1.2e-10 46.4 0.0 NC_013790.1 995344 995263 - cm no 0.49 Methanobrevibacter rumi ...
419 (44) ! 2.3e-10 45.4 0.0 NC_013790.1 256772 256696 - cm no 0.57 Methanobrevibacter rumi ...
420 (45) ! 2.5e-10 45.3 0.0 NC_013790.1 2584830 2584758 - cm no 0.64 Methanobrevibacter rumi ...
421 (46) ! 6.3e-10 44.1 0.0 NC_013790.1 2351071 2350997 - cm no 0.59 Methanobrevibacter rumi ...
422 (47) ! 6.4e-10 44.1 0.0 NC_013790.1 362552 362482 - cm no 0.55 Methanobrevibacter rumi ...
423 (48) ! 5.1e-09 41.2 0.0 NC_013790.1 1064775 1064858 + cm no 0.63 Methanobrevibacter rumi ...
424 (49) ! 1.2e-08 40.0 0.0 NC_013790.1 361222 361150 - cm no 0.45 Methanobrevibacter rumi ...
425 (50) ! 1.3e-08 40.0 0.0 NC_013790.1 361369 361297 - cm no 0.60 Methanobrevibacter rumi ...
426 (51) ! 4.8e-08 38.1 0.0 NC_013790.1 361596 361513 - cm no 0.61 Methanobrevibacter rumi ...
427 (52) ! 3.1e-07 35.6 0.0 NC_013790.1 1913310 1913227 - cm no 0.64 Methanobrevibacter rumi ...
428 (53) ! 2.6e-06 32.7 0.0 NC_013790.1 363464 363381 - cm no 0.51 Methanobrevibacter rumi ...
429 (54) ! 3e-06 32.5 0.0 NC_013790.1 2584954 2584872 - cm no 0.58 Methanobrevibacter rumi ...
430 ------ inclusion threshold ------
431 (55) ? 0.026 20.1 0.0 NC_013790.1 363803 363716 - cm no 0.50 Methanobrevibacter rumi ...
432 (56) ? 3.4 13.4 0.0 NC_013790.1 984373 984304 - cm no 0.53 Methanobrevibacter rumi ...
433 \end{sreoutput}
434
435 The first number is the rank of each hit\footnote{Ranks of hits are in
436 parantheses to make it easy to jump to/from an entry in the hit list
437 and the hit alignment section, described later.}. Next comes either a
438 \otext{!} or \otext{?} symbol and then the \emph{E-value} of the hit.
439 The E-value is the statistical significance of the hit: the number of
440 hits we'd expect to score this highly in a database of this size
441 (measured by the total number of nucleotides) if the database
442 contained only nonhomologous random sequences. The lower the E-value,
443 the more significant the hit. The \otext{!} or \otext{?} that
444 precedes the E-value indicates whether the hit does (\otext{!}) or
445 does not (\otext{?}) satisfy the inclusion threshold for the search.
446 Inclusion thresholds are used to determine what matches should be
447 considered to be ``true'', as opposed to reporting thresholds that
448 determine what matches will be reported (often including the top of
449 the noise, so you can see what interesting sequences might be getting
450 tickled by your search). By default, inclusion thresholds usually
451 require an E-value of 0.01 or less, and reporting E-value thresholds
452 are set to 10.0, but these can be changed (see the manual page for
453 \prog{cmsearch} toward the end of guide).
454
455 The E-value is based on the \emph{bit score}, which is in the next
456 column. This is the log-odds score for the hit. Some people like to
457 see a bit score instead of an E-value, because the bit score doesn't
458 depend on the size of the sequence database, only on the covariance
459 model and the target sequence.
460
461 The next number, the \emph{bias}, is a correction term for biased
462 sequence composition that has been applied to the sequence bit
463 score. Infernal uses an alternative null model we call \emph{null3},
464 described more in section~\ref{section:pipeline}, to determine the bias
465 bit score correction. The bias correction is often very small and is
466 only reported to one decimal place, after rounding. For all hits in
467 this example search the bias column reads 0.0 bits, indicating that
468 the correction is less than 0.05 bits. On very biased sequences this
469 correction can become significant and is helpful for lowering the
470 score of high-scoring false positives that achieve high scores solely
471 due to their biased composition.
472
473 Next comes the target sequence name the hit is in, and the start and
474 end positions of the hit within the sequence. Hits can occur on either
475 the top (Watson) or bottom (Crick) strand of the target
476 sequence\footnote{You can search either only the top strand with the
477 \otext{--toponly} or bottom strand with the \otext{--bottomonly} options
478 to \prog{cmsearch} and \prog{cmscan}.}, so the start position may be
479 less than (if hit is on the top strand) or greater than (if hit is on
480 the bottom strand) the end position. After the end position, comes a single
481 \otext{+} or \otext{-} symbol, indicating whether the hit is on the
482 top (\otext{+}) or bottom (\otext{-}) strand (solely for convenience -
483 so you don't have to look at the start and end positions to determine
484 the strand the hit is on).
485
486 After the strand symbol comes the model field, which indicates whether
487 the hit was found using either the CM (\otext{cm}) or a profile HMM
488 built from the CM (\otext{hmm}). This field is necessary because for
489 models with zero basepairs, \prog{cmsearch} (and \prog{cmscan}) use a
490 profile HMM instead of a CM for final hit scoring. This is done for
491 reasons of speed and efficiency, because profile HMM algorithms are
492 more efficient than CM ones and a CM with zero basepairs is
493 essentially equivalent to a profile HMM. In this example, since our
494 tRNA model does include basepairs, \prog{cmsearch} used a CM to score
495 all hits and so all hits have \prog{cm} for this column. There's an
496 example later in the tutorial of hits found with a profile HMM.
497
498 The next column indicates whether the hit is \emph{truncated} or
499 not. Infernal uses special versions of its CM dynamic programming
500 algorithms to allow detection of structural RNAs that have been
501 truncated due to missing data at the beginning and/or end of a target
502 sequence. Truncated hits are most common in databases that include
503 single reads from shotgun sequencing projects. Since our database is a
504 complete genome, we don't expect any hits to be truncated due to
505 missing data. For all hits the ``trunc'' column reads
506 ``no'' indicating that, as expected, none of the hits are
507 truncated. There are examples of truncated hits in the next exercise
508 which uses \prog{cmscan}. Section~\ref{section:pipeline} describes how
509 Infernal detects and aligns truncated hits in more detail.
510
511 The next column reports the GC fraction of the hit. This is the
512 fraction of residues in the target sequence hit that are either G or C
513 residues. The GC fraction is included as an additional indication of
514 the level of sequence bias of the hit. Some expert users may be aided
515 by this number when deciding if they believe a hit is a real homolog
516 or a false positive.
517
518 Finally comes the description of the sequence, if any. This
519 description is propogated from the input target sequence file.
520
521 After the hit list comes the hit alignments section. Each hit in
522 the hit list will have a corresponding entry in this section, in the
523 same order. As an illustrative example, let's take a look at
524 hit number 43. First, take a look at the first four lines for this
525 hit:
526
527 \begin{sreoutput}
528 >> NC_013790.1 Methanobrevibacter ruminantium M1 chromosome, complete genome
529 rank E-value score bias mdl mdl from mdl to seq from seq to acc trunc gc
530 ---- --------- ------ ----- --- -------- -------- ----------- ----------- ---- ----- ----
531 (43) ! 1.2e-10 46.4 0.0 cm 1 72 [] 995344 995263 - .. 0.93 no 0.49
532 \end{sreoutput}
533
534 The first line of each hit alignment begins with \otext{>>} followed
535 by a single space, the name of the target sequence, then two spaces
536 and the description of the sequence, if any. Next comes a set of
537 tabular fields that is partially redundant with the information in the
538 hit list. The first five columns are the same as in the hit list. The
539 next column reports the type of model used for the alignment, as
540 described above for the hit list. The next four columns report the
541 boundaries of the alignment with respect to the query model (``mdl
542 from'' and ``mdl to'') and the target sequence (``seq from'' and ``seq
543 to''). Following the ``seq to'' column is a \otext{+} or \otext{-}
544 symbol indicating whether the hit is on the top (\otext{+}) or bottom
545 (\otext{-}) strand.
546
547 It's not immediately easy to tell from the ``to'' coordinate whether
548 the alignment ended internally in the query model or target sequence,
549 versus ran all the way (as in a full-length global alignment) to the
550 end(s). To make this more readily apparent, with each pair of query
551 and target endpoint coordinates, there's also a little symbology. For
552 the normal case of a non-truncated hit: \otext{..} means both ends of
553 the alignment ended internally, and \otext{[]} means both ends of the
554 alignment were full-length flush to the ends of the query or target,
555 and \otext{[.} and \otext{.]} mean only the left (5') or right (3') end
556 was flush/full length. For truncated hits, the symbols are the same
557 except that either the first and/or the second symbol will be a
558 \verb+~+ for the query and target. If the first symbol is \verb+~+
559 then the left end of the alignment is truncated because the 5' end of
560 the hit is predicted to be missing (extend beyond the beginning of the
561 target sequence). Similarly, if the second symbol is \verb+~+ then the
562 right end of the alignment is truncated because the 3' end of the hit
563 is predicted to be missing (extend beyond the end of the target
564 sequence). These two symbols occur just after the ``mdl to'' column for
565 the query, and after the strand \otext{+} or \otext{-} symbol for the
566 target sequence.
567
568 The next column is labeled ``acc'' and is the average posterior
569 probability of the aligned target sequence residues; effectively, the
570 expected accuracy per residue of the alignment. (This field may be
571 absent and replaced by a column labeled ``cyksc'' in certain
572 situations, as explained more below.)
573
574 The final two columns indicate whether the hit is truncated or not and
575 the GC fraction of the hit. These are redundant with the columns of
576 the same name in the hit list, described above.
577
578 Next comes the alignment display. This is an ``optimal
579 posterior accuracy'' alignment~\citep{Holmes98}, which means it is the
580 alignment with the maximal summed posterior probability of all
581 aligned residues. Take a look at the alignment for hit number 43:
582
583 \begin{sreoutput}
584 v v NC
585 (((((((,,<<<<______.._>>>>,<<<<<_______>>>>>,,,........,,<<<<<_______>>>>>))))))): CS
586 tRNA5 1 gCcggcAUAGcgcAgUGGu..AgcgCgccagccUgucAagcuggAGg........UCCgggGUUCGAUUCcccGUgccgGca 72
587 :::G:CAUAGCG AG GGU A CGCG:CAG:CU +++A:CUG: G+ UC:GGGGUUCGA UCCCC:UG:C:::A
588 NC_013790.1 995344 AGAGACAUAGCGAAGCGGUcaAACGCGGCAGACUCAAGAUCUGUUGAuuaguucuUCAGGGGUUCGAAUCCCCUUGUCUCUA 995263
589 **********************************************9444444445************************** PP
590 \end{sreoutput}
591
592 The alignment contains six lines. Start by looking at the second line
593 which ends with \otext{CS}. The line shows the predicted secondary
594 structure of the target sequence. The format is a little fancier and
595 more informative than the simple least-common-denominator format we
596 used in the input alignment file. It's designed to make it easier to
597 see the secondary structure by eye. The format is described in detail
598 later (see WUSS format in section~\ref{section:formats}); for now,
599 here's all you need to know. Basepairs in simple stem loops are
600 annotated with \otext{<>} characters. Basepairs enclosing
601 multifurcations (multiple stem loops) are annotated with \otext{()},
602 such as the tRNA acceptor stem in this example. In more complicated
603 structures, \otext{[]} and \otext{\{\}} annotations also show up, to
604 reflect deeper nestings of multifurcations. For single stranded
605 residues, \otext{\_} characters mark hairpin loops; \otext{-}
606 characters mark interior loops and bulges; \otext{,} characters mark
607 single-stranded residues in multifurcation loops; and \otext{:}
608 characters mark single stranded residues external to any secondary
609 structure. Insertions relative to this consensus are annotated by a
610 \otext{.} character.
611
612 The line above the \otext{CS} line ends with \otext{NC} and marks
613 negative scoring non-canonical basepairs in the alignment with a
614 \otext{v} character. All other positions of the alignment will be
615 blank\footnote{For anyone trying to parse this output, this means it
616 is possible for this line to be completely blank except for the
617 \otext{NC} trailer.} More specifically, the following ten types of
618 basepairs which are assigned a negative score by the model at their
619 alignment positions will be marked with a \otext{v}: \otext{A:A},
620 \otext{A:C}, \otext{A:G}, \otext{C:A}, \otext{C:C}, \otext{C:U},
621 \otext{G:A}, \otext{G:G}, \otext{U:U}, and \otext{U:C}. The \otext{NC}
622 annotation makes it easy to quickly identify suspicious basepairs in
623 a hit. Importantly, the \otext{NC} annotation will only be present in
624 CM hit alignments (``mdl'' column reads ``cm'') and will be absent in
625 HMM hit alignments (``mdl'' column reads ``hmm'') because basepairs
626 are not scored by an HMM.
627
628 The third line shows that consensus of the query model. The highest
629 scoring residue sequence is shown. Upper case residues are highly
630 conserved. Lower case residues are weakly conserved or unconserved.
631 Dots (\otext{.}) in this line indicate insertions in the target
632 sequence with respect to the model.
633
634 The fourth line shows where the alignment score is coming from. For a
635 consensus basepair, if the observed pair is the highest-scoring
636 possible pair according to the consensus, both residues are shown in
637 upper case; if a pair has a score of $\geq 0$, both residues are
638 annotated by : characters (indicating an acceptable compensatory
639 basepair); else, there is a space, indicating that a negative
640 contribution of this pair to the alignment score. Note that the
641 \otext{NC} line will only mark a subset of these negative scoring
642 pairs with a \otext{v}, as discussed above.
643 For a single-stranded consensus residue, if the observed residue is
644 the highest scoring possibility, the residue is shown in upper case;
645 if the observed residue has a score of $\geq 0$, a \otext{+} character
646 is shown; else there is a space, indicating a negative contribution to
647 the alignment score. Importantly, for HMM hits (``mdl'' column reads
648 ``hmm''), \emph{all} positions are considered single stranded, since
649 an HMM scores each half of a basepair independently.
650
651 The fifth line, beginning with \otext{NC\_013790.1} is
652 the target sequence. Dashes (\otext{-}) in this line indicate deletions
653 in the target sequence with respect to the model.
654
655 The bottom line represents the posterior probability (essentially the
656 expected accuracy) of each aligned residue. A 0 means 0-5\%, 1 means
657 5-15\%, and so on; 9 means 85-95\%, and a \otext{*} means 95-100\%
658 posterior probability. You can use these posterior probabilities to
659 decide which parts of the alignment are well-determined or not. You'll
660 often observe, for example, that expected alignment accuracy degrades
661 around locations of insertion and deletion, which you'd intuitively
662 expect.
663
664 Alignments for some searches may be formatted slightly differently
665 than this example. Longer alignments to longer models will be broken
666 up into blocks of six lines each - this alignment was short enough to
667 be entirely contained within a single block. If your model was built
668 with the \otext{--hand} option in \prog{cmbuild}, then an additional
669 line will be included in each block, with RF annotation. If the model
670 used for the alignment was an HMM (the ``mdl'' column reads ``hmm'')
671 then the \otext{NC} line will be absent from each alignment
672 block. We'll see example of all three of these cases later in the
673 tutorial. Finally, the \otext{PP} line will be absent if
674 \prog{cmsearch} has determined that calculating posterior
675 probabilities for the optimal posterior accuracy alignment would have
676 required more than a preset amount of memory (that amount is
677 autodetermined based on model size, but is capped at a maximum of
678 1024Mb for the largest models, unless the \emprog{--mxsize} option is
679 used to increase it). If the \otext{PP} line is absent, the tabular
680 ``acc'' field described above will be absent and replaced with a
681 ``cyksc'' field which reports the bit score of the highest scoring CYK
682 alignment, and the displayed alignment will be the alignment computed
683 by the CYK algorithm which requires less memory than the optimal
684 posterior accuracy alignment.
685
686 After hit number 43, there's 13 more hit alignments for hits number 44
687 through 56.
688
689 Finally, at the bottom of the file, you'll see some summary
690 statistics. For example, at the bottom of the tRNA search output,
691 you'll find something like:
692
693 \begin{sreoutput}
694 Internal CM pipeline statistics summary:
695 ----------------------------------------
696 Query model(s): 1 (72 consensus positions)
697 Target sequences: 1 (5874406 residues searched)
698 Target sequences re-searched for truncated hits: 1 (360 residues re-searched)
699 Windows passing local HMM SSV filter: 10932 (0.2063); expected (0.35)
700 Windows passing local HMM Viterbi filter: (off)
701 Windows passing local HMM Viterbi bias filter: (off)
702 Windows passing local HMM Forward filter: 136 (0.002704); expected (0.005)
703 Windows passing local HMM Forward bias filter: 133 (0.002634); expected (0.005)
704 Windows passing glocal HMM Forward filter: 84 (0.001948); expected (0.005)
705 Windows passing glocal HMM Forward bias filter: 84 (0.001948); expected (0.005)
706 Envelopes passing glocal HMM envelope defn filter: 99 (0.001331); expected (0.005)
707 Envelopes passing local CM CYK filter: 60 (0.0007629); expected (0.0001)
708 Total CM hits reported: 56 (0.0007205); includes 0 truncated hit(s)
709
710 # CPU time: 1.44u 0.03s 00:00:01.47 Elapsed: 00:00:02.91
711 //
712 [ok]
713 \end{sreoutput}
714
715 This gives you some idea of what's going on in Infernal's acceleration
716 pipeline. You've got one query CM, and the database has one target
717 % ^ ^
718 sequence. The search examined 5,874,406 residues, even though the
719 % ^^^^^^^^^
720 actual target sequence length is only half that, because both the top
721 and bottom strand of each target is searched. 360 of those residues
722 % ^^^
723 were searched more than once in an effort to find truncated
724 hits. Ignore this for the moment, we'll revisit this later after
725 discussing the filter pipeline (in the subsection entitled ``Truncated
726 RNA detection'' below).
727
728 Each sequence goes through a multi-stage filter pipeline of four
729 scoring algorithms called SSV, Viterbi, Forward\footnote{Actually two
730 separate Forward based filters are used, the first with the profile
731 HMM in local mode and the next with the profile HMM in global
732 mode. There's more detail on this in
733 section~\ref{section:pipeline}.}, and CYK in order of increasing
734 sensitivity and increasing computational requirement. The filter
735 pipeline is the topic of section~\ref{section:pipeline} of this guide
736 but briefly, SSV, Viterbi and Forward are profile HMM algorithms which
737 are more efficient than CM algorithms. These three algorithms are the
738 same ones used by HMMER3 and are the main reason that version 1.1 of
739 Infernal is so much faster than previous versions. For these HMM
740 stages, Infernal uses a filter profile HMM that was constructed
741 simultaneously with the CM, from the same training alignment in
742 \prog{cmbuild}, and stored in the CM file. CYK is a CM scoring
743 algorithm, so it's slow, but it is accelerated using banded dynamic
744 programming with bands derived from an HMM alignment. Subsequences
745 that survive all filters are finally scored with the CM Inside
746 algorithm, agains using HMM bands. Subsequences that score
747 sufficiently high with Inside are then aligned using the optimal
748 posterior accuracy algorithm and displayed.
749
750 The score thresholds for a subsequence surviving each HMM filter stage
751 are dependent on the search space size (sequence database size for
752 \prog{cmsearch}). This differs from HMMER3 which always uses the same
753 filter thresholds. In general, the larger the search
754 space the more strict the thresholds are, because a hit must have a
755 higher bit score to have a significant E-value. In this case, the
756 database is relatively small so the filter thresholds have been set
757 relatively loosely. The SSV filter has been configured to allow
758 subsequences with a P-value of $\leq 0.35$ through
759 % ^^^^^^
760 the SSV score filter (thus, if the database contained no homologs and
761 P-values were accurately calculated, the highest scoring 35\% of the
762 % ^^^^
763 residues will pass the filter). Here, about 21\% of the database in
764 % ^^^^
765 10,932 separate windows got through the SSV filter. For a database of
766 %^^^^^
767 this size, the local Viterbi filter is turned off. The local Forward filter
768 is set to allow an expected 0.5\% of the database survive. Here about
769 % ^^^^
770 0.3\% survives in 136 windows. Next, each surviving window is checked
771 %^^
772 to see if the target sequence is ``obviously'' so biased in its
773 composition that it's unlikely to be a true homolog. This is called
774 the ``bias filter''\footnote{There's also a bias filter step used in
775 the local Viterbi filter stage, when it is used.} and applying a bit
776 score correction to previous filter's score for each window and
777 recomputing the P-value. Three of the 136 windows fail to pass
778 % ^^^^^ ^^^
779 the local Forward bias filter stage. Next, the Forward algorithm is
780 used to score each window again, but this time with the HMM configured
781 in glocal mode requiring a full length alignment to the
782 model\footnote{The use of glocal Forward is another important
783 difference between Infernal and HMMER3's (v3.0) pipeline. HMMER v3.0
784 only uses local HMM algorithms.} As with the local stage, an
785 expected 0.5\% of the database is expected to survive. In this case,
786 84 of the 133 windows, comprising about 0.2\% of the database,
787 %^ ^^^
788 survive. The bias filter is run again, this time applying a correction
789 to the glocal Forward scores. For this search, 0 windows are removed at
790 this stage. The envelope definition stage is next. This stage is very
791 similar to the HMMER3 domain definition stage, with the difference
792 that the HMM is configured in glocal rather than local mode. In this
793 stage, the Forward and Backward algorithms are used to identify zero
794 or more hit envelopes in each window, where each envelope contains one
795 putative hit. Often residues at the beginning and ends of windows are
796 determined to be nonhomologous and are not included in the
797 envelope. In this search, 99 envelopes are defined within the 84
798 % ^^^ ^^
799 windows. Note that the envelopes comprise only about 70\% of the
800 % ^^^
801 residues from the 84 windows, indicated by the drop of 0.1948\% to
802 % ^^^^^^^^
803 0.1331\%.
804 %%^^^^
805
806 After hit envelopes have been defined with the filter HMM, the two
807 remaining stages of the pipeline use the CM to score both the
808 conserved sequence and structure of each possible hit. In both of
809 these stages, constraints are derived from an HMM alignment of the
810 envelope and enforced as \emph{bands} on the CM dynamic programming
811 matrices (more on this in section~\ref{section:pipeline}). In the
812 first CM stage, the CYK algorithm (which is the SCFG analog of the
813 Viterbi HMM algorithm) is used to determine the best scoring maximum
814 likelihood alignment of any subsequence in each envelope to the CM. If
815 this alignment has a P-value of $\leq 0.0001$ then the envelope
816 survives to the final round. The envelopes passed to the final stage
817 may be shorter than those examined during the CYK stage. Specifically,
818 envelopes are redefined as starting and ending at the first and final
819 residues for which at least one alignment exists with a P-value $\leq
820 0.001$.
821
822 In the final round, the Inside algorithm (the SCFG analog of the HMM
823 Forward algorithm) is used to define final hit boundaries and
824 scores. Hits with scores above the reporting threshold were output, as
825 described above. In this search there were 56 such hits.
826 % ^^
827
828 Finally, the running time of the search is reported, in CPU time and
829 elapsed time. This search took about 3 seconds (wall
830 clock time) running on 4 cores.
831 % ^^^^^^^^^^^
832 \subsubsection{Truncated RNA detection}
833
834 Now, we come back to the topic of truncated hit detection. As briefly
835 mentioned above, the pipeline statistics summary from our search above
836 reported that 360 residues were re-searched for truncated
837 % ^^^
838 hits. Infernal explicitly looks at the 5' and 3' ends of target
839 sequences using specialized algorithms for detection of truncated
840 hits, in which part of the 5' and/or 3' end of the actual full length
841 sequence from the source organism's full genomic context is missing in
842 the input target sequence. Truncated hits will be most common in
843 sequence files consisting of unassembled sequencing reads. In our
844 search of the full archaeal genome above, no truncated hits were
845 found. However, there is an example of a truncated hit in the
846 \prog{cmscan} tutorial section below in a sequence from a metagenomics
847 sequencing survey.
848
849 Special dynamic programming algorithms are required for truncated hit
850 detection \citep{KolbeEddy09}, so sequences must be re-searched for
851 truncated hits after they are initially searched for standard
852 (non-truncated) hits. However, only the sequence ends must be
853 re-searched because Infernal assumes that only hits at sequence
854 terminii might be truncated. This is why our search above reported
855 that only 360 residues were re-searched for truncated hits. For each
856 % ^^^
857 model, an expected maximum length of a hit\footnote{The expected
858 maximum hit length is defined as the maximum of 1.25 times the
859 consensus length of the model and the $W$ parameter computed with
860 the QDB algorithm \citep{NawrockiEddy07}. $W$ is computed based on
861 the transition probabilities of the model by \prog{cmbuild} and
862 stored in the CM file.}
863 is used to define the window length at the
864 beginning and end of each sequence which must be re-searched for
865 truncated hits. For our tRNA model the maximum expected length is
866 90, so exactly 360 residues were re-searched: the first and final 90
867 %^ ^^^ ^^
868 residues on the top strand, and the first and final 90 residues on
869 % ^^
870 the bottom strand.
871
872 There is one more aspect of truncated hit detection that is important
873 to mention here. Because Infernal expects that hit truncation only
874 occurs at the ends of sequences, 5' truncated hits are forced to start
875 at the first nucleotide of a sequence, 3' truncated hits are forced to
876 end at the final nucleotide of the sequence, and 5' \emph{and} 3'
877 truncated hits are forced to include the full sequence.
878
879 The annotation of truncated hits in \prog{cmsearch} output is slightly
880 different than for standard (non-truncated) hits. An example is
881 included in the next section below.
882
883 \subsection{Searching a CM database with a query sequence}
884
885 The \prog{cmscan} program is for annotating all the different
886 known/detectable RNAs in a given sequence. It takes a single query
887 sequence and a CM database as input. The CM database might be Rfam,
888 for example, or another collection of your choice. \prog{cmscan} is
889 new to version 1.1 of Infernal. It is designed to be useful for
890 sequence datasets from RNA-Seq experiments or metagenomics surveys,
891 for which one wants to know what families of RNAs are represented in
892 the sequence dataset.
893
894 \subsubsection{Step 1: create an CM database flatfile}
895
896 A CM ``database'' flatfile is simply a concatenation of individual CM
897 files. To create a database flatfile, you can either build and
898 calibrate individual CM files and concatenate them, or you can
899 concatenate Stockholm alignments and use \prog{cmbuild} to build a CM
900 database of all of them in one command, and then calibrate that
901 database with \prog{cmcalibrate}. Importantly, \prog{cmscan} can only
902 be used with calibrated CMs.
903
904 Let's create a tiny database called \otext{minifam.cm} containing the
905 tRNA model we've been working with, a 5S ribosomal RNA model, and a
906 Cobalamin riboswitch model. To save you time, calibrated versions of
907 the 5S and Cobalamin models are included in the \otext{tutorial/}
908 directory in the files \otext{5S\_rRNA.c.cm}, and
909 \otext{Cobalamin.c.cm}. These files were created using \prog{cmbuild}
910 and \prog{cmcalibrate} from the Rfam 10.1 seed alignments for 5S\_rRNA
911 (RF00001) and Cobalamin (RF00174), provided in
912 \otext{tutorial/5S\_rRNA.sto} and \otext{tutorial/Cobalamin.sto}. The
913 third model is the tRNA model from earlier in the tutorial
914 (\otext{tRNA5.c.cm}). Feel free to build and calibrate these
915 models yourself if you'd like, but if you'd like to keep moving on
916 with the tutorial, use the pre-calibrated ones. To create the database,
917 simply concatenate the three provided files:
918
919 \user{cat tutorial/tRNA5.c.cm tutorial/5S\_rRNA.c.cm tutorial/Cobalamin.c.cm > minifam.cm}
920
921 \subsubsection{Step 2: compress and index the flatfile with cmpress}
922
923 The \prog{cmscan} program has to read a lot of CMs and their filter
924 HMMs in a hurry, and Infernal's ASCII flatfiles are bulky. To
925 accelerate this, \prog{cmscan} uses binary compression and indexing of
926 the flatfiles. To use \prog{cmscan}, you must first compress and
927 index your CM database with the \prog{cmpress} program:
928
929 \user{cmpress minifam.cm}
930
931 This will quickly produce:
932
933 \begin{sreoutput}
934 Working... done.
935 Pressed and indexed 3 CMs and p7 HMM filters (3 names and 2 accessions).
936 Covariance models and p7 filters pressed into binary file: minifam.cm.i1m
937 SSI index for binary covariance model file: minifam.cm.i1i
938 Optimized p7 filter profiles (MSV part) pressed into: minifam.cm.i1f
939 Optimized p7 filter profiles (remainder) pressed into: minifam.cm.i1p
940 \end{sreoutput}
941
942 and you'll see these four new binary files in the directory.
943
944 The \otext{tutorial} directory includes a copy of the
945 \otext{minifam.cm} file, which has already been pressed, so there
946 are example binary files \otext{tutorial/minifam.cm.i1\{m,i,f,p\}}
947 included in the tutorial.
948
949 Their format is ``proprietary'', which is an open source term of art
950 that means both ``We haven't found time to document them yet'' and ``We
951 still might decide to change them arbitrarily without telling you''.
952
953 \subsubsection{Step 3: search the CM database with cmscan}
954
955 Now we can analyze sequences using our CM database and
956 \prog{cmscan}.
957
958 For example, the file \otext{tutorial/metag-example.fa} includes 3
959 sequences (whole genome shotgun sequencing reads) derived from samples
960 of ``whale fall'' carcasses in a metagenomics study
961 \citep{Tringe05}. These three sequences were chosen from the roughly
962 200,000 in the complete dataset because they include statistically
963 significant hits to the three models in our toy CM database.
964
965 To scan the sequences with our database:
966
967 \user{cmscan minifam.cm tutorial/metag-example.fa}
968
969 The header and the first section of the output will look like:
970
971 \begin{sreoutput}
972 # cmscan :: search sequence(s) against a CM database
973 # INFERNAL 1.1.5 (Sep 2023)
974 # Copyright (C) 2023 Howard Hughes Medical Institute.
975 # Freely distributed under the BSD open source license.
976 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
977 # query sequence file: tutorial/metag-example.fa
978 # target CM database: minifam.cm
979 # number of worker threads: 4
980 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
981
982 Query: AAGA01015927.1 [L=943]
983 Description: Metagenome sequence AHAI1002.g1, whole genome shotgun sequence
984 Hit scores:
985 rank E-value score bias modelname start end mdl trunc gc description
986 ---- --------- ------ ----- --------- ------ ------ --- ----- ---- -----------
987 (1) ! 1.5e-23 92.7 0.0 5S_rRNA 59 174 + cm no 0.66 5S ribosomal RNA
988 (2) ! 9.6e-19 62.4 0.0 tRNA5 229 302 + cm no 0.62 -
989 (3) ! 6.1e-16 53.5 0.0 tRNA5 314 386 + cm no 0.59 -
990 \end{sreoutput}
991
992 \prog{cmscan} has identified three putative RNAs in the first query
993 sequence, one 5S rRNA and two tRNAs. The output fields are in the
994 same order and have the same meaning as in \prog{cmsearch}'s output.
995
996 Before we move on, this is a good opportunity to point out an
997 important difference between \prog{cmsearch} and \prog{cmscan} related
998 to the size of the search space (often referred to in the code and in
999 this guide as the $Z$ parameter). The size of the search space for
1000 \prog{cmscan} is double the length of the current (single) query
1001 sequence (doubled because we're searching both strands) multiplied by
1002 the number of models in the CM database (here, 3; for a Rfam search,
1003 on the order of 1000). Because each query sequence is probably a
1004 different size this means $Z$ changes for each query sequence. In
1005 \prog{cmsearch}, the size of the search space is double the summed
1006 length of all sequences in the database (again, doubled because both
1007 strands are searched). This means that E-values may differ even for
1008 the same individual CM vs. sequence comparison, depending on how you
1009 do the search. The search space size also affects what filter
1010 thresholds \prog{cmsearch} or \prog{cmscan} will use, which is
1011 discussed more in section~\ref{section:pipeline}.
1012
1013 Now back to the \prog{cmscan} results. What follows the ranked list of
1014 three hits are the hit alignments. These are constructed and annotated
1015 the same as in \prog{cmsearch}. The 5S alignment is:
1016
1017 \begin{widesreoutput}
1018 v v v v v v v NC
1019 (((((((((,,,,<<-<<<<<---<<--<<<<<<_______>>-->>>>-->>---->>>>>-->><<<-<<----<-<<-----<<____>>-- CS
1020 5S_rRNA 1 ccuggcggcCAUAgcggggcggAaacACccGauCCCAUCCCGaACuCggAAguUAAGcgcccuagcgccgggguAGuAcuggGgUGgGuGAcCaC 95
1021 CCUGGC:G C UAGCG:GG:GG CACC:GA CCCAU CCG ACUC:GAAG AA+C:CC:UAGC CCG::G G:A: G+G GGGU CC C
1022 AAGA01015927.1 59 CCUGGCGGCCGUAGCGCGGUGGUCCCACCUGACCCCAUGCCGAACUCAGAAGUGAAACGCCGUAGCGCCGAUG--GUAGUGUG--GGGUCUCCCC 149
1023 *************************************************************************..********..********** PP
1024
1025 v v v NC
1026 --->>->->>->>>,))))))))): CS
1027 5S_rRNA 96 cUGggAaaccagguCgccgccaggc 120
1028 UG :A:A::AGG C:GCCAGGC
1029 AAGA01015927.1 150 AUGCGAGAGUAGGGAACUGCCAGGC 174
1030 ************************* PP
1031 \end{widesreoutput}
1032
1033 After the three sequences, you'll see a pipeline statistics summary
1034 report:
1035
1036 \newpage
1037
1038 \begin{widesreoutput}
1039 Internal CM pipeline statistics summary:
1040 ----------------------------------------
1041 Query sequence(s): 1 (1886 residues searched)
1042 Query sequences re-searched for truncated hits: 1 (834.7 residues re-searched, avg per model)
1043 Target model(s): 3 (382 consensus positions)
1044 Windows passing local HMM SSV filter: 20 (0.3992); expected (0.35)
1045 Windows passing local HMM Viterbi filter: (off)
1046 Windows passing local HMM Viterbi bias filter: (off)
1047 Windows passing local HMM Forward filter: 4 (0.07976); expected (0.02)
1048 Windows passing local HMM Forward bias filter: 4 (0.07976); expected (0.02)
1049 Windows passing glocal HMM Forward filter: 2 (0.06641); expected (0.02)
1050 Windows passing glocal HMM Forward bias filter: 2 (0.06641); expected (0.02)
1051 Envelopes passing glocal HMM envelope defn filter: 3 (0.03357); expected (0.02)
1052 Envelopes passing local CM CYK filter: 3 (0.03357); expected (0.0001)
1053 Total CM hits reported: 3 (0.03222); includes 0 truncated hit(s)
1054
1055 # CPU time: 0.02u 0.00s 00:00:00.02 Elapsed: 00:00:00.09
1056 //
1057 \end{widesreoutput}
1058
1059 This report is similar to the one you saw earlier from
1060 \prog{cmsearch}, but not identical. One big difference is that
1061 \prog{cmscan} will report a summary per query sequence, instead of per
1062 query model. In this case, the sequence was 943 residues long, so a
1063 % ^^^
1064 total of 1886 residues were searched, since both strands were
1065 % ^^^^
1066 examined. The next line reports that the average number of residues
1067 re-searched for truncated hits per model was 834.7. An average is
1068 % ^^^^^
1069 reported here because remember the number of residues re-searched per
1070 model depends on the expected maximum size of a hit, which varies per
1071 model, because only sequence terminii are examined for truncated hits
1072 (see ``Truncated RNA detection'' above and
1073 section~\ref{section:pipeline}). The remainder of the output is the
1074 same as in \prog{cmsearch} except that the fractional values are
1075 averages per model. For example, for all three models a total of 3
1076 envelopes survived the CYK filter stage, and those surviving envelopes
1077 contained 3.357\% of the target sequence \emph{on average per model}.
1078 % ^^^^^
1079
1080 You may have noticed that the expected survival fractions are
1081 different than they were in the \prog{cmsearch} example. This is
1082 because the P-value filter thresholds are set differently depending on
1083 the search space. For this example, the search space ($Z$) is roughly
1084 only 6 Kb (1886 residues in the query sequence multiplied by 3 target
1085 models), so the thresholds are set differently than for the
1086 \prog{cmsearch} example which had a search space size of roughly 6
1087 Mb. The exact thresholds used for various $Z$ values can be found in
1088 Table~\ref{tbl:thresholds} in section~\ref{section:pipeline}.
1089
1090 \subsubsection{Truncated hit and local end alignment example}
1091 Next, take a look at the \prog{cmscan} output for the second query
1092 sequence \otext{AAFY01022046.1}. The bottom strand of this sequence
1093 contains one hit to the Cobalamin riboswitch model, which is truncated
1094 at the 5' end. Here is the alignment:
1095
1096 \begin{widesreoutput}
1097 Hit alignments:
1098 >> Cobalamin Cobalamin riboswitch
1099 rank E-value score bias mdl mdl from mdl to seq from seq to acc trunc gc
1100 ---- --------- ------ ----- --- -------- -------- ----------- ----------- ---- ----- ----
1101 (1) ! 6.6e-09 29.9 0.0 cm 31 190 ~] 934 832 - ~. 0.92 5' 0.48
1102
1103 ??? v v v v ???? NC
1104 ~~~~~~______>>>,,,,,(((,,,<.<<<<_______>>>>>,,<<<____>>>,<<<---<<<<~~~~~~>>>>---->>>,,,,)))]]]] CS
1105 Cobalamin 1 <[30]*agucggggguuAAaaGGGAAc.ccGGUGcaAauCCgggGCuGcCCCCgCaACUGUAAgcGg*[61]*cCgcgAGCCAGGAGACCuGCCg 173
1106 + + G + AA: GGAA: : GGUG AAAUCC ::+C:G CCC C:ACUGUAA:C: :G:+AG+CAG A AC : C
1107 AAFY01022046.1 934 <[ 0]*GUAGGCAAAAGGAAGAGGAAGgAUGGUGGAAAUCCUUCACGGGCCCGGCCACUGUAACCAG*[ 4]*UUGGAAGUCAG-AUACUCUUCU 849
1108 ......44455677788899******9899***********************************96...7..69*********.9********* PP
1109
1110 ?? NC
1111 ]]::::::::::::::: CS
1112 Cobalamin 174 ucaaaaauaguaucacc 190
1113 +AA + G+A+C+ C
1114 AAFY01022046.1 848 AUUAAGGCGGAAACUAC 832
1115 ***************** PP
1116 \end{widesreoutput}
1117
1118 This alignment has some important differences with the ones we've seen
1119 so far because it is of a truncated hit. First, notice that the
1120 \otext{trunc} column reads \otext{5'} indicating that Infernal
1121 predicts the 5' end (beginning) of this Cobalamin riboswitch is
1122 missing. (Note that this hit is on the bottom (reverse) strand so the
1123 Cobalamin hit is actually predicted to extend past the end of the
1124 input sequence (past residue 934), but on the opposite strand.) The 5'
1125 % ^^^
1126 end of the alignment indicates this with special annotation: the
1127 \otext{<[30]*} in the model line indicates that the missing sequence
1128 % ^^
1129 is expected to align to the 30 5'-most positions of the Cobalamin
1130 % ^^
1131 model (i.e. about 30 residues are missing) and the first \otext{a}
1132 % ^^
1133 residue in this line corresponds to model position 31; the
1134 % ^^
1135 \otext{<[0]*} annotation in the sequence line indicates that there are
1136 no observed residues which align to those 31 positions and the first
1137 % ^^
1138 \otext{G} residue is at position 934 of the sequence, which is the
1139 % ^^^
1140 first position (on the opposite strand) of the query sequence. If,
1141 alternatively, this sequence was 3' truncated, or both 5' \emph{and}
1142 3' truncated, there would be analogous annotation at the 3' end of the
1143 alignment. Also notice the \verb+~]+ and \verb+~.+ symbols following
1144 the model and sequence coordinates, respectively. The \verb+~+
1145 leftmost symbol in both of these pairs indicate that this hit is
1146 truncated at the 5' end. To make sense of this alignment display, it
1147 may help to look at the \prog{cmalign} alignment of the same sequence
1148 to the same model on page~\pageref{cmalign-cobalamin}, which shows all
1149 model and sequence positions.
1150
1151 Truncated hit alignments also contain different annotation in the
1152 \otext{NC} lines. Instead of only containing blank spaces or \otext{v}
1153 characters indicating negative scoring noncanonical basepairs,
1154 \otext{?} characters are used to denote basepairs for which the other
1155 half is missing due to the truncation. For example, the second
1156 \otext{g} in the first model line corresponds to the right half of a
1157 basepair for which the left half is included in the stretch of 30 5'
1158 % ^^
1159 truncated model positions, so it is annotated with a \otext{?}. A
1160 \otext{?} is used because it is impossible to tell if such basepairs
1161 are negative scoring non-canonicals or not since we don't know the
1162 identity of the other half.
1163
1164 This hit alignment also demonstrates another type of annotation not
1165 yet seen in the previous examples, for \emph{local end}
1166 alignments. Notice the stretch of six \verb+~+ characters towards the
1167 end of the first \otext{CS} line, at the same position as the string
1168 \otext{*[61]*} in the model line immediately below. This indicates a a
1169 % ^^
1170 special type of alignment called a local end. Local ends occur when a
1171 large insertion or deletion is used in the optimal alignment at
1172 reduced penalty \citep{KleinEddy03} and allow Infernal to be tolerant
1173 of the insertion and/or deletion of RNA substructures not modeled by
1174 the CM. An example of how local ends enable remote homology detection
1175 in RNase P can be see in Figure~\ref{fig:bsu-alignment} on
1176 page~\pageref{fig:bsu-alignment}. In this case, 61 model positions are
1177 % ^^
1178 deleted and 4 residues are inserted in the sequence (indicated by
1179 % ^
1180 \otext{*[ 4]*} at the corresponding positions in the sequence line).
1181 % ^
1182 It is possible for zero sequence residues to be inserted by a local
1183 end, and for the number of residues inserted in a local end to exceed
1184 the number of model positions. Note that a single \otext{7} annotates
1185 % ^
1186 the posterior probability of the four sequence residues in the
1187 \otext{PP} line. This means that the average posterior probability for
1188 these four residues is between 65 and 75\%. If no sequence residues
1189 % ^^ ^^
1190 were in this EL, the \otext{PP} annotation would be a gap (\otext{.})
1191 character.
1192
1193 \subsection{Searching the Rfam CM database with a query sequence}
1194
1195 The Rfam database \url{http://rfam.xfam.org/} is a collection
1196 of RNA families, each represented by a CM and multiple sequence
1197 alignment used to build that CM. As of September 2023, the current release
1198 % ^^^^^^^^^^^^^^
1199 is 14.9, which includes 4108 families. The Rfam website allows
1200 web-based searches using \prog{cmscan} of the Rfam CM database against
1201 query sequences that the user can upload. Alternatively, you can perform
1202 the same searches by running \prog{cmscan} locally, as shown in this
1203 example. By searching all of Rfam with your sequence dataset, you will
1204 be annotating your dataset for most known types of structural RNAs
1205 with a single command.
1206
1207 To complete this step of the tutorial you'll need to download the Rfam
1208 14.9 CM file from here: \\
1209 \url{https://ftp.ebi.ac.uk/pub/databases/Rfam/14.9/Rfam.cm.gz}
1210 and gunzipping it, like this:
1211
1212 \user{curl -k -L -o Rfam.cm.gz https://ftp.ebi.ac.uk/pub/databases/Rfam/14.9/Rfam.cm.gz}
1213
1214 \user{gunzip Rfam.cm.gz}
1215
1216 Then, as in the previous example, you'll need to run \prog{cmpress} on
1217 this CM database:
1218
1219 \user{cmpress Rfam.cm}
1220
1221 The next step is to run \prog{cmscan}. In order to reproduce how Rfam
1222 searches are performed \citep{Nawrocki15} several command line
1223 options are required. Each of these options is explained below. The
1224 full command is (split up into two lines so it fits on the page):
1225
1226 \indent\indent\small\verb+> cmscan --rfam --cut_ga --nohmmonly --tblout mrum-genome.tblout --fmt 2 \+\\
1227 \indent\indent\small\verb+> --clanin tutorial/Rfam.14.9.clanin Rfam.cm tutorial/mrum-genome.fa > mrum-genome.cmscan+\\
1228
1229 This command will take at least several minutes and possibly up to
1230 about 30 minutes depending on the number of cores and speed of your
1231 computer.
1232
1233 The command line options used in the above command are as follows:
1234
1235 \begin{sreitems}{\emprog{--nohmmonly}}
1236 \item[\otext{--rfam}] Specifies that the filter pipeline run in fast
1237 mode, with the same strict filters that are used for Rfam searches
1238 and for other sequence databases larger than 20 Gb (see
1239 section~\ref{section:pipeline}).
1240 %
1241 \item[\otext{--cut\_ga}] Specifies that the special Rfam \emph{GA}
1242 (gathering) thresholds be used to determine which hits are
1243 reported. These thresholds are stored in the \prog{Rfam.cm} file.
1244 Each model has its own GA bit score threshold, which was determined
1245 by Rfam curators as the bit score at and above which all hits are
1246 believed to be true homologs to the model. These determinations were made based on
1247 observed hit results against the large Rfamseq database used by
1248 Rfam~\citep{Nawrocki15}.
1249 %
1250 \item[\otext{--nohmmonly}] All models, even those with zero basepairs,
1251 are run in CM mode (not HMM mode). This ensures all GA cutoffs, which were
1252 determined in CM mode for each model, are valid.
1253 %
1254 \item[\otext{--tblout}] Specifies that a tabular output
1255 file should be created, see section~\ref{section:tabular}.
1256 %
1257 \item[\otext{--fmt 2}] The tabular output file will be in format 2,
1258 which includes annotation of overlapping hits. See
1259 page~\pageref{tabular-format2} for a complete description of this
1260 format.
1261 %
1262 \item[\otext{--clanin}] Clan information should be read
1263 from the file \prog{tutorial/Rfam.14.9.claninfo}. This file lists
1264 which models belong to the same clan. Clans are groups of models
1265 that are homologous and therefore it is expected that some hits to
1266 these models will overlap. For example, the LSU\_rRNA\_archaea and
1267 LSU\_rRNA\_bacteria models are both in the same clan.
1268 %
1269 \end{sreitems}
1270
1271 When the \prog{cmscan} command finishes running, the file
1272 \prog{mrum-genome.cmscan} will contain the standard output of the
1273 program. This file will be similar to what we saw in the earlier example of
1274 \prog{cmscan}. The file \prog{mrum-genome.tblout} has also been
1275 created, which is a tabular representation of all hits, one line per
1276 hit. Take a look at this file. The first two lines are comment lines
1277 (prefixed with \prog{\#} characters) with the labels of each of the 27
1278 columns of data in the file. Each subsequent line has 27 space
1279 delimited tokens. The specific meaning of these tokens is described in
1280 detail in section~\ref{section:tabular}. Below I'm including the
1281 first 24 lines of the file, with columns 3-5, 7-9 and 13-16 removed
1282 (replaced with \prog{...}) so that the text will fit on this page:
1283
1284 \begin{tinysreoutput}
1285 #idx target name ... clan name ... seq from seq to strand ... score E-value inc olp anyidx afrct1 afrct2 winidx wfrct1 wfrct2 description of target
1286 #--- ---------------------- ... --------- ... -------- -------- ------ ... ------ --------- --- --- ------ ------ ------ ------ ------ ------ ---------------------
1287 1 LSU_rRNA_archaea ... CL00112 ... 762872 765862 + ... 2763.5 0 ! ^ - - - - - - Archaeal large sub...
1288 2 LSU_rRNA_archaea ... CL00112 ... 2041329 2038338 - ... 2755.0 0 ! ^ - - - - - - Archaeal large sub...
1289 3 LSU_rRNA_bacteria ... CL00112 ... 762874 765862 + ... 1872.9 0 ! = 1 1.000 0.999 " " " Bacterial large su...
1290 4 LSU_rRNA_bacteria ... CL00112 ... 2041327 2038338 - ... 1865.5 0 ! = 2 1.000 0.999 " " " Bacterial large su...
1291 5 LSU_rRNA_eukarya ... CL00112 ... 763018 765851 + ... 1581.3 0 ! = 1 1.000 0.948 " " " Eukaryotic large s...
1292 6 LSU_rRNA_eukarya ... CL00112 ... 2041183 2038349 - ... 1572.1 0 ! = 2 1.000 0.948 " " " Eukaryotic large s...
1293 7 SSU_rRNA_archaea ... CL00111 ... 2043361 2041888 - ... 1552.0 0 ! ^ - - - - - - Archaeal small sub...
1294 8 SSU_rRNA_archaea ... CL00111 ... 760878 762351 + ... 1546.5 0 ! ^ - - - - - - Archaeal small sub...
1295 9 SSU_rRNA_bacteria ... CL00111 ... 2043366 2041886 - ... 1161.9 0 ! = 7 0.995 1.000 " " " Bacterial small su...
1296 10 SSU_rRNA_bacteria ... CL00111 ... 760873 762353 + ... 1156.4 0 ! = 8 0.995 1.000 " " " Bacterial small su...
1297 11 SSU_rRNA_eukarya ... CL00111 ... 2043361 2041891 - ... 970.4 3e-289 ! = 7 1.000 0.998 " " " Eukaryotic small s...
1298 12 SSU_rRNA_eukarya ... CL00111 ... 760878 762348 + ... 963.8 3e-287 ! = 8 1.000 0.998 " " " Eukaryotic small s...
1299 13 SSU_rRNA_microsporidia ... CL00111 ... 2043361 2041891 - ... 919.9 2.3e-277 ! = 7 1.000 0.998 " " " Microsporidia small..
1300 14 SSU_rRNA_microsporidia ... CL00111 ... 760878 762348 + ... 917.2 1.6e-276 ! = 8 1.000 0.998 " " " Microsporidia small..
1301 15 RNaseP_arch ... CL00002 ... 2614544 2614262 - ... 184.9 3.4e-50 ! * - - - - - - Archaeal RNase P
1302 16 Archaea_SRP ... CL00003 ... 1064321 1064634 + ... 197.6 2.1e-45 ! * - - - - - - Archaeal signal re...
1303 17 FMN ... - ... 193975 193837 - ... 115.2 2.1e-24 ! * - - - - - - FMN riboswitch (RF...
1304 18 tRNA ... CL00001 ... 735136 735208 + ... 72.1 1.5e-12 ! * - - - - - - tRNA
1305 19 tRNA ... CL00001 ... 2350593 2350520 - ... 71.0 3e-12 ! * - - - - - - tRNA
1306 20 tRNA ... CL00001 ... 2680310 2680384 + ... 70.9 3.2e-12 ! * - - - - - - tRNA
1307 21 tRNA ... CL00001 ... 2351254 2351181 - ... 69.7 6.7e-12 ! * - - - - - - tRNA
1308 22 tRNA ... CL00001 ... 361676 361604 - ... 69.5 7.6e-12 ! * - - -
1309 \end{tinysreoutput}
1310
1311 This tabular format includes the target model name, sequence name (in
1312 column 3, which is omitted above to save space), clan name, sequence
1313 coordinates, bit score, E-value and more. Because the \prog{--fmt 2}
1314 option was used, this file includes information on which hits overlap
1315 with other hits, starting at the column labelled ``olp'' and ending
1316 with ``wfrct2''. Hits with the ``*'' character in the ``olp'' column
1317 do not overlap with any other hits. Those with ``\verb+^+'' do overlap with
1318 at least one other hit, but none of those overlapping hits have a
1319 better score (that occurs higher in the list). Those with ``='' also
1320 overlap with at least one other hit that does have a better score, the
1321 index of which is given in the ``anyidx'' column. For more detailed
1322 explanation of these columns, see page~\pageref{tabular-format2}.
1323
1324 The top two hits are both to the \prog{LSU\_rRNA\_archaea}
1325 model. These are the two copies of LSU rRNA in the
1326 \emph{Methanobrevibacter ruminantium} genome. Hits number 3 and 4
1327 % ^ ^
1328 are to the \prog{LSU\_rRNA\_bacteria} model and overlap with hits 1
1329 % ^
1330 and 2 nearly completely (hit 1 is from sequence positions 762872 to 765862 and
1331 % ^ ^ ^^^^^^ ^^^^^^
1332 hit 3 is from sequence positions 762874 to 765862). This overlap is not
1333 % ^ ^^^^^^ ^^^^^^
1334 surprising because the bacterial and archaeal LSU rRNA models are very
1335 similar, and so are assigning high scores to the same
1336 subsequences. Further, hit 5 is to \prog{LSU\_rRNA\_eukarya} and also
1337 % ^
1338 overlaps hits 1 and 3. Because these three LSU models are all expected
1339 % ^ ^
1340 to produce overlapping hits due to their homology, Rfam has grouped
1341 them into the same \emph{clan}, note the ``CL00112'' value in the ``clan
1342 % ^^^^^^^
1343 name'' column for all three hits. This clan information was provided
1344 in the \prog{rfam.14.9.claninfo} input file we provided to \prog{cmscan}
1345 by using the \prog{--clanin} option.
1346
1347 The ``olp'' column indicates that hit 1 is the highest scoring of the
1348 three overlapping hits because it contains the ``\verb+^+''
1349 character. Hits 3 and 5 both have ``='' in the ``olp'' column
1350 % ^ ^
1351 indicating that there is another hit to another model which overlaps
1352 these hits and has a better score.
1353
1354 If you were using these results to produce annotations for the
1355 \emph{Methanobrevibacter ruminantium} genome, you may want to ignore
1356 any hits that have higher scoring overlaps. To do this you can just
1357 remove any hits with ``='' in the ``olp'' column. Alternatively, you
1358 can have these hits not printed to the tabular output file by
1359 additionally providing the \prog{--oskip} option to \prog{cmscan}.
1360 You can also modify the overlap annotation behavior with
1361 \prog{--oclan} option which restricts the annotation of overlaps to
1362 hits for models within the same clan. Overlapping hits from models
1363 that are not in the same clan will not be marked as
1364 overlaps, instead they will marked as ``*'' in the ``olp'' field.
1365
1366 For more information on using Infernal for genome annotation see a
1367 similar example in the Rfam documentation
1368 (https://rfam.readthedocs.io/en/latest/genome-annotation.html)
1369
1370 \subsection{Creating multiple alignments with cmalign}
1371 The file \otext{tutorial/mrum-tRNAs10.fa} is a FASTA file containing
1372 the 10 tRNA hits above the inclusion threshold (with an E-value
1373 less than $0.01$) found by \prog{cmsearch} in our
1374 search of \emph{M. ruminantium} genome\footnote{The
1375 \otext{-A <f>} option to \prog{cmsearch} can be used to save a
1376 Stockholm formatted multiple alignment of all hits above the
1377 inclusion threshold to file \otext{<f>}.}
1378 To align these 10 sequences to our example tRNA model and make a multiple sequence
1379 alignment:
1380
1381 \user{cmalign tRNA5.cm tutorial/mrum-tRNAs10.fa}
1382
1383 The output of this is a Stockholm format multiple alignment file:
1384
1385 \begin{tinysreoutput}
1386 # STOCKHOLM 1.0
1387 #=GF AU Infernal 1.1.5
1388
1389 mrum-tRNA.1 GGAGCUAUAGCUCAAU..GGC..AGAGCGUUUGGCUGACAU........................................CCAAAAGGUUAUGGGUUCGAUUCCCUUUAGCCCCA
1390 #=GR mrum-tRNA.1 PP ****************..***..******************........................................***********************************
1391 mrum-tRNA.2 GGGCCCGUAGCUCAGU.uGGG..AGAGCGCUGCCCUUGCAA........................................GGCAGAGGCCCCGGGUUCAAAUCCCGGUGGGUCCA
1392 #=GR mrum-tRNA.2 PP ****************.****..******************........................................***********************************
1393 mrum-tRNA.3 GGGCCCAUAGCUUAGCcaGGU..AGAGCGCUCGGCUCAUAA........................................CCGGGAUGUCAUGGGUUCGAAUCCCAUUGGGCCCA
1394 #=GR mrum-tRNA.3 PP *********************..******************........................................***********************************
1395 mrum-tRNA.4 AGGCUAGUGGCACAGCcuGGU.cAGCGCGCACGGCUGAUAA........................................CCGUGAGGUCCUGGGUUCGAAUCCCAGCUAGCCUA
1396 #=GR mrum-tRNA.4 PP ***************999***.*******************........................................***********************************
1397 mrum-tRNA.5 CCCGACUUAGCUCAAUuuGGC..AGAGCGUUGGACUGUAGA........................................UCCAAAUGUUGCUGGUUCAAGUCCGGCAGUCGGGA
1398 #=GR mrum-tRNA.5 PP *********************..******************........................................***********************************
1399 mrum-tRNA.6 GCUUCUAUGGGGUAAU.cGGC.aAACCCAUCGGACUUUCGA........................................UCCGAUAA-UCCGGGUUCAAAUCCCGGUAGAAGCA
1400 #=GR mrum-tRNA.6 PP ****************.****.*******************........................................********.9*************************
1401 mrum-tRNA.7 GCUCCGAUGGUGUAGUccGGCcaAUCAUUUCGGCCUUUCGA........................................GCCGAAGA-CUCGGGUUCGAAUCCCGGUCGGAGCA
1402 #=GR mrum-tRNA.7 PP ********************9999*****************........................................********.**************************
1403 mrum-tRNA.8 GCGGUGUUAGUCCAGCcuGGU.uAAGACUCUAGCCUGCCAC........................................GUUAGAGA-CCCGGGUUCAAAUCCCGGACGCCGCA
1404 #=GR mrum-tRNA.8 PP ***************999***.*******************........................................********.**************************
1405 mrum-tRNA.9 GCCGGGGUGGCUCAGC.uGGU.uAGAGCGCACGGCUC----auaggguaacuaagcgugcucugacuuuuuuccugggauaCCGUGAGAUCGCGGGUUCGAAUCCCGCCCCCGGCA
1406 #=GR mrum-tRNA.9 PP ****************.****.************995....678************************************************************************
1407 mrum-tRNA.10 GGUUCUAUAGUUUAAC.aGGU..AAAACAACUGGCUGUUAA........................................CCGGCAGA-UAGGAGUUCGAAUCUUCUUAGAACCG
1408 #=GR mrum-tRNA.10 PP ****************.****..******************........................................********.9*************************
1409 #=GC SS_cons (((((((,,<<<<___..___.._>>>>,<<<<<_______~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>>>>,,,,,<<<<<_______>>>>>))))))):
1410 #=GC RF gCcggcAUAGcgcAgU..GGu..AgcgCgccagccUgucAa~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~gcuggAGgUCCgggGUUCGAUUCcccGUgccgGca
1411 //
1412 \end{tinysreoutput}
1413
1414 The first thing to notice here is that \prog{cmalign} uses both lower
1415 case and upper case residues, and it uses two different characters for
1416 gaps. This is because there are two different kinds of columns:
1417 ``match'' columns in which residues are assigned to match states and
1418 gaps are treated as deletions relative to consensus, and ``insert''
1419 columns where residues are assigned to insert states.
1420 In a match column, residues are upper case, and a '\otext{-}'
1421 character means a deletion relative to the consensus. In an insert
1422 column, residues are lower case, and a '\otext{.}' is padding. A '\otext{-}' deletion
1423 has a cost: transition probabilities were assessed, penalizing the
1424 transition into and out of a deletion. A '\otext{.}' pad has no cost per se;
1425 instead, the sequence(s) with insertions are paying transition
1426 probabilities into and out of their inserted residue.
1427
1428 Actually, there's two types of insert columns: standard insert columns
1429 where residues are assigned to insert states and less common ``local end''
1430 insertion columns where residues are assigned to a special local end
1431 state called the ``EL'' state. There is one EL state per model and it
1432 allows a CM to permit large insertions or deletions in the structure
1433 present in the alignment the model was built from, at a reduced
1434 cost. This can help Infernal detect remote homologs in some cases. We
1435 saw an example of this in our Cobalamin \prog{cmscan} hit
1436 above. Another example is shown in Figure~\ref{fig:bsu-alignment} on
1437 page~\pageref{fig:bsu-alignment}. Columns containing EL insertions are
1438 denoted in the \otext{\#=GC RF} annotation, described next.
1439
1440 Take a look at the final two lines of the alignment. The \otext{\#=GC
1441 RF} line is Stockholm-format \emph{reference coordinate annotation},
1442 with a residue marking each column that the CM considered to be
1443 consensus, a '\otext{.}' marking insert columns and a '\verb+~+'
1444 marking EL insert columns. For match columns, upper case residues
1445 denote strongly conserved columns, and lower case denotes weakly
1446 conserved ones. The \otext{\#=GC SS\_cons} line gives the consensus
1447 secondary structure of the model. The symbols here have the same
1448 meaning that they did in a pairwise alignment from \prog{cmsearch},
1449 for a detailed description see section~\ref{section:formats}. As in the
1450 RF annotation, EL columns are indicated by '\verb+~+'. In this
1451 alignment, \otext{mrum-tRNA.9} is the only sequence that uses the EL
1452 state.
1453
1454 Important: both standard and local end insertions in a CM are
1455 \emph{unaligned} (the same way that insertions are unaligned in
1456 profile HMM alignments produced by the HMMER package). Suppose one
1457 sequence has an insertion of length 10 and another has an insertion of
1458 length 2 in the same place in the model. The alignment will show ten
1459 insert columns, to accomodate the longest insertion. The residues of
1460 the shorter insertion are thrown down in an arbitrary order. (If you
1461 must know: by arbitrary Infernal convention, the insertion is divided
1462 in half; half is left-justified, and the other half is
1463 right-justified, leaving '.' characters in the middle.) Notice that
1464 in the previous paragraph I oh-so-carefully said residues are
1465 ``assigned'' to a state, not ``aligned''. For match states, assigned
1466 and aligned are the same thing: a one-to-one correspondence between a
1467 residue and a consensus match state in the model. But there may be one
1468 \emph{or more} residues assigned to the same insert state.
1469
1470 Don't be confused by the unaligned nature of CM insertions. You're
1471 sure to see cases where lower-case inserted residues are ``obviously
1472 misaligned''. This is just because Infernal isn't trying to ``align''
1473 them in the first place: it is assigning them to unaligned
1474 insertions. For example of an obvious misalignment look at sequences
1475 \otext{mrum-tRNA.6} and \otext{mrum-tRNA.8} in the above example
1476 alignment. The first inserted (lowercase) \otext{c} in
1477 \otext{mrum-tRNA.6} would be better aligned with respect to
1478 \otext{mrum-tRNA.8} if it were placed one position to the left.
1479
1480 Enough about the sequences in the alignment. Now notice all those
1481 \otext{PP} annotation lines. That's posterior probability annotation,
1482 as in the single sequence alignments that \prog{cmscan} and
1483 \prog{cmsearch} showed. This essentially represents the confidence
1484 that each residue is aligned where it should be.
1485
1486 Er, I mean, ``assigned'', not ``aligned''. The posterior probability
1487 assigned to an inserted residue is the probability that it is assigned
1488 to the insert state that corresponds to that column, or the EL state
1489 in the case of local end insertions. Because the same insert state
1490 might correspond to more than one column, the probability on an insert
1491 residue is \emph{not} the probability that it belongs in that
1492 particular column; again, where there's a choice of column for
1493 inserted residues, that choice is arbitrary.
1494
1495 \subsubsection{cmalign assumes sequences may be truncated}
1496 \prog{cmalign} assumes that input sequences may be truncated and uses
1497 specialized dynamic programming algorithms to align them appropriately
1498 based on that assumption. Importantly, output
1499 alignments from \prog{cmalign} do not indicate when sequences have
1500 been truncated, as those from \prog{cmsearch} and \prog{cmscan} do. As
1501 an example, use the \ccode{tutorial/Cobalamin.c.cm} model to align the
1502 truncated Cobalamin hit (in the file \ccode{tutorial/Cobalamin.fa})
1503 from the \prog{cmscan} example above (I've split up the alignment
1504 below so it will fit on the page):
1505
1506 \user{cmalign tutorial/Cobalamin.c.cm tutorial/Cobalamin.fa}
1507
1508 \label{cmalign-cobalamin}
1509 \begin{sreoutput}
1510 # STOCKHOLM 1.0
1511 #=GF AU Infernal 1.1.5
1512
1513 Cobalamin.1 ------------------------------GUAGGCAAAAGGAAGAGGAAGgAUGGUGGAAAUCCUUCACGGGCCCGGCCA
1514 #=GR Cobalamin.1 PP ..............................44455677788899******9899***************************
1515 #=GC SS_cons :::::::::::::::[[[[[[<<<____________>>>,,,,,(((,,,<.<<<<_______>>>>>,,<<<____>>>,
1516 #=GC RF uuaaauuauucuggugacGGUcccccuuaaagucagggguuAAaaGGGAAc.ccGGUGcaAauCCgggGCuGcCCCCgCaA
1517
1518
1519 Cobalamin.1 CUGUAACCAG---------------------------------auuu----------------------------UUGGAA
1520 #=GR Cobalamin.1 PP ********96.................................5789............................69****
1521 #=GC SS_cons <<<---<<<<------<<<<<<-----<<<-<<<<<<______~~~~>>>>>>--->>>>>>>>>---------->>>>--
1522 #=GC RF CUGUAAgcGggaagcaccccccaaaauGCCACUGgcccguaag~~~~ggcCGGGAAGGCggggggaagcgaugAccCgcgA
1523
1524
1525 Cobalamin.1 GUCAG-AUACUCUUCUAUUAAGGCGGAAACUAC
1526 #=GR Cobalamin.1 PP *****.9**************************
1527 #=GC SS_cons -->>>,,,,)))]]]]]]:::::::::::::::
1528 #=GC RF GCCAGGAGACCuGCCgucaaaaauaguaucacc
1529
1530 \end{sreoutput}
1531
1532 If you look back to the \prog{cmscan} hit alignment for this sequence,
1533 you'll notice that this looks a little different. Instead of the
1534 \otext{<[30]*} annotation in the model line indicating 30 model
1535 % ^^
1536 positions were missing due to a presumed 5' truncation, \prog{cmalign}
1537 includes those 30 positions, and their secondary structure
1538 % ^^
1539 annotation. The local end alignment annotation in the middle of the
1540 second line is different too. In the \prog{cmscan} hit alignment the
1541 model line included \otext{*[61]*} indicating that 61 model positions
1542 % ^^ ^^
1543 were skipped to a local end insertion. In the \prog{cmalign} output
1544 those 61 positions are included, aligned to gaps in the sequence.
1545 % ^^
1546 \prog{cmalign} also shows the identity of the four inserted residues
1547 in the EL state, and annotates each with a posterior probability,
1548 whereas \prog{cmscan} only indicated the number of inserted EL
1549 residues and their average posterior probability.
1550
1551 If you examine the \prog{cmscan} and \prog{cmalign} alignments closely
1552 you'll notice that they are identical (the same sequence residues are
1553 aligned to the same model positions in each) and include identical
1554 posterior probability annotation. While this will be the case for the
1555 large majority of sequences, it is not guaranteed by Infernal, and
1556 sometimes a \prog{cmsearch} or \prog{cmscan} alignment of a hit will
1557 differ from a \prog{cmalign} alignment of the same hit. There are
1558 several technical reasons for this, including the fact that the HMM
1559 band constraints used by \prog{cmalign} can differ from those used by
1560 \prog{cmsearch} and \prog{cmscan} which in rare cases can lead to a
1561 different alignment or different posterior probabilities. Another
1562 reason is that while \prog{cmalign} always assumes a sequence may be
1563 5' or 3' truncated, \prog{cmsearch} and \prog{cmscan} only allow
1564 certain types of truncation (5', 3' or both) at sequence
1565 terminii. The types of truncated alignment allowed modify the
1566 dynamic programming alignment algorithm, so this difference can also
1567 result in different alignments. However, most of the time the
1568 alignments will be identical, and when they are different they will
1569 usually only be slightly different.
1570
1571 \subsection{Searching a sequence database for RNAs with unknown or no
1572 secondary structure}
1573
1574 Some functional RNAs, including many types of small nucleolar RNAs
1575 (snoRNAs) do not conserve a secondary structure. It is more
1576 appropriate to model such RNA families with a profile HMM than a CM,
1577 because CMs only differ from profile HMMs in their modeling of
1578 basepairs and because profile HMM scoring algorithms are more
1579 efficient than CM ones.
1580
1581 Likewise, profile HMMs are more appropriate than CMs for modeling RNAs
1582 of unknown structure. For such RNAs, a profile HMM search may reveal
1583 additional homologs that can help elucidate the conserved structure
1584 for the family, if there is one. Given the multiple homologs, you can
1585 use other programs like RNAalifold~\citep{Bernhart08,Hofacker02} or
1586 Locarna~\citep{Will12} to try to predict the conserved secondary
1587 structure of a collection of homologous RNAs. Currently, Infernal
1588 itself does not have the capability of predicting structure, but it's
1589 predecessor COVE did with the \prog{covet} program, still available at
1590 \url{eddylab.org/software/cove/cove.tar.Z}.
1591
1592 Infernal automatically detects when a model has zero basepairs and
1593 uses efficient profile HMM algorithms in \prog{cmsearch} and
1594 \prog{cmscan}. As an example, let's revisit the construction of our
1595 tRNA model but pretend that we do not know the conserved cloverlear
1596 structure of tRNA. The file
1597 \otext{tutorial/tRNA5-noss.sto} is identical to the file
1598 \otext{tutorial/tRNA5.sto} except that it does not contain consensus
1599 secondary structure annotation.
1600 To build a structureless tRNA model from this alignment, execute:
1601
1602 \user{cmbuild --noss tRNA5-noss.cm tutorial/tRNA5-noss.sto}
1603
1604 The \otext{--noss} option is required when the alignment file lacks
1605 structure annotation. By forcing the use of \otext{--noss} we're
1606 forcing the user to realize that having no secondary structure is a
1607 special case for Infernal.
1608
1609 The output will be similar to be the earlier example, but not
1610 identical:
1611
1612 \begin{sreoutput}
1613 # cmbuild :: covariance model construction from multiple sequence alignments
1614 # INFERNAL 1.1.5 (Sep 2023)
1615 # Copyright (C) 2023 Howard Hughes Medical Institute.
1616 # Freely distributed under the BSD open source license.
1617 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1618 # CM file: tRNA5-noss.cm
1619 # alignment file: tutorial/tRNA5-noss.sto
1620 # ignore secondary structure, if any: yes
1621 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1622 # rel entropy
1623 # -----------
1624 # idx name nseq eff_nseq alen clen bps bifs CM HMM description
1625 # ------ -------------------- -------- -------- ------ ----- ---- ---- ----- ----- -----------
1626 1 tRNA5-noss 5 5.00 74 72 0 0 0.552 0.552
1627 #
1628 # CPU time: 0.05u 0.00s 00:00:00.05 Elapsed: 00:00:00.06
1629 \end{sreoutput}
1630
1631 The output reports that this model has 0 basepairs (``bps'') (the
1632 earlier example had 21) and that the CM relative entropy is different
1633 from before because basepairs have been ignored. Now the CM and HMM
1634 relative entropy are identical, because the CM can be mirrored nearly
1635 identically by a profile HMM.
1636
1637 Remember that after we built our tRNA CM with structure above, we
1638 needed to use \prog{cmcalibrate} to calibrate the model before we
1639 could perform searches. Importantly, zero basepair models do not need
1640 to be calibrated prior to running \prog{cmsearch}\footnote{Zero
1641 basepair models do need to be calibrated before they can be used
1642 with \prog{cmscan} however.}, so we can skip that step here.
1643
1644 Now, let's repeat the search of the \emph{M. ruminantium} genome but
1645 using our structureless tRNA model:
1646
1647 \user{cmsearch tRNA5-noss.cm tutorial/mrum-genome.fa}\\
1648
1649 This search is faster than the first one because only profile HMM
1650 algorithms are used this time around. Take a look at the list of hits:
1651
1652 \begin{sreoutput}
1653 rank E-value score bias sequence start end mdl trunc gc description
1654 ---- --------- ------ ----- ----------- ------- ------- --- ----- ---- -----------
1655 (1) ! 3.8e-09 38.2 0.0 NC_013790.1 362022 361960 - hmm - 0.46 Methanobrevibacter rumi ...
1656 (2) ! 3.1e-07 32.1 0.0 NC_013790.1 762496 762559 + hmm - 0.64 Methanobrevibacter rumi ...
1657 (3) ! 3.1e-07 32.1 0.0 NC_013790.1 2041698 2041635 - hmm - 0.64 Methanobrevibacter rumi ...
1658 (4) ! 4.9e-06 28.4 0.0 NC_013790.1 2585264 2585203 - hmm - 0.56 Methanobrevibacter rumi ...
1659 (5) ! 6.2e-06 28.0 0.0 NC_013790.1 735143 735198 + hmm - 0.59 Methanobrevibacter rumi ...
1660 (6) ! 7e-06 27.9 0.0 NC_013790.1 2351247 2351188 - hmm - 0.57 Methanobrevibacter rumi ...
1661 (7) ! 1.2e-05 27.2 0.0 NC_013790.1 662193 662251 + hmm - 0.64 Methanobrevibacter rumi ...
1662 (8) ! 1.2e-05 27.1 0.0 NC_013790.1 2186009 2185951 - hmm - 0.51 Methanobrevibacter rumi ...
1663 (9) ! 4.4e-05 25.4 0.0 NC_013790.1 2585183 2585118 - hmm - 0.56 Methanobrevibacter rumi ...
1664 (10) ! 6.6e-05 24.8 0.0 NC_013790.1 1873882 1873820 - hmm - 0.63 Methanobrevibacter rumi ...
1665 (11) ! 0.00015 23.6 0.0 NC_013790.1 360882 360824 - hmm - 0.51 Methanobrevibacter rumi ...
1666 (12) ! 0.00061 21.7 0.0 NC_013790.1 361910 361851 - hmm - 0.38 Methanobrevibacter rumi ...
1667 (13) ! 0.00095 21.1 0.0 NC_013790.1 2350586 2350528 - hmm - 0.58 Methanobrevibacter rumi ...
1668 (14) ! 0.0018 20.3 0.0 NC_013790.1 995341 995267 - hmm - 0.51 Methanobrevibacter rumi ...
1669 (15) ! 0.0027 19.7 0.0 NC_013790.1 97728 97788 + hmm - 0.49 Methanobrevibacter rumi ...
1670 (16) ! 0.0029 19.6 0.0 NC_013790.1 2186083 2186024 - hmm - 0.50 Methanobrevibacter rumi ...
1671 (17) ! 0.0032 19.5 0.0 NC_013790.1 2130421 2130351 - hmm - 0.59 Methanobrevibacter rumi ...
1672 (18) ! 0.0047 19.0 0.0 NC_013790.1 360727 360670 - hmm - 0.43 Methanobrevibacter rumi ...
1673 (19) ! 0.0058 18.7 0.0 NC_013790.1 1160527 1160608 + hmm - 0.59 Methanobrevibacter rumi ...
1674 (20) ! 0.0077 18.3 0.0 NC_013790.1 361056 360994 - hmm - 0.40 Methanobrevibacter rumi ...
1675 ------ inclusion threshold ------
1676 (21) ? 0.012 17.7 0.0 NC_013790.1 2151679 2151737 + hmm - 0.56 Methanobrevibacter rumi ...
1677 (22) ? 0.019 17.0 0.0 NC_013790.1 2327123 2327043 - hmm - 0.62 Methanobrevibacter rumi ...
1678 (23) ? 0.025 16.7 0.0 NC_013790.1 360973 360920 - hmm - 0.54 Methanobrevibacter rumi ...
1679 (24) ? 0.038 16.1 0.0 NC_013790.1 2350982 2350919 - hmm - 0.50 Methanobrevibacter rumi ...
1680 (25) ? 0.039 16.0 0.0 NC_013790.1 361671 361606 - hmm - 0.50 Methanobrevibacter rumi ...
1681 (26) ? 0.039 16.0 0.0 NC_013790.1 2680176 2680227 + hmm - 0.62 Methanobrevibacter rumi ...
1682 (27) ? 0.062 15.4 0.0 NC_013790.1 1064778 1064857 + hmm - 0.62 Methanobrevibacter rumi ...
1683 (28) ? 0.062 15.4 0.0 NC_013790.1 362793 362738 - hmm - 0.46 Methanobrevibacter rumi ...
1684 (29) ? 0.064 15.4 0.0 NC_013790.1 2585067 2585000 - hmm - 0.59 Methanobrevibacter rumi ...
1685 (30) ? 0.073 15.2 0.0 NC_013790.1 2749938 2749884 - hmm - 0.47 Methanobrevibacter rumi ...
1686 (31) ? 0.074 15.2 0.0 NC_013790.1 2749832 2749778 - hmm - 0.47 Methanobrevibacter rumi ...
1687 (32) ? 0.13 14.4 0.0 NC_013790.1 361729 361689 - hmm - 0.56 Methanobrevibacter rumi ...
1688 (33) ? 1.3 11.2 0.0 NC_013790.1 361439 361393 - hmm - 0.49 Methanobrevibacter rumi ...
1689 (34) ? 4.4 9.6 0.0 NC_013790.1 2583867 2583803 - hmm - 0.49 Methanobrevibacter rumi ...
1690 (35) ? 6 9.1 0.0 NC_013790.1 546054 546021 - hmm - 0.68 Methanobrevibacter rumi ...
1691 \end{sreoutput}
1692
1693 Note that this time we only find 35 hits (20 with E-values less than
1694 the inclusion threshold of 0.01) compared to 56 (with 54 less than
1695 0.01) in the original search with the structure-based CM. The
1696 increased sensitivity in the initial CM search exemplifies the
1697 additional power that comes with knowledge of the conserved secondary
1698 structure. Not all RNAs will show such a dramatic difference
1699 though. In fact, tRNA is a particularly strong example of the power of
1700 CMs versus sequence-only based methods like HMMs because about as much
1701 statistical signal is present in their structure as in their primary
1702 sequence. Many structural RNAs contain significantly less information
1703 in their structure than in sequence conservation, but many include 10
1704 bits or more of information in their structure. An additional 10 bits
1705 roughly translates into lowering the expected statistical significance
1706 of homologs detected in database searches by about 3 orders or
1707 magnitude\footnote{For a graph showing the relative amount of
1708 information in structure for sequence for many different types of RNAs
1709 see Figure 1.9 of \citep{Nawrocki09}}.
1710
1711 HMM hit alignments differ slightly from CM hit alignments. Take a look
1712 at the first alignment:
1713
1714 \begin{sreoutput}
1715 >> NC_013790.1 Methanobrevibacter ruminantium M1 chromosome, complete genome
1716 rank E-value score bias mdl mdl from mdl to seq from seq to acc trunc gc
1717 ---- --------- ------ ----- --- -------- -------- ----------- ----------- ---- ----- ----
1718 (1) ! 3.8e-09 38.2 0.0 hmm 5 67 .. 362022 361960 - .. 0.93 - 0.46
1719
1720 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: CS
1721 tRNA5-noss 5 auAUaGcgcAGUGGuAGcGCGgcagccUgucaauguggAGGUCCuggGUUCGAUUCccaGUgu 67
1722 uAUaGc+cA+UGG AG+GCG g cUg ca + AGGU uggGUUCGAUUCcc U+
1723 NC_013790.1 362022 CUAUAGCUCAAUGGCAGAGCGUUUGGCUGACAUCCAAAAGGUUAUGGGUUCGAUUCCCUUUAG 361960
1724 689******************************************************988876 PP
1725 \end{sreoutput}
1726
1727 First, note that the \otext{mdl} field reads \otext{hmm} instead of
1728 \otext{cm}. Also, because HMMs do not model basepairs, there is no
1729 \otext{NC} annotation pointing out negative scoring noncanonical
1730 basepairs.
1731
1732 If you were to look at more hits you may notice that HMM hits are
1733 more likely to not be full length than CM hits are. This hit, for
1734 example, begins at model position 5 and ends at model position 67,
1735 % ^ ^^
1736 whereas our earlier CM search included a full length alignment from
1737 model position 1 to 72 for the same region of the genome. The profile
1738 % ^ ^^
1739 HMMs used in Infernal allow local alignments that begin and end at any
1740 position in the model, with an equal score given for all possible
1741 start and end positions (this is the same local alignment strategy
1742 used in HMMER3~\citep{Eddy08}). In contrast, the CM local alignment
1743 strategy used by Infernal encourages global alignments by enforcing a
1744 score penalty for local ones. Partly because CM and HMM alignments
1745 differ in this way, ``truncated'' HMM hits can start and end anywhere
1746 in the target sequence (instead of being identified only with
1747 specialized algorithms only at sequence ends like a CM), and so the
1748 \otext{trunc} field is invalid for HMM hits and will always read
1749 ``\otext{-}''.
1750
1751 In \prog{cmscan}, HMM algorithms will be used to compute alignments
1752 for all models in the CM database that contain zero basepairs, and CM
1753 algorithms will be used for all others. Hits found with the HMM will
1754 be annotated like this example above, while CM hits will be annotated
1755 like the earlier CM examples.
1756
1757 By default, Infernal uses HMM algorithms for models with zero
1758 basepairs, mainly because they are more efficient. If you'd like, you
1759 can force the use of CM algorithms for such models with the
1760 \otext{--nohmmonly} option with \prog{cmsearch} or \prog{cmscan}. Using
1761 \otext{--nohmmonly} will encourage more full length hits, but will
1762 cause the program to run a few-fold slower, and also requires that the
1763 CM be calibrated with \prog{cmcalibrate} first.
1764
1765 \subsection{Forcing global CM alignment with the -g option}
1766
1767 By default, \prog{cmsearch}, \prog{cmscan} and \prog{cmalign} allow
1768 local \emph{or} global alignments between the sequence and the
1769 model. This allows an alignment to use what's called a ``local begin''
1770 and start at any match position in the model and to use what's called
1771 a ``local end'' to prematurely exit a section of the model to handle
1772 large insertions or deletions of the model structure and potentially
1773 insert nonhomologous residues into the alignment (these were the
1774 \verb+~+ annotated residues in the \prog{cmscan} and \prog{cmalign}
1775 examples above). Local alignments are permitted by default, because
1776 our internal benchmarks suggest this strategy is more sensitive for
1777 remote homology detection. (An example of a local RNase P alignment is
1778 demonstrated in Figure~\ref{fig:bsu-alignment} on
1779 page~\pageref{fig:bsu-alignment} of this guide.)
1780 However, some users may wish to turn off local alignment. This can be
1781 done using the \otext{-g} option to \prog{cmsearch}, \prog{cmscan},
1782 and \prog{cmalign}. The use of local mode by default in \prog{cmalign}
1783 is new to version 1.1 - all previous versions used global alignment by
1784 default. Importantly, using \otext{-g} does not turn off truncated hit
1785 detection and alignment; to do that use \otext{--notrunc}.
1786
1787 \subsection{Specifying and annotating match positions with cmbuild --hand}
1788
1789 When \prog{cmbuild} constructs a model from an input alignment it must
1790 decide which columns of the input alignment to define as match (also
1791 called ``consensus'') and insert columns. To do this, it first
1792 computes weights for each sequences using an \emph{ad hoc} algorithm
1793 to downweight closely related sequences and upweight distantly related
1794 ones. Then, for each position, the sum of the weights of the sequences
1795 that include a residue at the position is computed. If this sum is at
1796 least half the total number of sequences then the position is defined
1797 as a match position, else it is an insert position. If you're curious
1798 which positions get annotated as match versus insert in your
1799 alignment, use the \otext{-O <f>} option with \prog{cmbuild}, which
1800 will save a annotated version of your input alignment to file
1801 \otext{<f>}, including the weights of each sequence. In this output
1802 alignment, positions with residues in the \otext{\#=GC RF} lines of
1803 the alignment are match positions, and positions with gap characters
1804 are inserts.
1805
1806 Sometimes you may want to override this automated behavior by
1807 specifying which columns be defined as match/insert, especially if
1808 you've painstakingly created your alignment by hand. You can do this
1809 with the \otext{--hand} option\footnote{This is the same option as
1810 \otext{--rf} from previous versions of Infernal.}. Using this option
1811 you can also define a character to annotate each match position, which
1812 will be propagated to alignment output. In this section we'll go
1813 through an example of using \otext{--hand} with the 5 sequence tRNA
1814 alignment from earlier in the tutorial.
1815
1816 Take a look at the file \otext{tutorial/tRNA5-hand.sto}:
1817
1818 \vspace{1em}
1819 \begin{minipage}{4.0in}
1820 \begin{sreoutput}[xleftmargin=0em]
1821 # STOCKHOLM 1.0
1822
1823 tRNA1 GCGGAUUUAGCUCAGUUGGG.AGAGCGCCAGACUGAAGAUCUGGAGGUCC
1824 tRNA2 UCCGAUAUAGUGUAAC.GGCUAUCACAUCACGCUUUCACCGUGGAGA.CC
1825 tRNA3 UCCGUGAUAGUUUAAU.GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA.UC
1826 tRNA4 GCUCGUAUGGCGCAGU.GGU.AGCGCAGCAGAUUGCAAAUCUGUUGGUCC
1827 tRNA5 GGGCACAUGGCGCAGUUGGU.AGCGCGCUUCCCUUGCAAGGAAGAGGUCA
1828 #=GC SS_cons <<<<<<<..<<<<.........>>>>.<<<<<.......>>>>>.....<
1829 #=GC RF [accep]======[=Dloop=]============acd=======[vlp]=
1830
1831 tRNA1 UGUGUUCGAUCCACAGAAUUCGCA
1832 tRNA2 GGGGUUCGACUCCCCGUAUCGGAG
1833 tRNA3 GGGGUUCAAUUCCCCGUCGCGGAG
1834 tRNA4 UUAGUUCGAUCCUGAGUGCGAGCU
1835 tRNA5 UCGGUUCGAUUCCGGUUGCGUCCA
1836 #=GC SS_cons <<<<.......>>>>>>>>>>>>.
1837 #=GC RF ====[Tloop]=====[accep]=
1838 //
1839 \end{sreoutput}
1840 \end{minipage}
1841 \begin{minipage}{1.5in}
1842 \includegraphics[scale=0.4]{Figures/trna1-DF6280-hand}
1843 \end{minipage}
1844 \vspace{1em}
1845
1846 This file is the same as \otext{tutorial/tRNA5.sto} except for the two
1847 additional lines beginning with \otext{\#=GC RF}. This RF (reference)
1848 annotation is required for using \otext{--hand}. When \otext{--hand}
1849 is used, any non-gap character in the reference annotation will be
1850 assigned as a match (consensus) position. Importantly, four different
1851 characters are considered gaps: dashes (\otext{-}), underscores
1852 (\otext{\_}), dots (\otext{.}) and tildes (\verb+~+). In this example
1853 alignment, all columns are non-gap characters, so all columns will be
1854 considered match positions.
1855
1856 Different regions of the secondary structure have been marked up using
1857 abbreviations for the names of the regions in the reference
1858 annotation. For example, \otext{acd} annotates the three positions of
1859 the anticodon, and \otext{[vlp]} annotates the so-called variable
1860 loop. I've used \otext{[} and \otext{]} to indicate region boundaries
1861 in some cases. Crucially, I've avoided the use of any gap characters
1862 for positions between named regions which I still want to be
1863 considered match positions, and opted to use \otext{=} (which is not
1864 considered a gap by \prog{cmbuild}) for these positions.
1865
1866 To build the hand-specified model from this alignment, do:
1867
1868 \user{cmbuild --hand tRNA5-hand.cm tutorial/tRNA5-hand.sto}
1869
1870 \begin{sreoutput}
1871 # cmbuild :: covariance model construction from multiple sequence alignments
1872 # INFERNAL 1.1.5 (Sep 2023)
1873 # Copyright (C) 2023 Howard Hughes Medical Institute.
1874 # Freely distributed under the BSD open source license.
1875 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1876 # CM file: tRNA5-hand.cm
1877 # alignment file: tutorial/tRNA5-hand.sto
1878 # use #=GC RF annotation to define consensus columns: yes
1879 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1880 # rel entropy
1881 # -----------
1882 # idx name nseq eff_nseq alen clen bps bifs CM HMM description
1883 # ------ -------------------- -------- -------- ------ ----- ---- ---- ----- ----- -----------
1884 1 tRNA5-hand 5 3.59 74 74 21 2 0.763 0.476
1885 #
1886 # CPU time: 0.09u 0.00s 00:00:00.09 Elapsed: 00:00:00.10
1887 \end{sreoutput}
1888
1889 The output reports that the model now has 74 match (consensus)
1890 positions in the \otext{clen} column. If we had built this model
1891 without specifying \otext{--hand} (as we did earlier in this tutorial)
1892 the resulting model would have had only 72 consensus positions.
1893 (I've annotated the two extra match positions with three gaps in
1894 \otext{tRNA5.hand.sto} as match solely to demonstrate how
1895 \otext{--hand} works, not because I think it's better to model these
1896 positions as matches than inserts.)
1897
1898 Now, let's use this model to search the \emph{M. ruminantium} genome
1899 again. First, the model must be calibrated. To save time, a calibrated
1900 version of the file is in \otext{tutorial/tRNA5-hand.c.cm}. To do the
1901 search:
1902
1903 \user{cmsearch tutorial/tRNA5-hand.c.cm tutorial/mrum-genome.fa}
1904
1905 The results are very similar to the earlier search with the
1906 tRNA model built with default \prog{cmbuild} parameters (though not
1907 identical since the model now has two additional match positions). The
1908 important difference involves the hit alignments. Take a look at the
1909 alignment for hit number 46 as an illustrative example:
1910
1911 \newpage
1912
1913 \begin{widesreoutput}
1914 >> NC_013790.1 Methanobrevibacter ruminantium M1 chromosome, complete genome
1915 rank E-value score bias mdl mdl from mdl to seq from seq to acc trunc gc
1916 ---- --------- ------ ----- --- -------- -------- ----------- ----------- ---- ----- ----
1917 (46) ! 1.6e-09 43.2 0.0 cm 1 74 [] 995344 995263 - .. 0.90 no 0.49
1918
1919 v v NC
1920 (((((((,,<<<<________._>>>>,<<<<<_______>>>>>,,,........,,<<<<<_______>>>>>))))))): CS
1921 tRNA5-hand 1 gCcggcaUAGcgcAgUUGGuu.AgcgCgccagccUgucAagcuggAGg........UCCgggGUUCGAUUCcccGugccgGca 74
1922 :::G:CAUAGCG AG GGU+ A CGCG:CAG:CU +++A:CUG: G+ UC:GGGGUUCGA UCCCC:UG:C:::A
1923 NC_013790.1 995344 AGAGACAUAGCGAAGC-GGUCaAACGCGGCAGACUCAAGAUCUGUUGAuuaguucuUCAGGGGUUCGAAUCCCCUUGUCUCUA 995263
1924 ************9***.8886258***********************9444444445************************** PP
1925 [accep]======[=Dloop=.]============acd=======[vl........p]=====[Tloop]=====[accep]= RF
1926 \end{widesreoutput}
1927
1928 The reference annotation from the training alignment to \prog{cmbuild}
1929 has been propagated to the hit as an extra \otext{RF} line at the
1930 bottom of the alignment. All inserts in the alignment are annotated as
1931 \otext{.} columns in the RF annotation. Note that the variable loop
1932 (annotated as \otext{[vlp]} in the training alignment) contains 8
1933 inserted residues. The RF annotation will also be transferred to
1934 multiple alignments created with \prog{cmalign}.
1935
1936 \subsection{Building models from fragmentary sequences}
1937
1938 Sometimes sequences in the \prog{cmbuild} input alignment are sequence
1939 \emph{fragments} with missing data at the 5' or 3' ends. Gaps at the
1940 ends of fragments are treated as missing data by \prog{cmbuild}
1941 instead of as deletions. The definition of fragments can be important
1942 because if sequences have missing data at the end but are not
1943 defined as fragments then the parameters of the resulting model will
1944 incorrectly reflect that deletions are common at the beginning and/or end of the
1945 sequence. Such a model will be less specific for full length matches
1946 to the model. To build the best model from a given alignment, all sequences
1947 with missing data should be defined as fragments.
1948
1949 By default, \prog{cmbuild} will try to guess which sequences are
1950 fragments by defining any sequence which spans less than 0.5 fraction of the
1951 length of the input alignment as a fragment, but this
1952 fraction can be changed to \prog{<x>} with the \prog{--fragthresh <x>}
1953 option. There are two other ways to define fragments. If the
1954 alignment contains RF annotation like the example above, the
1955 \prog{--hand} and \prog{--fragnrfpos <n>} options can be used in
1956 combination to define a sequence as a fragment if it has more than
1957 \prog{<n>} terminal gaps in nongap RF positions at the 5' \emph{or} 3'
1958 ends. Finally, fragments can be defined manually in the input alignment
1959 using \verb+~+ characters at the ends of fragments as explained more below.
1960
1961 The following modified version of the tRNA alignment will help
1962 illustrate the different fragment definition options. It can be found in
1963 the file \prog{tutorial/tRNA5-hand.frag.sto}:
1964
1965 \begin{sreoutput}
1966 # STOCKHOLM 1.0
1967
1968 tRNA1 ................UGGG.AGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAG........
1969 tRNA2 UCCGAUAUAGUGUAAC.GGCUAUCACAUCACGCUUUCACCGUGGAGA.CCGGGGUUCGACUCCCCGUAUCGGAG
1970 tRNA3 UCCGUGAUAGUUUAAU.GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA.UCGGGGUUCAAUUCCCCGUCGCGGAG
1971 tRNA4 ....................................AAAUCUGUUGGUCCUUAGUUCGAU..............
1972 tRNA5 ..GCACAUGGCGCAGUUGGU.AGCGCGCUUCCCUUGCAAGGAAGAGGUCAUCGGUUCGAUUCCGGUUGCGUCCA
1973 #=GC SS_cons <<<<<<<..<<<<.........>>>>.<<<<<.......>>>>>.....<<<<<.......>>>>>>>>>>>>.
1974 #=GC RF [accep]======[=Dloop=]============acd=======[vlp]=====[Tloop]=====[accep]=
1975 //
1976 \end{sreoutput}
1977
1978 If this alignment is used as input to \prog{cmbuild} with the command:
1979
1980 \user{cmbuild -O tRNA-hand.O.stk tRNA-hand.frag.cm tutorial/tRNA5-hand.frag.sto}\\
1981
1982 then only the \prog{tRNA4} sequence will be defined as a fragment,
1983 because it spans positions $37$ to $60$ out of a total of $74$
1984 positions ($(60-37+1)/74 = 0.324$) which is less than the $0.5$
1985 threshold. The \prog{tRNA1} sequence spans positions $17$ to $66$ and
1986 so is above the threshold $((66-17+1)/74 = 0.676)$. Due to the \prog{-O}
1987 option above, \prog{cmbuild} saved the annotated alignment file to
1988 \prog{tRNA-hand.O.stk}. That file, shown below, indicates that \prog{tRNA4} is
1989 defined as a fragment with the \verb+~+ characters used for terminal gaps (also note that
1990 the RF annotation has been changed to the consensus sequence because
1991 \prog{--hand} was not used):
1992
1993 \newpage
1994
1995 \begin{sreoutput}
1996 # STOCKHOLM 1.0
1997 #=GF ID tRNA5-hand.frag
1998 #=GF AU Infernal 1.1.5
1999
2000 #=GS tRNA1 WT 0.89
2001 #=GS tRNA2 WT 1.00
2002 #=GS tRNA3 WT 1.08
2003 #=GS tRNA4 WT 0.86
2004 #=GS tRNA5 WT 1.17
2005
2006 tRNA1 ----------------uGGG-AGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAG--------
2007 tRNA2 UCCGAUAUAGUGUAAC.GGCUAUCACAUCACGCUUUCACCGUGGAGA-CCGGGGUUCGACUCCCCGUAUCGGAG
2008 tRNA3 UCCGUGAUAGUUUAAU.GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA-UCGGGGUUCAAUUCCCCGUCGCGGAG
2009 tRNA4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAAUCUGUUGGUCCUUAGUUCGAU~~~~~~~~~~~~~~
2010 tRNA5 --GCACAUGGCGCAGUuGGU-AGCGCGCUUCCCUUGCAAGGAAGAGGUCAUCGGUUCGAUUCCGGUUGCGUCCA
2011 #=GC SS_cons (((((((,,<<<<___._____>>>>,<<<<<_______>>>>>,,,,,<<<<<_______>>>>>))))))):
2012 #=GC RF UCcgacAUAGugcAAU.GGuuAgcaCGcccgcCUuucAagcgggAGgUCCgggGUUCGAUUCcccGUgucgGAg
2013 //
2014 \end{sreoutput}
2015
2016 Fragments can be defined differently if \prog{--hand} and
2017 \prog{--fragnrfpos 5} options are used, with the following command:
2018
2019 \begin{widesreoutput}
2020 > cmbuild --hand --fragnrfpos 5 -O tRNA-hand.O.2.stk tRNA-hand.frag2.cm tutorial/tRNA5-hand.frag.sto
2021 \end{widesreoutput}
2022
2023 In this case, both \prog{tRNA1} and \prog{tRNA4} sequences are defined as
2024 fragments because they include more than $5$ gaps in nongap RF positions
2025 at the 5' or 3' ends (in this case both ends). Again, the fragment
2026 definitions are indicated in the output alignment file
2027 \prog{tRNA-hand.O.2.stk}:
2028
2029 \begin{sreoutput}
2030 # STOCKHOLM 1.0
2031 #=GF ID tRNA5-hand.frag
2032 #=GF AU Infernal 1.1.5
2033
2034 #=GS tRNA1 WT 0.89
2035 #=GS tRNA2 WT 1.02
2036 #=GS tRNA3 WT 1.09
2037 #=GS tRNA4 WT 0.84
2038 #=GS tRNA5 WT 1.16
2039
2040 tRNA1 ~~~~~~~~~~~~~~~~UGGG-AGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAG~~~~~~~~
2041 tRNA2 UCCGAUAUAGUGUAAC-GGCUAUCACAUCACGCUUUCACCGUGGAGA-CCGGGGUUCGACUCCCCGUAUCGGAG
2042 tRNA3 UCCGUGAUAGUUUAAU-GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA-UCGGGGUUCAAUUCCCCGUCGCGGAG
2043 tRNA4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAAUCUGUUGGUCCUUAGUUCGAU~~~~~~~~~~~~~~
2044 tRNA5 --GCACAUGGCGCAGUUGGU-AGCGCGCUUCCCUUGCAAGGAAGAGGUCAUCGGUUCGAUUCCGGUUGCGUCCA
2045 #=GC SS_cons (((((((,,<<<<_________>>>>,<<<<<_______>>>>>,,,,,<<<<<_______>>>>>))))))):
2046 #=GC RF [accep]======[=Dloop=]============acd=======[vlp]=====[Tloop]=====[accep]=
2047 //
2048 \end{sreoutput}
2049
2050 Alternatively, if fragments are annotated in the input alignment, the
2051 \prog{--fraggiven} option can be used. The
2052 \prog{tutorial/tRNA5-hand.fraggiven.sto} shows an example with the \prog{tRNA1},
2053 \prog{tRNA2} and \prog{tRNA5} sequences all defined as fragments:
2054
2055 \begin{sreoutput}
2056 # STOCKHOLM 1.0
2057
2058 tRNA1 ~~~~~~~~~~~~~~~~UGGG.AGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAG~~~~~~~~
2059 tRNA2 UCCGAUAUAGUGUAAC.GGCUAUCACAUCACGCUUUCACCGUGGAGA.CCGGGGUUCGACUCCCCGUAUCGGAG
2060 tRNA3 UCCGUGAUAGUUUAAU.GGUCAGAAUGGGCGCUUGUCGCGUGCCAGA.UCGGGGUUCAAUUCCCCGUCGCGGAG
2061 tRNA4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAAUCUGUUGGUCCUUAGUUCGAU~~~~~~~~~~~~~~
2062 tRNA5 ~~GCACAUGGCGCAGUUGGU.AGCGCGCUUCCCUUGCAAGGAAGAGGUCAUCGGUUCGAUUCCGGUUGCGUCCA
2063 #=GC SS_cons <<<<<<<..<<<<.........>>>>.<<<<<.......>>>>>.....<<<<<.......>>>>>>>>>>>>.
2064 #=GC RF [accep]======[=Dloop=]============acd=======[vlp]=====[Tloop]=====[accep]=
2065 //
2066 \end{sreoutput}
2067
2068 The command to build a model using the fragment definitions in
2069 that alignment is:
2070
2071 \user{cmbuild --fraggiven tRNA-hand.fraggiven.cm tutorial/tRNA5-hand.fraggiven.sto}
2072
2073 To obtain alignments annotated with fragments with \verb+~+
2074 characters, you can either manually edit an existing alignment file,
2075 or generate alignments with the \prog{cmsearch} program using the
2076 \prog{-A} option, or the \prog{cmalign} program with the \prog{--miss}
2077 option which will have sequences inferred to have missing data
2078 annotated as fragments.
2079
2080 \subsection{Parallelizing calibration of large models by splitting
2081 into partitions}
2082
2083 For large models, like small and large subunit ribosomal RNA (SSU and
2084 LSU rRNA) models, the \prog{cmcalibrate} step can be extremely slow
2085 and require a large amount of memory. Parallelization with
2086 multithreading can help, but memory can still be limiting. For
2087 example, the eukaryotic LSU rRNA model from Rfam (RF02543) requires
2088 about 14Gb of RAM per thread and roughly 30 hours on 12 threads (so
2089 168Gb RAM total) for calibration\footnote{The \prog{--memreq} and
2090 \prog{--forecast} options to \prog{cmcalibrate} can be used to
2091 estimate the required memory and time, respectively.}. MPI
2092 parallelization is also implemented for \prog{cmcalibrate} but not all
2093 systems are set up to use it. If you have access to a compute farm or
2094 cluster, an alternative way to parallelize calibration is
2095 using the \prog{--split} and \prog{--merge} options introduced in
2096 version 1.1.5 which allow parallelization across different CPUs
2097 without using MPI by partitioning the calibration calculations. To use
2098 this method to parallelize calibration of a Cobalamin riboswitch CM
2099 in the file built from the \prog{tutorial/Cobalamin.sto} alignment, we
2100 first build the model with the command:
2101
2102 \user{cmbuild Cobalamin.cm tutorial/Cobalamin.sto}
2103
2104 Then the first step for the parallelized calibration is to create the
2105 script that will execute the calibration calculations for each partition:
2106
2107 \user{cmcalibrate --split --ptot 16 --cfile Cobalamin.cfile Cobalamin.cm}
2108
2109 This will result in the following output:
2110
2111 \begin{sreoutput}
2112 # cmcalibrate :: fit exponential tails for CM E-values
2113 # INFERNAL 1.1.5 (Sep 2023)
2114 # Copyright (C) 2023 Howard Hughes Medical Institute.
2115 # Freely distributed under the BSD open source license.
2116 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2117 # CM file: Cobalamin.cm
2118 # split mode: on
2119 # saving partition commands to file: Cobalamin.cfile
2120 # total number of partitions: 16
2121 # number of worker threads: 0
2122 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2123 # List of commands for each partition saved to file Cobalamin.cfile.
2124 #
2125 # Command to merge per-partition scores after all commands are finished:
2126 # src/cmcalibrate --merge --ptot 16 Cobalamin.cm
2127 #
2128 # CPU time: 0.00u 0.00s 00:00:00.00 Elapsed: 00:00:00.00
2129 [ok]
2130 \end{sreoutput}
2131
2132 And will have created the file \prog{Cobalamin.cfile} which will look
2133 like:
2134
2135 \begin{sreoutput}
2136 cmcalibrate --ptot 16 --part 1 --pfile Cobalamin.cm.calib.1 Cobalamin.cm
2137 cmcalibrate --ptot 16 --part 2 --pfile Cobalamin.cm.calib.2 Cobalamin.cm
2138 cmcalibrate --ptot 16 --part 3 --pfile Cobalamin.cm.calib.3 Cobalamin.cm
2139 cmcalibrate --ptot 16 --part 4 --pfile Cobalamin.cm.calib.4 Cobalamin.cm
2140 cmcalibrate --ptot 16 --part 5 --pfile Cobalamin.cm.calib.5 Cobalamin.cm
2141 cmcalibrate --ptot 16 --part 6 --pfile Cobalamin.cm.calib.6 Cobalamin.cm
2142 cmcalibrate --ptot 16 --part 7 --pfile Cobalamin.cm.calib.7 Cobalamin.cm
2143 cmcalibrate --ptot 16 --part 8 --pfile Cobalamin.cm.calib.8 Cobalamin.cm
2144 cmcalibrate --ptot 16 --part 9 --pfile Cobalamin.cm.calib.9 Cobalamin.cm
2145 cmcalibrate --ptot 16 --part 10 --pfile Cobalamin.cm.calib.10 Cobalamin.cm
2146 cmcalibrate --ptot 16 --part 11 --pfile Cobalamin.cm.calib.11 Cobalamin.cm
2147 cmcalibrate --ptot 16 --part 12 --pfile Cobalamin.cm.calib.12 Cobalamin.cm
2148 cmcalibrate --ptot 16 --part 13 --pfile Cobalamin.cm.calib.13 Cobalamin.cm
2149 cmcalibrate --ptot 16 --part 14 --pfile Cobalamin.cm.calib.14 Cobalamin.cm
2150 cmcalibrate --ptot 16 --part 15 --pfile Cobalamin.cm.calib.15 Cobalamin.cm
2151 cmcalibrate --ptot 16 --part 16 --pfile Cobalamin.cm.calib.16 Cobalamin.cm
2152 \end{sreoutput}
2153
2154 Alternatively, if the \prog{--cbash} option is added to the above
2155 command the \prog{Cobalamin.cfile} would be a more compact bash
2156 shell script with a for loop:
2157
2158 \begin{sreoutput}
2159 # !/bin/bash
2160 for ((i = 1; i <= 16; i++)); do
2161 cmcalibrate --ptot 16 --part $i --pfile Cobalamin.cm.calib.$i Cobalamin.cm
2162 done
2163 \end{sreoutput}
2164
2165 For this command, we specified that there by 16 partitions with the
2166 option \prog{--ptot 16}, but this number can be as high as
2167 160. This is because by default there are 160 10Kb sequences (1.6Mb
2168 total) searched during the calibration, so the minimal workunit is
2169 a search of a single 10Kb sequence. If the \prog{-L} option is used to
2170 modify the 1.6Mb total length, then the maximum allowed \prog{<n>}
2171 with \prog{--ptot <n>} will change accordingly (see the
2172 \prog{cmcalibrate} manual page in section 7 of this guide for more
2173 % ^hard-coded, careful
2174 details on \prog{cmcalibrate} options).
2175
2176 If you'd like to use additional options for the calibration, for
2177 example if you want to specify that each partition use only one thread
2178 with the \prog{--cpu 1} option, or run in non-threaded serial mode
2179 with \prog{--cpu 0}, perhaps to limit the required amount of RAM, you
2180 should specify those additional option in the original command above
2181 that includes \prog{--split} and they will be included in the
2182 partition commands in the \prog{Cobalamin.cfile} script.
2183
2184 The next step is to run these 16 commands. If you execute either of
2185 these scripts without modification, the 16 partition commands will run
2186 in serial, one after the other. This would not save any time or reduce
2187 memory requirement versus a standard \prog{cmcalibrate} command like
2188 those shown earlier in this tutorial. So for this approach to make any
2189 sense, you will need to modify the \prog{Cobalamin.cfile} file so that
2190 it will run on a compute cluster. For example, if you use Sun Grid
2191 Engine (SGE) and the program \prog{qsub} to submit jobs to a cluster,
2192 then you might modify the \prog{Cobalamin.cfile} file to something
2193 like:
2194
2195 \begin{sreoutput}
2196 # !/bin/bash
2197 for ((i = 1; i <= 16; i++)); do
2198 qsub -n Cobalamin.$i -V -o Cobalamin.$i.out -e Cobalamin.$i.err -m n \
2199 ``cmcalibrate --ptot 16 --part $i --pfile Cobalamin.cm.calib.$i Cobalamin.cm''
2200 done
2201 \end{sreoutput}
2202
2203 The modified script can then be used to submit all 16 jobs. When they
2204 are all finished the final step is to merge the results and update the
2205 CM file with the calibration statistics:
2206
2207 \user{cmcalibrate --merge --ptot 16 Cobalamin.cm}
2208
2209 After this, you will be able to use the \prog{cmsearch} and
2210 \prog{cmscan} with \prog{Cobalamin.cm}. The E-value-related statistics
2211 that are added to the \prog{Cobalamin.cm} file using this split/merge
2212 approach will be identical to those added with standard
2213 \prog{cmcalibrate} (unless the \prog{--seed <n>} option is used to
2214 change the seeding of the random number generator).
2215
2216 \subsubsection{Reading from a stdin pipe using - (dash) as a filename argument}
2217
2218 Generally, Infernal programs read their sequence and/or profile input
2219 from files. Unix power users often find it convenient to string an
2220 incantation of commands together with pipes (indeed, such wizardly
2221 incantations are a point of pride). For example, you might extract a
2222 subset of query sequences from a larger file using a one-liner
2223 combination of scripting commands (perl, awk, whatever). To facilitate
2224 the use of Infernal programs in such incantations, you can almost
2225 always use an argument of '-' (dash) in place of a filename, and the
2226 program will take its input from a standard input pipe instead of
2227 opening a file.
2228
2229 For example, the following three commands are entirely equivalent, and
2230 give essentially identical output:
2231
2232 \user{cmalign tRNA5.cm mrum-tRNAs10.fa}
2233
2234 \user{cat tRNA5.cm | ../src/cmalign - mrum-tRNAs10.fa}
2235
2236 \user{cat mrum-tRNAs10.fa | ../src/cmalign tRNA5.cm -}
2237
2238 Most Easel ``miniapp'' programs share the same ability of pipe-reading.
2239
2240 Because the programs for CM fetching (\prog{cmfetch}) and
2241 sequence fetching (\prog{esl-sfetch}) can fetch any number of profiles
2242 or (sub)sequences by names/accessions given in a list, \emph{and} these
2243 programs can also read these lists from a stdin pipe, you can craft
2244 incantations that generate subsets of queries or targets on the
2245 fly. For example, you can extract and align all hits found by
2246 \prog{cmsearch} with an E-value below the inclusion threshold as
2247 follows (using the \textbackslash character twice below to split up the final
2248 command onto three lines):
2249
2250 %note: can't use \user{} here because too many special characters
2251 %(believe me I tried). Only difference between \user{} and the way
2252 %I've done it below is that we're not bold, oh well.
2253 \indent\indent\small\verb+> cmsearch --tblout tRNA5.mrum-genome.tbl tRNA5.c.cm mrum-genome.fa+ \\
2254 \indent\indent\small\verb+> esl-sfetch --index mrum-genome.fa+ \\
2255 \indent\indent\small\verb+> cat tRNA5.mrum-genome.tbl | grep -v ^# | grep ! \ + \\
2256 \indent\indent\small\verb+> | awk '{ printf(``%s/%s-%s %s %s %s\n'', $1, $8, $9, $8, $9, $1); }' \ + \\
2257 \indent\indent\small\verb+> | esl-sfetch -Cf mrum-genome.fa - | cmalign tRNA5.cm - + \\
2258
2259 The first command performed the search using the CM file
2260 \ccode{tRNA5.c.cm} and sequence file \ccode{mrum-genome.fa} (these
2261 were used in the tutorial), and saved tabular output to
2262 \prog{tRNA5.mrum-genome.tbl}. The second command indexed the genome
2263 file to prepare it for fast (sub)sequence retrieval. In the third
2264 command we've extracted only those lines from
2265 \prog{tRNA5.mrum-genome.tbl} that do not begin with a \prog{\#} (these
2266 are comment lines) and also include a \prog{!} (these are hits that
2267 have E-values below the inclusion threshold) using the first two
2268 \prog{grep} commands. This output was then sent through \prog{awk} to
2269 reformat the tabular output to the ``GDF'' format that
2270 \prog{esl-sfetch} expects: \otext{<newname> <from> <to> <source
2271 seqname>}. These lines are then piped into \prog{esl-sfetch} (using
2272 the '-' argument) to retrieve each hit (only the subsequence that
2273 comprises each hit -- not the full target sequence). \prog{esl-sfetch}
2274 will output a FASTA file, which is finally being piped into
2275 \prog{cmalign}, again using the '-' argument. The output that is
2276 actually printed to the screen will be a multiple alignment of all the
2277 included tRNA hits.
2278
2279 You can do similar commands piping subsets of CMs. Supposing you have a copy of Rfam in Rfam.cm:
2280
2281 \user{cmfetch --index Rfam.cm} \\
2282 \user{cat myqueries.list | cmfetch -f Rfam.cm - | cmsearch - mrum-genome.fa}
2283
2284 This takes a list of query CM names/accessions in
2285 \prog{myqueries.list}, fetches them one by one from Rfam, and does an
2286 cmsearch with each of them against the sequence file
2287 \prog{mrum-genome.fa}. As above, the \prog{cat myqueries.list} part
2288 can be replaced by any suitable incantation that generates a list of
2289 profile names/accessions.
2290
2291 There are three kinds of cases where using '-' is restricted or
2292 doesn't work. A fairly obvious restriction is that you can only use
2293 one '-' per command; you can't do a \prog{cmalign - -} that tries to
2294 read both a CM and sequences through the same stdin
2295 pipe. Second, another case is when an input file must be obligately
2296 associated with additional, separately generated auxiliary files, so
2297 reading data from a single stream using '-' doesn't work because the
2298 auxiliary files aren't present (in this case, using '-' will be
2299 prohibited by the program). An example is \prog{cmscan}, which needs
2300 its \prog{<cmfile>} argument to be associated with four auxiliary
2301 files named \prog{<cmfile>.i1\{mifp\}} that \prog{cmpress} creates,
2302 so \prog{cmscan} does not permit a '-' for its \prog{<cmfile>}
2303 argument. Finally, when a command would require multiple passes over
2304 an input file the command will generally abort after the first pass
2305 if you are trying to read that file through a standard input pipe
2306 (pipes are nonrewindable in general; a few Easel programs
2307 will buffer input streams to make multiple passes possible, but this
2308 is not usually the case). An important example is trying to search a
2309 database that is streamed into \prog{cmsearch}. This is not allowed
2310 because \prog{cmsearch} first reads the entire sequence file to
2311 determine its size (which dictates the filter thresholds that will be
2312 used for the search), then needs to rewind the file before beginning
2313 the search.
2314
2315 In general, Infernal, HMMER and Easel programs document in their man
2316 page whether (and which) command line arguments can be replaced by
2317 '-'. You can find the HMMER and Easel program man pages in PDF format
2318 in the HMMER user's guide\cite{hmmer3guide}. You can always check by
2319 trial and error, too. The worst that can happen is a ``Failed to open
2320 file -'' error message, if the program can't read from pipes.