1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
# Copyright 2012 by Wibowo Arindrarto. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Bio.SearchIO support for HMMER output formats.
This module adds support for parsing HMMER outputs. HMMER is a
suite of programs implementing the profile hidden Markov models to find
similarity across protein sequences.
Bio.SearchIO.HmmerIO was tested on the following HMMER versions and flavors:
- HMMER3 flavors: hmmscan, hmmsearch, phmmer
- HMMER2 flavors: hmmpfam, hmmsearch
More information on HMMER are available through these links:
- Web page: http://hmmer.janelia.org/
- User guide: ftp://selab.janelia.org/pub/software/hmmer3/3.0/Userguide.pdf
Supported formats
=================
Bio.SearchIO.HmmerIO supports the following HMMER output formats:
- Plain text, v3.0 - 'hmmer3-text' - parsing, indexing
- Table, v3.0 - 'hmmer3-tab' - parsing, indexing, writing
- Domain table, v3.0 - 'hmmer3-domtab'* - parsing, indexing, writing
- Plain text, v2.x - 'hmmer2-text' - parsing, indexing
* For the domain table output, due to the way HMMER outputs the sequence
coordinates, you have to specify what HMMER flavor produced the output as the
file format. So instead of using 'hmmer3-domtab', you have to use either
'hmmscan3-domtab', 'hmmsearch3-domtab', or 'phmmer3-domtab' as the file format
name.
Note that for all output formats, HMMER uses its own convention of input and
output coordinates. It does not use the term 'hit' or 'query', instead it
uses 'hmm' or 'ali'. For example, 'hmmfrom' is the start coordinate of the HMM
sequence while 'alifrom' is the start coordinate of the protein sequence.
HmmerIO is aware of this different naming scheme and will adjust them
accordingly to fit SearchIO's object model. If HmmerIO sees that the output file
to parse was written by hmmsearch or phmmer, all 'hmm' coordinates will be the
hit coordinates and 'ali' coordinates will be the query coordinates. Conversely,
if the HMMER flavor is hmmscan, 'hmm' will be query and 'ali' will be hit.
This is why the 'hmmer3-domtab' format has to be specified with the source HMMER
flavor. The parsers need to know which is the hit and which is the query.
'hmmer3-text' has its source program information present in the file, while
'hmmer3-tab' does not output any coordinates. That's why both of these formats
do not need direct flavor specification like 'hmmer3-domtab'.
Also note that when using the domain table format writers, it will use HMMER's
naming convention ('hmm' and 'ali') so the files you write will be similar to
files written by a real HMMER program.
hmmer2-text and hmmer3-text
===========================
The parser for HMMER 3.0 plain text output can parse output files with alignment
blocks (default) or without (with the '--noali' flag). If the alignment blocks
are present, you can also parse files with variable alignment width (using the
'--notextw' or '--textw' flag).
The following SearchIO objects attributes are provided. Rows marked with '*'
denotes attributes not available in the hmmer2-text format:
+-----------------+-------------------------+----------------------------------+
| Object | Attribute | Value |
+=================+=========================+==================================+
| QueryResult | accession | accession (if present) |
| +-------------------------+----------------------------------+
| | description | query sequence description |
| +-------------------------+----------------------------------+
| | id | query sequence ID |
| +-------------------------+----------------------------------+
| | program | HMMER flavor |
| +-------------------------+----------------------------------+
| | seq_len* | full length of query sequence |
| +-------------------------+----------------------------------+
| | target | target search database |
| +-------------------------+----------------------------------+
| | version | BLAST version |
+-----------------+-------------------------+----------------------------------+
| Hit | bias* | hit-level bias |
| +-------------------------+----------------------------------+
| | bitscore | hit-level score |
| +-------------------------+----------------------------------+
| | description | hit sequence description |
| +-------------------------+----------------------------------+
| | domain_exp_num* | expected number of domains in |
| | | the hit (exp column) |
| +-------------------------+----------------------------------+
| | domain_obs_num | observed number of domains in |
| | | the hit (N column) |
| +-------------------------+----------------------------------+
| | evalue | hit-level e-value |
| +-------------------------+----------------------------------+
| | id | hit sequence ID |
| +-------------------------+----------------------------------+
| | is_included* | boolean, whether the hit is in |
| | | the inclusion threshold or not |
+-----------------+-------------------------+----------------------------------+
| HSP | acc_avg* | expected accuracy per alignment |
| | | residue (acc column) |
| +-------------------------+----------------------------------+
| | bias* | hsp-level bias |
| +-------------------------+----------------------------------+
| | bitscore | hsp-level score |
| +-------------------------+----------------------------------+
| | domain_index | the domain index set by HMMER |
| +-------------------------+----------------------------------+
| | env_end* | end coordinate of the envelope |
| +-------------------------+----------------------------------+
| | env_endtype* | envelope end types (e.g. '[]', |
| | | '..', '[.', etc.) |
| +-------------------------+----------------------------------+
| | env_start* | start coordinate of the envelope |
| +-------------------------+----------------------------------+
| | evalue | hsp-level independent e-value |
| +-------------------------+----------------------------------+
| | evalue_cond* | hsp-level conditional e-value |
| +-------------------------+----------------------------------+
| | hit_endtype | hit sequence end types |
| +-------------------------+----------------------------------+
| | is_included* | boolean, whether the hit of the |
| | | hsp is in the inclusion |
| | | threshold |
| +-------------------------+----------------------------------+
| | query_endtype | query sequence end types |
+-----------------+-------------------------+----------------------------------+
| HSPFragment | aln_annotation | alignment similarity string and |
| (also via HSP) | | other annotations (e.g. PP, CS) |
| +-------------------------+----------------------------------+
| | aln_span | length of alignment fragment |
| +-------------------------+----------------------------------+
| | hit | hit sequence |
| +-------------------------+----------------------------------+
| | hit_end | hit sequence end coordinate, may |
| | | be 'hmmto' or 'alito' depending |
| | | on the HMMER flavor |
| +-------------------------+----------------------------------+
| | hit_start | hit sequence start coordinate, |
| | | may be 'hmmfrom' or 'alifrom' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | hit_strand | hit sequence strand |
| +-------------------------+----------------------------------+
| | query | query sequence |
| +-------------------------+----------------------------------+
| | query_end | query sequence end coordinate, |
| | | may be 'hmmto' or 'alito' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | query_start | query sequence start coordinate, |
| | | may be 'hmmfrom' or 'alifrom' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | query_strand | query sequence strand |
+-----------------+-------------------------+----------------------------------+
hmmer3-tab
==========
The following SearchIO objects attributes are provided:
+-----------------+-------------------------+----------------------------------+
| Object | Attribute | Column / Value |
+=================+=========================+==================================+
| QueryResult | accession | query accession (if present) |
| +-------------------------+----------------------------------+
| | description | query sequence description |
| +-------------------------+----------------------------------+
| | id | query name |
+-----------------+-------------------------+----------------------------------+
| Hit | accession | hit accession |
| +-------------------------+----------------------------------+
| | bias | hit-level bias |
| +-------------------------+----------------------------------+
| | bitscore | hit-level score |
| +-------------------------+----------------------------------+
| | description | hit sequence description |
| +-------------------------+----------------------------------+
| | cluster_num | clu column |
| +-------------------------+----------------------------------+
| | domain_exp_num | exp column |
| +-------------------------+----------------------------------+
| | domain_included_num | inc column |
| +-------------------------+----------------------------------+
| | domain_obs_num | dom column |
| +-------------------------+----------------------------------+
| | domain_reported_num | rep column |
| +-------------------------+----------------------------------+
| | env_num | env column |
| +-------------------------+----------------------------------+
| | evalue | hit-level evalue |
| +-------------------------+----------------------------------+
| | id | target name |
| +-------------------------+----------------------------------+
| | overlap_num | ov column |
| +-------------------------+----------------------------------+
| | region_num | reg column |
+-----------------+-------------------------+----------------------------------+
| HSP | bias | bias of the best domain |
| +-------------------------+----------------------------------+
| | bitscore | bitscore of the best domain |
| +-------------------------+----------------------------------+
| | evalue | evalue of the best domain |
+-----------------+-------------------------+----------------------------------+
hmmer3-domtab
=============
To parse domain table files, you must use the HMMER flavor that produced the
file. So instead of using 'hmmer3-domtab', use either 'hmmsearch3-domtab',
'hmmscan3-domtab', or 'phmmer3-domtab'.
The following SearchIO objects attributes are provided:
+-----------------+-------------------------+----------------------------------+
| Object | Attribute | Value |
+=================+=========================+==================================+
| QueryResult | accession | accession |
| +-------------------------+----------------------------------+
| | description | query sequence description |
| +-------------------------+----------------------------------+
| | id | query sequence ID |
| +-------------------------+----------------------------------+
| | seq_len | full length of query sequence |
+-----------------+-------------------------+----------------------------------+
| Hit | accession | accession |
| +-------------------------+----------------------------------+
| | bias | hit-level bias |
| +-------------------------+----------------------------------+
| | bitscore | hit-level score |
| +-------------------------+----------------------------------+
| | description | hit sequence description |
| +-------------------------+----------------------------------+
| | evalue | hit-level e-value |
| +-------------------------+----------------------------------+
| | id | hit sequence ID |
| +-------------------------+----------------------------------+
| | seq_len | length of hit sequence or HMM |
+-----------------+-------------------------+----------------------------------+
| HSP | acc_avg | expected accuracy per alignment |
| | | residue (acc column) |
| +-------------------------+----------------------------------+
| | bias | hsp-level bias |
| +-------------------------+----------------------------------+
| | bitscore | hsp-level score |
| +-------------------------+----------------------------------+
| | domain_index | the domain index set by HMMER |
| +-------------------------+----------------------------------+
| | env_end | end coordinate of the envelope |
| +-------------------------+----------------------------------+
| | env_start | start coordinate of the envelope |
| +-------------------------+----------------------------------+
| | evalue | hsp-level independent e-value |
| +-------------------------+----------------------------------+
| | evalue_cond | hsp-level conditional e-value |
+-----------------+-------------------------+----------------------------------+
| HSPFragment | hit_end | hit sequence end coordinate, may |
| (also via HSP) | | be 'hmmto' or 'alito' depending |
| | | on the HMMER flavor |
| +-------------------------+----------------------------------+
| | hit_start | hit sequence start coordinate, |
| | | may be 'hmmfrom' or 'alifrom' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | hit_strand | hit sequence strand |
| +-------------------------+----------------------------------+
| | query_end | query sequence end coordinate, |
| | | may be 'hmmto' or 'alito' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | query_start | query sequence start coordinate, |
| | | may be 'hmmfrom' or 'alifrom' |
| | | depending on the HMMER flavor |
| +-------------------------+----------------------------------+
| | query_strand | query sequence strand |
+-----------------+-------------------------+----------------------------------+
"""
from .hmmer2_text import Hmmer2TextParser, Hmmer2TextIndexer
from .hmmer3_domtab import Hmmer3DomtabParser, Hmmer3DomtabHmmhitParser, Hmmer3DomtabHmmqueryParser
from .hmmer3_domtab import Hmmer3DomtabHmmhitIndexer, Hmmer3DomtabHmmqueryIndexer
from .hmmer3_domtab import Hmmer3DomtabHmmhitWriter, Hmmer3DomtabHmmqueryWriter
from .hmmer3_text import Hmmer3TextParser, Hmmer3TextIndexer
from .hmmer3_tab import Hmmer3TabParser, Hmmer3TabIndexer, Hmmer3TabWriter
# if not used as a module, run the doctest
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()
|