| 1 |
\chapter{Input files and formats} |
| 2 |
\label{chapter:formats} |
| 3 |
\setcounter{footnote}{0} |
| 4 |
|
| 5 |
\section{Reading from files, compressed files, and pipes} |
| 6 |
|
| 7 |
Generally, HMMER programs read their sequence and/or profile input |
| 8 |
from files. Unix power users often find it convenient to string an |
| 9 |
incantation of commands together with pipes.\sidenote{Indeed, such |
| 10 |
wizardly incantations are a point of pride.} For example, you might |
| 11 |
extract a subset of query sequences from a larger file using a |
| 12 |
one-liner combination of scripting commands (python, perl, awk, |
| 13 |
whatever). To facilitate the use of HMMER programs in such |
| 14 |
incantations, you can almost always use an argument of '-' (dash) in |
| 15 |
place of a filename, and the program will take its input from a |
| 16 |
standard input pipe instead of opening a file. |
| 17 |
|
| 18 |
For example, the following three commands are equivalent, and give |
| 19 |
essentially identical output: |
| 20 |
|
| 21 |
\vspace{1ex} |
| 22 |
\user{\% hmmsearch globins4.hmm uniprot\_sprot.fasta} \\ |
| 23 |
\user{\% cat globins4.hmm | hmmsearch - uniprot\_sprot.fasta} \\ |
| 24 |
\user{\% cat uniprot\_sprot.fasta | hmmsearch globins4.hmm - } \\ |
| 25 |
\vspace{1ex} |
| 26 |
|
| 27 |
Most Easel ``miniapp'' programs share the same pipe-reading ability. |
| 28 |
|
| 29 |
Because the programs for profile HMM fetching (\mono{hmmfetch}) and |
| 30 |
sequence fetching (\mono{esl-sfetch}) can fetch any number of profiles |
| 31 |
or sequences by names/accessions given in a list, \emph{and} these |
| 32 |
programs can also read these lists from a stdin pipe, you can craft |
| 33 |
incantations that generate subsets of queries or targets on the |
| 34 |
fly. For example: |
| 35 |
|
| 36 |
\vspace{1ex} |
| 37 |
\begin{fullwidth} |
| 38 |
\user{\indent \% esl-sfetch --index uniprot\_sprot.fasta} \\ |
| 39 |
\user{\% cat mytargs.list | esl-sfetch -f uniprot\_sprot.fasta - | hmmsearch globins4.hmm -} \\ |
| 40 |
\end{fullwidth} |
| 41 |
\vspace{1ex} |
| 42 |
|
| 43 |
This takes a list of sequence names/accessions in |
| 44 |
\mono{mytargets.list}, fetches them one by one from UniProt (note that |
| 45 |
we index the UniProt file first, for fast retrieval; and note that |
| 46 |
\mono{esl-sfetch} is reading its \mono{<namefile>} list of |
| 47 |
names/accessions through a pipe using the '-' argument), and pipes |
| 48 |
them to an \mono{hmmsearch}. It should be obvious from this that we |
| 49 |
can replace the \mono{cat mytargets.list} with \emph{any} incantation |
| 50 |
that generates a list of sequence names/accessions (including SQL |
| 51 |
database queries). |
| 52 |
|
| 53 |
Ditto for piping subsets of profiles. Supposing you have a copy of Pfam in Pfam-A.hmm: |
| 54 |
|
| 55 |
\vspace{1ex} |
| 56 |
\begin{fullwidth} |
| 57 |
\user{\indent \% hmmfetch --index Pfam-A.hmm} \\ |
| 58 |
\user{\% cat myqueries.list | hmmfetch -f Pfam.hmm - | hmmsearch - uniprot\_sprot.fasta}\\ |
| 59 |
\end{fullwidth} |
| 60 |
\vspace{1ex} |
| 61 |
|
| 62 |
This takes a list of query profile names/accessions in |
| 63 |
\mono{myqueries.list}, fetches them one by one from Pfam, and does an |
| 64 |
hmmsearch with each of them against UniProt. As above, the \mono{cat |
| 65 |
myqueries.list} part can be replaced by any suitable incantation |
| 66 |
that generates a list of profile names/accessions. |
| 67 |
|
| 68 |
There are three kinds of cases where using '-' is restricted or |
| 69 |
doesn't work. A fairly obvious restriction is that you can only use |
| 70 |
one '-' per command; you can't do a \mono{hmmsearch - -} that tries to |
| 71 |
read both profile queries and sequence targets through the same stdin |
| 72 |
pipe. Second, another case is when an input file must be obligately |
| 73 |
associated with additional, separately generated auxiliary files, so |
| 74 |
reading data from a single stream using '-' doesn't work because the |
| 75 |
auxiliary files aren't present (in this case, using '-' will be |
| 76 |
prohibited by the program). An example is \mono{hmmscan}, which needs |
| 77 |
its \mono{<hmmfile>} argument to be associated with four auxiliary |
| 78 |
files named \mono{<hmmfile>.h3\{mifp\}} that \mono{hmmpress} creates, |
| 79 |
so \mono{hmmscan} does not permit a '-' for its \mono{<hmmfile>} |
| 80 |
argument. Finally, when a command would require multiple passes over |
| 81 |
an input file, the command will generally abort after the first pass |
| 82 |
if you are trying to read that file through a standard input pipe |
| 83 |
(pipes are nonrewindable in general; a few HMMER or Easel programs |
| 84 |
will buffer input streams to make multiple passes possible, but this |
| 85 |
is not usually the case). An example would be trying to search a file |
| 86 |
containing multiple profile queries against a streamed target |
| 87 |
database: |
| 88 |
|
| 89 |
\vspace{1ex} |
| 90 |
\begin{fullwidth} |
| 91 |
\user{\indent \% cat myqueries.list | hmmfetch -f Pfam.hmm > many.hmms}\\ |
| 92 |
\user{\% cat mytargets.list | esl-sfetch -f uniprot\_sprot.fasta - | hmmsearch many.hmms -}\\ |
| 93 |
\end{fullwidth} |
| 94 |
\vspace{1ex} |
| 95 |
|
| 96 |
This will fail. Unfortunately the above business about how it will |
| 97 |
``generally abort after the first pass'' means it fails weirdly. The |
| 98 |
first query profile search will succeed, and its output will appear; |
| 99 |
then an error message will be generated when \mono{hmmsearch} sees the |
| 100 |
\emph{second} profile query and oops, suddenly realizes it is unable |
| 101 |
to rewind the target sequence database stream. This is inherent in how |
| 102 |
it reads the profile HMM query file sequentially as a stream (which is |
| 103 |
what's allowing it to read input from stdin pipes in the first place), |
| 104 |
one model at a time: it doesn't see there's more than one query model |
| 105 |
in the file until it gets to the second model. |
| 106 |
|
| 107 |
This case isn't too restricting because the same end goal can be |
| 108 |
achieved by reordering the commands. In cases where you want to do |
| 109 |
multiple queries against multiple targets, you always want to be |
| 110 |
reading the \emph{queries} from a stdin pipe, not the targets: |
| 111 |
|
| 112 |
\vspace{1ex} |
| 113 |
\user{\% cat mytargets.list | esl-sfetch -f uniprot\_sprot.fasta > mytarget.seqs}\\ |
| 114 |
\user{\% cat myqueries.list | hmmfetch -f Pfam.hmm - | hmmsearch - mytarget.seqs}\\ |
| 115 |
\vspace{1ex} |
| 116 |
|
| 117 |
So in this multiple queries/multiple targets case of using stdin |
| 118 |
pipes, you just have to know, for any given program, which file it |
| 119 |
considers to be queries and which it considers to be targets. (That |
| 120 |
is, the logic in searching many queries against many targets is ``For |
| 121 |
each query: search the target database; then rewind the target |
| 122 |
database to the beginning.'') For \mono{hmmsearch}, the profiles are |
| 123 |
queries and sequences are targets. For \mono{hmmscan}, the reverse. |
| 124 |
|
| 125 |
In general, HMMER and Easel programs document in their man page |
| 126 |
whether (and which) command line arguments can be replaced by '-'. |
| 127 |
You can always check by trial and error, too. The worst that can |
| 128 |
happen is a ``Failed to open file -'' error message, if the program |
| 129 |
can't read from pipes. |
| 130 |
|
| 131 |
\subsection{.gz compressed files} |
| 132 |
|
| 133 |
In general, HMMER programs and Easel miniapps can also read \mono{.gz} |
| 134 |
compressed files; they will uncompress them on the fly. You need to |
| 135 |
have \mono{gunzip} installed on your system for this to work. |
| 136 |
|
| 137 |
A significant exception is \mono{jackhmmer}, which needs to do |
| 138 |
multiple iterations over the same input sequence database. Because it |
| 139 |
needs to rewind and read the same target database more than once, |
| 140 |
\mono{jackhmmer} won't accept a standard input stream as the database |
| 141 |
argument (unlike most other programs); and because we treat compressed |
| 142 |
files as standard input streams, by opening a pipe from an external |
| 143 |
decompression program, \mono{jackhmmer} won't accept a compressed seq |
| 144 |
database file either. If a program can't accept stdin or a .gz file, |
| 145 |
it'll tell you, by failing with an informative error message. |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 150 |
\newpage |
| 151 |
\section{HMMER profile HMM files} |
| 152 |
\label{section:savefiles} |
| 153 |
|
| 154 |
A HMMER profile file looks like this, with ...'s marking elisions made |
| 155 |
for clarity and space:\sidenote{This is the \mono{globins4.hmm} |
| 156 |
profile from the tutorial.} |
| 157 |
|
| 158 |
\xsreoutput{inclusions/hmmbuild-globins.out2} |
| 159 |
|
| 160 |
A profile file consists of one or more profiles. Each profile starts |
| 161 |
with a format version identifier (here, \mono{HMMER3/\HMMERfmtversion{}}) and ends with |
| 162 |
\mono{//} on a line by itself. The format version identifier allows |
| 163 |
backward compatibility as the HMMER software evolves: it tells the |
| 164 |
parser this file is from HMMER3's save file format version |
| 165 |
\HMMERfmtversion{}.\footnote{HMMER 3.0 used 3/b format. HMMER 3.1 and 3.2 use 3/f |
| 166 |
format. Some alpha test versions of 3.0 used 3/a format. Internal |
| 167 |
development versions of 3.1 used 3/c, 3/d, and 3/e formats.} The |
| 168 |
closing \mono{//} allows multiple profiles to be concatenated. |
| 169 |
|
| 170 |
The format is divided into two regions. The first region contains |
| 171 |
textual information and miscalleneous parameters in a roughly |
| 172 |
tag-value scheme. This section ends with a line beginning with the |
| 173 |
keyword \mono{HMM}. The second region is a tabular, whitespace-limited |
| 174 |
format for the main model parameters. |
| 175 |
|
| 176 |
All probability parameters are all stored as negative natural log |
| 177 |
probabilities with five digits of precision to the right of the |
| 178 |
decimal point, rounded. For example, a probability of $0.25$ is stored |
| 179 |
as $-\log 0.25 = 1.38629$. The special case of a zero probability is |
| 180 |
stored as '*'. |
| 181 |
|
| 182 |
Spacing is arranged for human readability, but the parser only cares |
| 183 |
that fields are separated by at least one space character. |
| 184 |
|
| 185 |
A more detailed description of the format follows. |
| 186 |
|
| 187 |
\subsection{header section} |
| 188 |
|
| 189 |
The header section is parsed line by line in a tag/value format. Each |
| 190 |
line type is either \textbf{mandatory} or \textbf{optional} as |
| 191 |
indicated. |
| 192 |
|
| 193 |
\begin{sreitems}{\monob{header}} |
| 194 |
|
| 195 |
\item [\monob{HMMER3/\HMMERfmtversion{}}] Unique identifier for the save file format |
| 196 |
version; the \mono{/\HMMERfmtversion{}} means that this is HMMER3 profile file format |
| 197 |
version \HMMERfmtversion{}. When HMMER3 changes its save file format, the revision |
| 198 |
code advances. This way, parsers can be backwards |
| 199 |
compatible. The remainder of the line after the \mono{HMMER3/\HMMERfmtversion{}} tag |
| 200 |
is free text that is ignored by the parser. HMMER currently writes |
| 201 |
its version number and release date in brackets here, |
| 202 |
e.g. \mono{\HMMERsavestamp{}} in this |
| 203 |
example. \textbf{Mandatory.} |
| 204 |
|
| 205 |
\item [\monob{NAME <s>}] Model name; \mono{<s>} is a single word |
| 206 |
containing no spaces or tabs. The name is normally picked up from the |
| 207 |
\mono{\#=GF ID} line from a Stockholm alignment file. If this is not |
| 208 |
present, the name is created from the name of the alignment file by |
| 209 |
removing any file type suffix. For example, an otherwise nameless HMM |
| 210 |
built from the alignment file \mono{rrm.slx} would be named |
| 211 |
\mono{rrm}. \textbf{Mandatory.} |
| 212 |
|
| 213 |
\item [\monob{ACC <s>}] Accession number; \mono{<s>} is a one-word |
| 214 |
accession number. This is picked up from the \mono{\#=GF AC} line in a |
| 215 |
Stockholm format alignment. \textbf{Optional.} |
| 216 |
|
| 217 |
\item [\monob{DESC <s>}] Description line; \mono{<s>} is a one-line |
| 218 |
free text description. This is picked up from the \mono{\#=GF DE} line |
| 219 |
in a Stockholm alignment file. \textbf{Optional.} |
| 220 |
|
| 221 |
\item [\monob{LENG <d>}] Model length; \mono{<d>}, a positive nonzero |
| 222 |
integer, is the number of match states in the model. |
| 223 |
\textbf{Mandatory.} |
| 224 |
|
| 225 |
\item [\monob{MAXL <d>}] Max instance length; \mono{<d>}, a positive |
| 226 |
nonzero integer, is the upper bound on the length at which and instance |
| 227 |
of the model is expected to be found. Used only by nhmmer and nhmmscan. |
| 228 |
\textbf{Optional.} |
| 229 |
|
| 230 |
\item [\monob{ALPH <s>}] Symbol alphabet type. For biosequence |
| 231 |
analysis models, \mono{<s>} is \mono{amino}, \mono{DNA}, or \mono{RNA} |
| 232 |
(case insensitive). There are also other accepted alphabets for |
| 233 |
purposes beyond biosequence analysis, including \mono{coins}, |
| 234 |
\mono{dice}, and \mono{custom}. This determines the symbol alphabet |
| 235 |
and the size of the symbol emission probability distributions. If |
| 236 |
\mono{amino}, the alphabet size $K$ is set to 20 and the symbol |
| 237 |
alphabet to ``ACDEFGHIKLMNPQRSTVWY'' (alphabetic order); if |
| 238 |
\mono{DNA}, the alphabet size $K$ is set to 4 and the symbol alphabet |
| 239 |
to ``ACGT''; if \mono{RNA}, the alphabet size $K$ is set to 4 and the |
| 240 |
symbol alphabet to ``ACGU''. \textbf{Mandatory.} |
| 241 |
|
| 242 |
\item [\monob{RF <s>}] Reference annotation flag; \mono{<s>} is |
| 243 |
either \mono{no} or \mono{yes} (case insensitive). If \mono{yes}, the |
| 244 |
reference annotation character field for each match state in the main |
| 245 |
model (see below) is valid; if \mono{no}, these characters are |
| 246 |
ignored. Reference column annotation is picked up from a Stockholm |
| 247 |
alignment file's \mono{\#=GC RF} line. It is propagated to alignment |
| 248 |
outputs, and also may optionally be used to define consensus match |
| 249 |
columns in profile HMM construction. \textbf{Optional}; assumed to be |
| 250 |
no if not present. |
| 251 |
|
| 252 |
\item [\monob{MM <s>}] Model masked flag; \mono{<s>} is |
| 253 |
either \mono{no} or \mono{yes} (case insensitive). If \mono{yes}, the |
| 254 |
model mask annotation character field for each match state in the main |
| 255 |
model (see below) is valid; if \mono{no}, these characters are |
| 256 |
ignored. Indicates that the profile model was created such that |
| 257 |
emission probabilities at masked positions are set to match the |
| 258 |
background frequency, rather than being set based on observed frequencies |
| 259 |
in the alignment. Position-specific insertion and deletion rates are not |
| 260 |
altered, even in masked regions. \textbf{Optional}; assumed to be |
| 261 |
no if not present. |
| 262 |
|
| 263 |
\item [\monob{CONS <s>}] Consensus residue annotation flag; |
| 264 |
\mono{<s>} is either \mono{no} or \mono{yes} (case insensitive). If |
| 265 |
\mono{yes}, the consensus residue field for each match state in the |
| 266 |
main model (see below) is valid. If \mono{no}, these characters are |
| 267 |
ignored. Consensus residue annotation is determined when models are |
| 268 |
built. For models of single sequences, the consensus is the same as |
| 269 |
the query sequence. For models of multiple alignments, the consensus |
| 270 |
is the maximum likelihood residue at each position. Upper case |
| 271 |
indicates that the model's emission probability for the consensus |
| 272 |
residue is $\geq$ an arbitrary threshold (0.5 for protein models, |
| 273 |
0.9 for DNA/RNA models). |
| 274 |
|
| 275 |
\item [\monob{CS <s>}] Consensus structure annotation flag; |
| 276 |
\mono{<s>} is either \mono{no} or \mono{yes} (case insensitive). If |
| 277 |
\mono{yes}, the consensus structure character field for each match |
| 278 |
state in the main model (see below) is valid; if \mono{no} these |
| 279 |
characters are ignored. Consensus structure annotation is picked up |
| 280 |
from a Stockholm file's \mono{\#=GC SS\_cons} line, and propagated to |
| 281 |
alignment displays. \textbf{Optional}; assumed to be no if not |
| 282 |
present. |
| 283 |
|
| 284 |
\item [\monob{MAP <s>}] Map annotation flag; \mono{<s>} is either |
| 285 |
\mono{no} or \mono{yes} (case insensitive). If set to \mono{yes}, the |
| 286 |
map annotation field in the main model (see below) is valid; if |
| 287 |
\mono{no}, that field will be ignored. The HMM/alignment map |
| 288 |
annotates each match state with the index of the alignment column from |
| 289 |
which it came. It can be used for quickly mapping any subsequent |
| 290 |
HMM alignment back to the original multiple alignment, via the model. |
| 291 |
\textbf{Optional}; assumed to be no if not present. |
| 292 |
|
| 293 |
\item [\monob{DATE <s>}] Date the model was constructed; \mono{<s>} |
| 294 |
is a free text date string. This field is only used for logging |
| 295 |
purposes.\footnote{HMMER does not use dates for any purpose other than |
| 296 |
human-readable annotation, so it is no more prone than you are to Y2K, |
| 297 |
Y2038, or any other date-related eschatology.} \textbf{Optional.} |
| 298 |
|
| 299 |
\item [\monob{COM [<n>] <s>}] Command line log; \mono{<n>} counts |
| 300 |
command line numbers, and \mono{<s>} is a one-line command. There may |
| 301 |
be more than one \mono{COM} line per save file, each numbered starting |
| 302 |
from $n=1$. These lines record every HMMER command that modified the |
| 303 |
save file. This helps us reproducibly and automatically log how Pfam |
| 304 |
models have been constructed, for example. \textbf{Optional.} |
| 305 |
|
| 306 |
\item [\monob{NSEQ <d>}] Sequence number; \mono{<d>} is a nonzero |
| 307 |
positive integer, the number of sequences that the HMM was trained on. |
| 308 |
This field is only used for logging purposes. |
| 309 |
\textbf{Optional.} |
| 310 |
|
| 311 |
\item [\monob{EFFN <f>}] Effective sequence number; \mono{<f>} is a |
| 312 |
nonzero positive real, the effective total number of sequences |
| 313 |
determined by \mono{hmmbuild} during sequence weighting, for combining |
| 314 |
observed counts with Dirichlet prior information in parameterizing the |
| 315 |
model. This field is only used for logging purposes. |
| 316 |
\textbf{Optional.} |
| 317 |
|
| 318 |
\item [\monob{CKSUM <d>}] Training alignment checksum; \mono{<d>} is |
| 319 |
a nonnegative unsigned 32-bit integer. This number is calculated |
| 320 |
from the training sequence data, and used in conjunction with the |
| 321 |
alignment map information to verify that a given alignment is indeed |
| 322 |
the alignment that the map is for. \textbf{Optional.} |
| 323 |
|
| 324 |
\item [\monob{GA <f> <f>}] Pfam gathering thresholds GA1 and GA2. |
| 325 |
See Pfam documentation of GA lines. \textbf{Optional.} |
| 326 |
|
| 327 |
\item [\monob{TC <f> <f>}] Pfam trusted cutoffs TC1 and TC2. See |
| 328 |
Pfam documentation of TC lines. \textbf{Optional.} |
| 329 |
|
| 330 |
\item [\monob{NC <f> <f>}] Pfam noise cutoffs NC1 and NC2. See Pfam |
| 331 |
documentation of NC lines. \textbf{Optional.} |
| 332 |
|
| 333 |
\item [\monob{STATS <s1> <s2> <f1> <f2>}] Statistical parameters |
| 334 |
needed for E-value calculations. \mono{<s1>} is the model's |
| 335 |
alignment mode configuration: currently only \mono{LOCAL} is |
| 336 |
recognized. \mono{<s2>} is the name of the score distribution: |
| 337 |
currently \mono{MSV}, \mono{VITERBI}, and \mono{FORWARD} are |
| 338 |
recognized. \mono{<f1>} and \mono{<f2>} are two real-valued |
| 339 |
parameters controlling location and slope of each distribution, |
| 340 |
respectively; $\mu$ and $\lambda$ for Gumbel distributions for MSV |
| 341 |
and Viterbi scores, and $\tau$ and $\lambda$ for exponential tails |
| 342 |
for Forward scores. $\lambda$ values must be positive. All three |
| 343 |
lines or none of them must be present: when all three are present, |
| 344 |
the model is considered to be calibrated for E-value |
| 345 |
statistics. \textbf{Optional.} |
| 346 |
|
| 347 |
\item [\monob{HMM }] Flags the start of the main model |
| 348 |
section. Solely for human readability of the tabular model data, the |
| 349 |
symbol alphabet is shown on the \mono{HMM} line, aligned to the fields |
| 350 |
of the match and insert symbol emission distributions in the main |
| 351 |
model below. The next line is also for human readability, providing |
| 352 |
column headers for the state transition probability fields in the main |
| 353 |
model section that follows. Though unparsed after the \mono{HMM} tag, |
| 354 |
the presence of two header lines is \textbf{mandatory:} the parser |
| 355 |
always skips the line after the \mono{HMM} tag line. |
| 356 |
|
| 357 |
\item [\monob{COMPO <f>*K}] The first line in the main model section |
| 358 |
may be an optional line starting with \monob{COMPO}: these are the |
| 359 |
model's overall average match state emission probabilities, which are |
| 360 |
used as a background residue composition in the ``filter null'' |
| 361 |
model. The $K$ fields on this line are log probabilities for each |
| 362 |
residue in the appropriate biosequence alphabet's |
| 363 |
order. \textbf{Optional.} |
| 364 |
|
| 365 |
\end{sreitems} |
| 366 |
|
| 367 |
\subsection{main model section} |
| 368 |
|
| 369 |
All the remaining fields are \textbf{mandatory}. |
| 370 |
|
| 371 |
The first two lines in the main model section are |
| 372 |
atypical.\footnote{That is, the first two lines after the optional |
| 373 |
\mono{COMPO} line. Don't be confused by the presence of an optional \mono{COMPO} |
| 374 |
line here. The \mono{COMPO} line is placed in the model section, below the |
| 375 |
residue column headers, because it's an array of numbers much like |
| 376 |
residue scores, but it's not really part of the model.} They |
| 377 |
contain information for the core model's BEGIN node. This is stored as |
| 378 |
model node 0, and match state 0 is treated as the BEGIN state. The |
| 379 |
begin state is mute, so there are no match emission probabilities. The |
| 380 |
first line is the insert 0 emissions. The second line contains the |
| 381 |
transitions from the begin state and insert state 0. These seven |
| 382 |
numbers are: $B \rightarrow M_1$, $B \rightarrow I_0$, $B \rightarrow |
| 383 |
D_1$; $I_0 \rightarrow M_1$, $I_0 \rightarrow I_0$; then a 0.0 and a |
| 384 |
'*', because by convention, nonexistent transitions from the |
| 385 |
nonexistent delete state 0 are set to $\log 1 = 0$ and $\log 0 = |
| 386 |
-\infty = $ `*'. |
| 387 |
|
| 388 |
The remainder of the model has three lines per node, for $M$ nodes |
| 389 |
(where $M$ is the number of match states, as given by the \mono{LENG} |
| 390 |
line). These three lines are ($K$ is the alphabet size in residues): |
| 391 |
|
| 392 |
\begin{sreitems}{\textbf{State transition line}} |
| 393 |
|
| 394 |
\item [\textbf{Match emission line}] The first field is the node |
| 395 |
number ($1 \ldots M$). The parser verifies this number as a |
| 396 |
consistency check (it expects the nodes to come in order). The next |
| 397 |
$K$ numbers for match emissions, one per symbol, in alphabetic order. |
| 398 |
|
| 399 |
The next field is the \mono{MAP} annotation for this node. If |
| 400 |
\mono{MAP} was \mono{yes} in the header, then this is an integer, |
| 401 |
representing the alignment column index for this match state |
| 402 |
(1..alen); otherwise, this field is `-'. |
| 403 |
|
| 404 |
The next field is the \mono{CONS} consensus residue for this node. If |
| 405 |
\mono{CONS} was \mono{yes} in the header, then this is a single |
| 406 |
character, representing the consensus residue annotation for this |
| 407 |
match state; otherwise, this field is `-'. |
| 408 |
|
| 409 |
The next field is the \mono{RF} annotation for this node. If |
| 410 |
\mono{RF} was \mono{yes} in the header, then this is a single |
| 411 |
character, representing the reference annotation for this match state; |
| 412 |
otherwise, this field is `-'. |
| 413 |
|
| 414 |
The next field is the \mono{MM} mask value for this node. If |
| 415 |
\mono{MM} was \mono{yes} in the header, then this is a single 'm' |
| 416 |
character, indicating that the position was identified as a masked |
| 417 |
position during model construction; otherwise, this field is `-'. |
| 418 |
|
| 419 |
The next field is the \mono{CS} annotation for this node. If |
| 420 |
\mono{CS} was \mono{yes}, then this is a single character, |
| 421 |
representing the consensus structure at this match state; otherwise |
| 422 |
this field is `-'. |
| 423 |
|
| 424 |
\item [\textbf{Insert emission line}] The $K$ fields on this line are |
| 425 |
the insert emission scores, one per symbol, in alphabetic order. |
| 426 |
|
| 427 |
\item [\textbf{State transition line}] The seven fields on this line |
| 428 |
are the transitions for node $k$, in the order shown by the transition |
| 429 |
header line: $M_k \rightarrow M_{k+1}, I_{k}, D_{k+1}$; $ I_k |
| 430 |
\rightarrow M_{k+1}, I_k$; $D_{k} \rightarrow M_{k+1}, D_{k+1}$. |
| 431 |
|
| 432 |
For transitions from the final node $M$, match state $M+1$ is |
| 433 |
interpreted as the END state $E$, and there is no delete state $M+1$; |
| 434 |
therefore the final $M_k \rightarrow D_{k+1}$ and $D_k \rightarrow |
| 435 |
D_{k+1}$ transitions are always * (zero probability), and the final |
| 436 |
$D_k \rightarrow M_{k+1}$ transition is always 0.0 (probability 1.0). |
| 437 |
\end{sreitems} |
| 438 |
|
| 439 |
Finally, the last line of the format is the ``//'' record separator. |
| 440 |
|
| 441 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 442 |
\newpage |
| 443 |
\section{Stockholm, the recommended multiple sequence alignment format} |
| 444 |
\label{section:stockholm} |
| 445 |
|
| 446 |
The Pfam and Rfam Consortiums have developed a multiple sequence |
| 447 |
alignment format called ``Stockholm format'' that allows rich and |
| 448 |
extensible annotation. |
| 449 |
|
| 450 |
Most popular multiple alignment file formats can be changed into a |
| 451 |
minimal Stockholm format file just by adding a Stockholm header line |
| 452 |
and a trailing \mono{//} terminator: |
| 453 |
|
| 454 |
\xsreoutput{inclusions/globins4.sto} |
| 455 |
|
| 456 |
The first line in the file must be \mono{\# STOCKHOLM 1.x}, where |
| 457 |
\mono{x} is a minor version number for the format specification (and |
| 458 |
which currently has no effect on my parsers). This line allows a |
| 459 |
parser to instantly identify the file format. |
| 460 |
|
| 461 |
In the alignment, each line contains a name, followed by the aligned |
| 462 |
sequence. A dash, period, underscore, or tilde (but not whitespace) |
| 463 |
denotes a gap. If the alignment is too long to fit on one line, the |
| 464 |
alignment may be split into multiple blocks, with blocks separated by |
| 465 |
blank lines. The number of sequences, their order, and their names |
| 466 |
must be the same in every block. Within a given block, each |
| 467 |
(sub)sequence (and any associated \mono{\#=GR} and \mono{\#=GC} markup, |
| 468 |
see below) is of equal length, called the \emph{block length}. Block |
| 469 |
lengths may differ from block to block. The block length must be at |
| 470 |
least one residue, and there is no maximum. |
| 471 |
|
| 472 |
Other blank lines are ignored. You can add comments anywhere to the |
| 473 |
file (even within a block) on lines starting with a \mono{\#}. |
| 474 |
|
| 475 |
All other annotation is added using a tag/value comment style. The |
| 476 |
tag/value format is inherently extensible, and readily made |
| 477 |
backwards-compatible; unrecognized tags will simply be ignored. Extra |
| 478 |
annotation includes consensus and individual RNA or protein secondary |
| 479 |
structure, sequence weights, a reference coordinate system for the |
| 480 |
columns, and database source information including name, accession |
| 481 |
number, and coordinates (for subsequences extracted from a longer |
| 482 |
source sequence) See below for details. |
| 483 |
|
| 484 |
\subsection{syntax of Stockholm markup} |
| 485 |
|
| 486 |
There are four types of Stockholm markup annotation, for per-file, |
| 487 |
per-sequence, per-column, and per-residue annotation: |
| 488 |
|
| 489 |
\begin{description}%{\monob{\#=GR <seqname> <tag> <..s..>}} |
| 490 |
\item [\monob{\#=GF <tag> <s>}] |
| 491 |
Per-file annotation. \mono{<s>} is a free format text line |
| 492 |
of annotation type \mono{<tag>}. For example, \mono{\#=GF DATE |
| 493 |
April 1, 2000}. Can occur anywhere in the file, but usually |
| 494 |
all the \mono{\#=GF} markups occur in a header. |
| 495 |
|
| 496 |
\item [\monob{\#=GS <seqname> <tag> <s>}] |
| 497 |
Per-sequence annotation. \mono{<s>} is a free format text line |
| 498 |
of annotation type \mono{tag} associated with the sequence |
| 499 |
named \mono{<seqname>}. For example, \mono{\#=GS seq1 |
| 500 |
SPECIES\_SOURCE Caenorhabditis elegans}. Can occur anywhere |
| 501 |
in the file, but in single-block formats (e.g. the Pfam |
| 502 |
distribution) will typically follow on the line after the |
| 503 |
sequence itself, and in multi-block formats (e.g. HMMER |
| 504 |
output), will typically occur in the header preceding the |
| 505 |
alignment but following the \mono{\#=GF} annotation. |
| 506 |
|
| 507 |
\item [\monob{\#=GC <tag> <..s..>}] |
| 508 |
Per-column annotation. \mono{<..s..>} is an aligned text line |
| 509 |
of annotation type \mono{<tag>}. |
| 510 |
\mono{\#=GC} lines are |
| 511 |
associated with a sequence alignment block; \mono{<..s..>} |
| 512 |
is aligned to the residues in the alignment block, and has |
| 513 |
the same length as the rest of the block. |
| 514 |
Typically \mono{\#=GC} lines are placed at the end of each block. |
| 515 |
|
| 516 |
\item [\monob{\#=GR <seqname> <tag> <..s..>}] |
| 517 |
Per-residue annotation. \mono{<..s..>} is an aligned text line |
| 518 |
of annotation type \mono{<tag>}, associated with the sequence |
| 519 |
named \mono{<seqname>}. |
| 520 |
\mono{\#=GR} lines are |
| 521 |
associated with one sequence in a sequence alignment block; |
| 522 |
\mono{<..s..>} |
| 523 |
is aligned to the residues in that sequence, and has |
| 524 |
the same length as the rest of the block. |
| 525 |
Typically |
| 526 |
\mono{\#=GR} lines are placed immediately following the |
| 527 |
aligned sequence they annotate. |
| 528 |
\end{description} |
| 529 |
|
| 530 |
|
| 531 |
\subsection{semantics of Stockholm markup} |
| 532 |
|
| 533 |
Any Stockholm parser will accept syntactically correct files, but is |
| 534 |
not obligated to do anything with the markup lines. It is up to the |
| 535 |
application whether it will attempt to interpret the meaning (the |
| 536 |
semantics) of the markup in a useful way. At the two extremes are the |
| 537 |
Belvu alignment viewer and the HMMER profile hidden Markov model |
| 538 |
software package. |
| 539 |
|
| 540 |
Belvu simply reads Stockholm markup and displays it, without trying to |
| 541 |
interpret it at all. The tag types (\mono{\#=GF}, etc.) are sufficient |
| 542 |
to tell Belvu how to display the markup: whether it is attached to the |
| 543 |
whole file, sequences, columns, or residues. |
| 544 |
|
| 545 |
HMMER uses Stockholm markup to pick up a variety of information from |
| 546 |
the Pfam multiple alignment database. The Pfam consortium therefore |
| 547 |
agrees on additional syntax for certain tag types, so HMMER can parse |
| 548 |
some markups for useful information. This additional syntax is imposed |
| 549 |
by Pfam, HMMER, and other software of mine, not by Stockholm format |
| 550 |
per se. You can think of Stockholm as akin to XML, and what my |
| 551 |
software reads as akin to an XML DTD, if you're into that sort of |
| 552 |
structured data format lingo. |
| 553 |
|
| 554 |
The Stockholm markup tags that are parsed semantically by my software |
| 555 |
are as follows: |
| 556 |
|
| 557 |
\subsection{recognized \#=GF annotations} |
| 558 |
\begin{sreitems}{\monob{TC <f> <f>}} |
| 559 |
\item [\monob{ID <s>}] |
| 560 |
Identifier. \monob{<s>} is a name for the alignment; |
| 561 |
e.g. ``rrm''. One word. Unique in file. |
| 562 |
|
| 563 |
\item [\monob{AC <s>}] |
| 564 |
Accession. \monob{<s>} is a unique accession number for the |
| 565 |
alignment; e.g. |
| 566 |
``PF00001''. Used by the Pfam database, for instance. |
| 567 |
Often a alphabetical prefix indicating the database |
| 568 |
(e.g. ``PF'') followed by a unique numerical accession. |
| 569 |
One word. Unique in file. |
| 570 |
|
| 571 |
\item [\monob{DE <s>}] |
| 572 |
Description. \monob{<s>} is a free format line giving |
| 573 |
a description of the alignment; e.g. |
| 574 |
``RNA recognition motif proteins''. One line. Unique in file. |
| 575 |
|
| 576 |
\item [\monob{AU <s>}] |
| 577 |
Author. \monob{<s>} is a free format line listing the |
| 578 |
authors responsible for an alignment; e.g. |
| 579 |
``Bateman A''. One line. Unique in file. |
| 580 |
|
| 581 |
\item [\monob{GA <f> <f>}] |
| 582 |
Gathering thresholds. Two real numbers giving HMMER bit score |
| 583 |
per-sequence and per-domain cutoffs used in gathering the |
| 584 |
members of Pfam full alignments. |
| 585 |
|
| 586 |
\item [\monob{NC <f> <f>}] |
| 587 |
Noise cutoffs. Two real numbers giving HMMER bit score |
| 588 |
per-sequence and per-domain cutoffs, set according to the |
| 589 |
highest scores seen for unrelated sequences when gathering |
| 590 |
members of Pfam full alignments. |
| 591 |
|
| 592 |
\item [\monob{TC <f> <f>}] |
| 593 |
Trusted cutoffs. Two real numbers giving HMMER bit score |
| 594 |
per-sequence and per-domain cutoffs, set according to the |
| 595 |
lowest scores seen for true homologous sequences that |
| 596 |
were above the GA gathering thresholds, when gathering |
| 597 |
members of Pfam full alignments. |
| 598 |
\end{sreitems} |
| 599 |
|
| 600 |
\subsection{recognized \#=GS annotations} |
| 601 |
|
| 602 |
\begin{sreitems}{\monob{WT <f>}} |
| 603 |
\item [\monob{WT <f>}] |
| 604 |
Weight. \monob{<f>} is a positive real number giving the |
| 605 |
relative weight for a sequence, usually used to compensate |
| 606 |
for biased representation by downweighting similar sequences. |
| 607 |
Usually the weights average 1.0 (e.g. the weights sum to |
| 608 |
the number of sequences in the alignment) but this is not |
| 609 |
required. Either every sequence must have a weight annotated, |
| 610 |
or none of them can. |
| 611 |
|
| 612 |
\item [\monob{AC <s>}] |
| 613 |
Accession. \monob{<s>} is a database accession number for |
| 614 |
this sequence. (Compare the \mono{\#=GF AC} markup, which gives |
| 615 |
an accession for the whole alignment.) One word. |
| 616 |
|
| 617 |
\item [\monob{DE <s>}] |
| 618 |
Description. \monob{<s>} is one line giving a description for |
| 619 |
this sequence. (Compare the \mono{\#=GF DE} markup, which gives |
| 620 |
a description for the whole alignment.) |
| 621 |
\end{sreitems} |
| 622 |
|
| 623 |
|
| 624 |
\subsection{recognized \#=GC annotations} |
| 625 |
|
| 626 |
\begin{sreitems}{\monob{SA\_cons}} |
| 627 |
|
| 628 |
\item [\monob{RF}] |
| 629 |
Reference line. Any character is accepted as a markup for a |
| 630 |
column. The intent is to allow labeling the columns with some |
| 631 |
sort of mark. |
| 632 |
|
| 633 |
\item [\monob{MM}] |
| 634 |
Model mask line. An 'm' indicates that the column lies within a |
| 635 |
masked range, so that \mono{hmmbuild} should produce emissions matching |
| 636 |
the background for a match state corresponding to that alignment column. |
| 637 |
Otherwise, a '.' is used. |
| 638 |
|
| 639 |
\item [\monob{SS\_cons}] |
| 640 |
Secondary structure consensus. For protein alignments, |
| 641 |
DSSP codes or gaps are accepted as markup: [HGIEBTSCX.-\_], where |
| 642 |
H is alpha helix, G is 3/10-helix, I is p-helix, E is extended |
| 643 |
strand, B is a residue in an isolated b-bridge, T is a turn, |
| 644 |
S is a bend, C is a random coil or loop, and X is unknown |
| 645 |
(for instance, a residue that was not resolved in a crystal |
| 646 |
structure). |
| 647 |
|
| 648 |
\item [\monob{SA\_cons}] |
| 649 |
Surface accessibility consensus. 0-9, gap symbols, or X are |
| 650 |
accepted as markup. 0 means $<$10\% accessible residue surface |
| 651 |
area, 1 means $<$20\%, 9 means $<$100\%, etc. X means unknown |
| 652 |
structure. |
| 653 |
\end{sreitems} |
| 654 |
|
| 655 |
\subsection{recognized \#=GR annotations} |
| 656 |
\begin{sreitems}{\monob{SA}} |
| 657 |
\item [\monob{SS}] |
| 658 |
Secondary structure consensus. See \mono{\#=GC SS\_cons} above. |
| 659 |
\item [\monob{SA}] |
| 660 |
Surface accessibility consensus. See \mono{\#=GC SA\_cons} above. |
| 661 |
\item [\monob{PP}] Posterior probability for an aligned residue. This |
| 662 |
represents the probability that this residue is assigned to the HMM |
| 663 |
state corresponding to this alignment column, as opposed to some |
| 664 |
other state. (Note that a residue can be confidently |
| 665 |
\emph{unaligned}: a residue in an insert state or flanking N or C |
| 666 |
state may have high posterior probability.) The posterior |
| 667 |
probability is encoded as 11 possible characters \mono{0-9*+}: $0.0 |
| 668 |
\leq p < 0.05$ is coded as 0, $0.05 \leq p < 0.15$ is coded as 1, |
| 669 |
(... and so on ...), $0.85 \leq p < 0.95$ is coded as 9, and $0.95 |
| 670 |
\leq p \leq 1.0$ is coded as '*'. Gap characters appear in the PP |
| 671 |
line where no residue has been assigned. |
| 672 |
\end{sreitems} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 677 |
\newpage |
| 678 |
\section{A2M multiple alignment format} |
| 679 |
|
| 680 |
% Adapted from Easel documentation's format_a2m.tex by: |
| 681 |
% - including format_a2m.tex |
| 682 |
% - add the section header below |
| 683 |
% - revise first pp to be about HMMER. |
| 684 |
|
| 685 |
HMMER's Easel library routines are capable of writing alignments in UC |
| 686 |
Santa Cruz ``A2M'' (alignment to model) format, the native input |
| 687 |
format for the UCSC SAM profile HMM software package. |
| 688 |
|
| 689 |
To select A2M format, use the format code \mono{a2m}: for example, |
| 690 |
to reformat a Stockholm alignment to A2M: |
| 691 |
|
| 692 |
\user{esl-reformat a2m myali.sto} |
| 693 |
|
| 694 |
Easel currently does not read A2M format, and it currently only writes |
| 695 |
in what UCSC calls ``dotless'' A2M format. |
| 696 |
|
| 697 |
The most official documentation for A2M format appears to be at |
| 698 |
\url{http://compbio.soe.ucsc.edu/a2m-desc.html}. You may refer to that |
| 699 |
document if anything in the brief description below is unclear. |
| 700 |
|
| 701 |
\subsection{An example A2M file} |
| 702 |
|
| 703 |
This alignment: |
| 704 |
|
| 705 |
\begin{sreoutput} |
| 706 |
seq1 ACDEF...GHIKLMNPQTVWY |
| 707 |
seq2 ACDEF...GHIKLMNPQTVWY |
| 708 |
seq3 ---EFmnrGHIKLMNPQT--- |
| 709 |
\end{sreoutput} |
| 710 |
|
| 711 |
\noindent |
| 712 |
is encoded in A2M format as: |
| 713 |
|
| 714 |
\begin{sreoutput} |
| 715 |
>seq1 Sequence 1 description |
| 716 |
ACDEFGHIKLMNPQTVWY |
| 717 |
>seq2 Sequence 2 description |
| 718 |
ACDEFGHIKLMNPQTVWY |
| 719 |
>seq3 Sequence 3 description |
| 720 |
---EFmnrGHIKLMNPQT--- |
| 721 |
\end{sreoutput} |
| 722 |
|
| 723 |
A2M format looks a lot like aligned FASTA format. A crucial difference |
| 724 |
is that the aligned sequences in a ``dotless'' A2M file do not |
| 725 |
necessarily all have the same number of characters. The format |
| 726 |
distinguishes between ``consensus columns'' (where residues are in |
| 727 |
upper case and gaps are a dash, `-') and ``insert columns'' (where |
| 728 |
residues are in lower case and gaps are dots, `.', that aren't |
| 729 |
explicitly shown in the format -- hence ``dotless'' A2M). The position |
| 730 |
and number of gaps in insert columns (dots) is implicit in this |
| 731 |
representation. An advantage of this format is its compactness. |
| 732 |
|
| 733 |
This representation only works if all insertions relative to consensus |
| 734 |
are considered to be unaligned characters. That is how insertions are |
| 735 |
handled by profile HMM implementations like SAM and HMMER, and profile |
| 736 |
SCFG implementations like Infernal. |
| 737 |
|
| 738 |
Thus every sequence must have the same number of consensus columns |
| 739 |
(upper case letters plus `-' characters), and may have additional lower |
| 740 |
case letters for insertions. |
| 741 |
|
| 742 |
\subsection{Legal characters} |
| 743 |
|
| 744 |
A2M (and SAM) do not support some special characters such as `*' |
| 745 |
(not-a-residue) or `\mono{\~}' (missing data). Easel outputs these |
| 746 |
characters as gaps: either `-' in a consensus column, or nothing in an |
| 747 |
insert column. |
| 748 |
|
| 749 |
The SAM software parses only a subset of legal ambiguity codes for |
| 750 |
amino acids and nucleotides. For amino acids, it only reads \{BXZ\} in |
| 751 |
addition to the 20 standard one-letter codes. For nucleotides, it only |
| 752 |
reads \{NRY\} in addition to \{ACGTU\}. With one crucial exception, it |
| 753 |
treats all other letters as X or N. |
| 754 |
|
| 755 |
The crucial exception is `O'. SAM reads an `O' as the position of a |
| 756 |
``free insertion module'' (FIM), a concept specific to SAM-style |
| 757 |
profile HMMs. This has no impact on nucleic acid sequences, where `O' |
| 758 |
is not a legal character. But in amino acid sequences, `O' means |
| 759 |
pyrrolysine, one of the unusual genetically-encoded amino acids. This |
| 760 |
means that A2M format alignments must not contain pyrrolysine |
| 761 |
residues, lest they be read as FIMs. For this reason, Easel converts |
| 762 |
`O' residues to `X' when it writes an amino acid alignment in A2M |
| 763 |
format. |
| 764 |
|
| 765 |
\subsection{Determining consensus columns} |
| 766 |
|
| 767 |
Writing A2M format requires knowing which alignment columns are |
| 768 |
supposed to be considered consensus and which are considered |
| 769 |
inserts. If the alignment was produced by HMMER or Infernal, then the |
| 770 |
alignment has so-called ``reference annotation'' (what appears as a |
| 771 |
\mono{\#=GC RF} line in Stockholm format) marking the consensus |
| 772 |
columns. |
| 773 |
|
| 774 |
Often, an alignment has no reference annotation; for example, if it |
| 775 |
has been read from an alignment format that has no reference |
| 776 |
annotation line (only Stockholm and SELEX formats support reference |
| 777 |
annotation). In this case, Easel internally generates a ``reasonable'' |
| 778 |
guess at consensus columns, using essentially the same procedure that |
| 779 |
HMMER's \mono{hmmbuild} program uses by default: sequence fragments |
| 780 |
(sequences $<$50\% of the mean sequence length in the alignment |
| 781 |
overall) are ignored, and for the remaining sequences, any column |
| 782 |
containing $\geq$ 50\% residues is considered to be a consensus |
| 783 |
column. |
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 789 |
\newpage |
| 790 |
\section{hmmpgmd sequence database format} |
| 791 |
|
| 792 |
The hmmpgmd sequence database format closely resembles the |
| 793 |
FASTA format, with slight modification to support use within HMMER's |
| 794 |
\mono{hmmpgmd} daemon. |
| 795 |
|
| 796 |
|
| 797 |
The \mono{hmmpgmd} program enables search of one or more sequence |
| 798 |
databases (e.g. NR, SwissProt, UniProt) within a single instance, |
| 799 |
having loaded a single sequence file into memory. Because the set of |
| 800 |
sequences found within the various databases may overlap, the hmmpgmd |
| 801 |
format allows each sequence to be stored once, and includes a small piece of |
| 802 |
metadata that indicates, for each sequence, the list of source databases in |
| 803 |
which the sequence is found. When a search is performed in \mono{hmmpgmd}, a |
| 804 |
single target database is specified, and search is restricted to sequences |
| 805 |
belonging to that database. |
| 806 |
|
| 807 |
Furthermore, because a single sequence might be found multiple times |
| 808 |
within a single sequence database, \mono{hmmpgmd} is designed to compute |
| 809 |
E-values not just on the total number of non-redundant sequences |
| 810 |
within a database, but on the total number of sequences in the original |
| 811 |
(possibly redundant) database, provided those redundant counts are |
| 812 |
given in the hmmpgmd-formatted file. |
| 813 |
|
| 814 |
The \mono{hmmpgmd} file begins with a single line containing various counts |
| 815 |
describing the contents of the file, of the form |
| 816 |
|
| 817 |
\monob{\#res\_cnt seq\_cnt db\_cnt cnt\_1 fullcnt\_1 cnt\_2 fullcnt\_2 $\ldots$ date\_stamp} |
| 818 |
|
| 819 |
\subsection{Fields in header line} |
| 820 |
|
| 821 |
\begin{sreitems}{\monob{header}} |
| 822 |
|
| 823 |
\item [\monob{res\_cnt}] Number of residues in the sequence file. |
| 824 |
|
| 825 |
\item [\monob{seq\_cnt}] Number of sequences in the sequence file. |
| 826 |
|
| 827 |
\item [\monob{db\_cnt}] Number of databases in the sequence file. |
| 828 |
|
| 829 |
\item [\monob{cnt\_i}] Of the sequnces in the file, the number that belong to |
| 830 |
database \mono{i}. Note that if the file contains only a single |
| 831 |
database, this will match \mono{seq\_cnt}. |
| 832 |
|
| 833 |
\item [\monob{fullcnt\_i}] For database \mono{i}, the number of sequences |
| 834 |
that should be used in computing E-values. If redundant |
| 835 |
sequences were collapsed out of the original database, this may be |
| 836 |
larger than \mono{cnt\_i}. |
| 837 |
|
| 838 |
\end{sreitems} |
| 839 |
|
| 840 |
|
| 841 |
\subsection{FASTA-like sequence format} |
| 842 |
|
| 843 |
In the main body of the sequence file, database sequences are stored |
| 844 |
sequentially, with each entry consisting of a one-line FASTA-like |
| 845 |
header followed by one or more lines containing the amino acid sequence, |
| 846 |
like |
| 847 |
|
| 848 |
\begin{sreoutput} |
| 849 |
>1 100 |
| 850 |
ACDEFGHIKLMNPQTVWY |
| 851 |
>2 010 |
| 852 |
ACDKLMNPQTVWYEFGHI |
| 853 |
>3 111 |
| 854 |
EFMNRGHIKLMNPQT |
| 855 |
\end{sreoutput} |
| 856 |
|
| 857 |
Note that the per-entry header line is made up of two parts. The first part |
| 858 |
is a numeric, incrementing sequence identifier (the i'th entry has the |
| 859 |
identifier \mono{i}). The second part is a bit string indicating database |
| 860 |
membership. In this example, sequence 1 is found in database 1, sequence 2 is |
| 861 |
found in database 2, and sequence 3 found in databases 1, 2, and 3. The number |
| 862 |
of bits in each bit string should match \mono{db\_cnt}. |
| 863 |
|
| 864 |
Because \mono{hmmpgmd} accepts only numeric sequence identifiers, it is |
| 865 |
necessary to keep track of the mapping between each numeric sequence identifier |
| 866 |
and the corresponding meta data (e.g. name, accession, description) external to |
| 867 |
the hmmpgmd-format file, and post-process \mono{hmmpgmd} seach results to |
| 868 |
apply those fields to the target sequence information. |
| 869 |
Depending on the size of the map list, this might be easily acheived with a |
| 870 |
simple perl array, or might require a more heavy-duty mapping backend such as |
| 871 |
mongodb (\url{http://www.mongodb.org}). |
| 872 |
|
| 873 |
|
| 874 |
\subsection{Creating a file in hmmpgmd format} |
| 875 |
|
| 876 |
The HMMER-Easel tool \mono{esl-reformat} is able to convert a file in unaligned |
| 877 |
fasta format into an hmmpgmd format file, such as |
| 878 |
|
| 879 |
\user{esl-reformat --id\_map mydb.hmmpgmd.map hmmpgmd mydb.fasta > mydb.hmmpgmd} |
| 880 |
|
| 881 |
The optional \mono{--id\_map} flag captures sequence name and description |
| 882 |
information into a simple tabular file, to be used for mapping those values |
| 883 |
back to \mono{hmmpgmd} query hits. |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 888 |
\newpage |
| 889 |
\section{Score matrix files} |
| 890 |
|
| 891 |
Profile HMMs can be built from single sequences, not just from |
| 892 |
multiple sequence alignments. For example, the \mono{phmmer} and |
| 893 |
\mono{jackhmmer} search programs take a single sequence query as an |
| 894 |
input, and \mono{nhmmer} can as well. For single sequence queries, the |
| 895 |
probability parameters for residue alignments are derived from a |
| 896 |
substitution score matrix, such as BLOSUM62. Scores are converted to |
| 897 |
probabilities as described by Altschul (1991).\cite{Altschul91}. The |
| 898 |
scores can be arbitrary, but they must satisfy a couple of conditions |
| 899 |
so they can be interpreted as implicit log-odds probabilities: there |
| 900 |
must be at least one positive score, and the expected score (on |
| 901 |
nonhomologous alignments) must be negative. |
| 902 |
|
| 903 |
The default score matrix for protein alignments is BLOSUM62; for DNA, |
| 904 |
a matrix we call DNA1. Using the \mono{--mx} option (for programs that |
| 905 |
can use score matrices), you can choose instead one of several |
| 906 |
alternative protein score matrices: PAM30, PAM70, PAM120, PAM240, |
| 907 |
BLOSUM45, BLOSUM50, BLOSUM80, and BLOSUM90. For example, you could use |
| 908 |
\mono{--mx BLOSUM50}. |
| 909 |
|
| 910 |
The \mono{--mxfile} option allows you to provide a score matrix as a |
| 911 |
file. You can download many standard score matrice files from NCBI at |
| 912 |
\url{ftp://ftp.ncbi.nlm.nih.gov/blast/matrices/}. HMMER can read |
| 913 |
\emph{almost} any of these files, with one exception: because it |
| 914 |
requires the score matrix to be symmetrical (same number of residues |
| 915 |
in rows and columns), the NCBI \mono{NUC.4.4} matrix for DNA works, |
| 916 |
but the alternative short-form format \mono{NUC.4.2} does not |
| 917 |
work. The scores in these two files are identical, so just use |
| 918 |
\mono{NUC.4.4}, and files like it. |
| 919 |
|
| 920 |
Here's a simple example file: |
| 921 |
|
| 922 |
\begin{sreoutput} |
| 923 |
# My score matrix |
| 924 |
# |
| 925 |
A T G C |
| 926 |
A 1 -3 -3 -3 |
| 927 |
T -3 1 -3 -3 |
| 928 |
G -3 -3 1 -3 |
| 929 |
C -3 -3 -3 1 |
| 930 |
\end{sreoutput} |
| 931 |
|
| 932 |
In more detail, the rules for the format are: |
| 933 |
|
| 934 |
\begin{itemize} |
| 935 |
|
| 936 |
\item Blank lines are ignored. |
| 937 |
|
| 938 |
\item A \mono{\#} indicates a comment. Anything after it is |
| 939 |
ignored. Lines that start with \mono{\#} are ignored like blank |
| 940 |
lines. |
| 941 |
|
| 942 |
\item The first data line is a header line, labeling each column with |
| 943 |
$n$ single residue characters (case-insensitive). A nucleic matrix |
| 944 |
has $4 \leq n \leq 16$: at least the four canonical residues |
| 945 |
\mono{ACGT} (or \mono{U}, for you RNA zealots), and it may also |
| 946 |
contain any or all ambiguity codes \mono{RYMKSWHBVDN*}. A protein |
| 947 |
matrix has $20 \leq n 27$; it must contain at least the 20 canonical |
| 948 |
residues \mono{ACDEFGHIKLMNPQRSTVWY}, and may contain any or all |
| 949 |
ambiguity codes \mono{BJZOU}. These residues can be in any order, |
| 950 |
but the rows must be in the same order as the columns. |
| 951 |
|
| 952 |
\item The next $n$ data lines are the rows of a square $n \times n$ |
| 953 |
score matrix: |
| 954 |
|
| 955 |
\begin{itemize} |
| 956 |
\item Fields in the row are whitespace-delimited (tabs or |
| 957 |
spaces). |
| 958 |
|
| 959 |
\item Optionally, each row can start with its single residue label. |
| 960 |
Therefore each row has either $n+1$ fields if there is a leading |
| 961 |
label, or $n$ fields if not. Rows and columns are in the same order. |
| 962 |
|
| 963 |
\item Each score is an integer. Plus signs are optional. |
| 964 |
\end{itemize} |
| 965 |
|
| 966 |
\item The file may not contain any additional lines (other than |
| 967 |
comments or blank lines). |
| 968 |
\end{itemize} |
| 969 |
|
| 970 |
HMMER only uses the scores for canonical residues, and uses them to |
| 971 |
calculate probabilities. If scores for ambiguous residue codes are |
| 972 |
provided, HMMER ignores them; it has its own logic for dealing with |
| 973 |
the probability of ambiguous residues, given the probability of |
| 974 |
canonical residues. |
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|