Class: Bio::HMMER::Report
Overview
A parser class for a search report by hmmsearch or hmmpfam program in the HMMER package.
Examples
Examples
#for multiple reports in a single output file (example.hmmpfam)
Bio::HMMER.reports(File.read("example.hmmpfam")) do |report|
report.program['name']
report.parameter['HMM file']
report.query_info['Query sequence']
report.hits.each do |hit|
hit.accession
hit.description
hit.score
hit.evalue
hit.hsps.each do |hsp|
hsp.accession
hsp.domain
hsp.evalue
hsp.midline
end
end
References
-
HMMER hmmer.wustl.edu/
Defined Under Namespace
Constant Summary collapse
- DELIMITER =
Delimiter of each entry for Bio::FlatFile support.
RS = "\n//\n"
Instance Attribute Summary collapse
-
#domain_top_hits ⇒ Object
readonly
statistics by hmmsearch.
-
#histogram ⇒ Object
readonly
statistics by hmmsearch.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#hsps ⇒ Object
readonly
Returns an Array of Bio::HMMER::Report::Hsp objects.
-
#parameter ⇒ Object
readonly
A hash contains parameters used.
-
#program ⇒ Object
readonly
A Hash contains program information used.
-
#query_info ⇒ Object
readonly
A hash contains the query information.
-
#statistical_detail ⇒ Object
readonly
statistics by hmmsearch.
-
#total_seq_searched ⇒ Object
readonly
statistics by hmmsearch.
-
#whole_seq_top_hits ⇒ Object
readonly
statistics by hmmsearch.
Instance Method Summary collapse
-
#each ⇒ Object
(also: #each_hit)
Iterates each hit (Bio::HMMER::Report::Hit).
-
#initialize(data) ⇒ Report
constructor
Parses a HMMER search report (by hmmpfam or hmmsearch program) and reutrns a Bio::HMMER::Report object.
Constructor Details
#initialize(data) ⇒ Report
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 |
# File 'lib/bio/appl/hmmer/report.rb', line 156 def initialize(data) # The input data is divided into six data fields, i.e. header, # query infomation, hits, HSPs, alignments and search statistics. # However, header and statistics data don't necessarily exist. subdata, is_hmmsearch = get_subdata(data) # if header exists, parse it if subdata["header"] @program, @parameter = parse_header_data(subdata["header"]) else @program, @parameter = [{}, {}] end @query_info = parse_query_info(subdata["query"]) @hits = parse_hit_data(subdata["hit"]) @hsps = parse_hsp_data(subdata["hsp"], is_hmmsearch) if @hsps != [] # split alignment subdata into an array of alignments aln_ary = subdata["alignment"].split(/^\S+.*?\n/).slice(1..-1) # append alignment information to corresponding Hsp aln_ary.each_with_index do |aln, i| @hsps[i].set_alignment(aln) end end # assign each Hsp object to its parent Hit hits_hash = {} @hits.each do |hit| hits_hash[hit.accession] = hit end @hsps.each do |hsp| if hits_hash.has_key?(hsp.accession) hits_hash[hsp.accession].append_hsp(hsp) end end # parse statistics (for hmmsearch) if is_hmmsearch @histogram, @statistical_detail, @total_seq_searched, \ @whole_seq_top_hits, @domain_top_hits = \ parse_stat_data(subdata["statistics"]) end end |
Instance Attribute Details
#domain_top_hits ⇒ Object (readonly)
statistics by hmmsearch. Keys are ‘Total memory’, ‘Satisfying E cutoff’ and ‘Total hits’.
144 145 146 |
# File 'lib/bio/appl/hmmer/report.rb', line 144 def domain_top_hits @domain_top_hits end |
#histogram ⇒ Object (readonly)
statistics by hmmsearch.
132 133 134 |
# File 'lib/bio/appl/hmmer/report.rb', line 132 def histogram @histogram end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
123 124 125 |
# File 'lib/bio/appl/hmmer/report.rb', line 123 def hits @hits end |
#hsps ⇒ Object (readonly)
Returns an Array of Bio::HMMER::Report::Hsp objects. Under special circumstances, some HSPs do not have parent Hit objects. If you want to access such HSPs, use this method.
129 130 131 |
# File 'lib/bio/appl/hmmer/report.rb', line 129 def hsps @hsps end |
#parameter ⇒ Object (readonly)
A hash contains parameters used. Valid keys are ‘HMM file’ and ‘Sequence file’.
116 117 118 |
# File 'lib/bio/appl/hmmer/report.rb', line 116 def parameter @parameter end |
#program ⇒ Object (readonly)
A Hash contains program information used. Valid keys are ‘name’, ‘version’, ‘copyright’ and ‘license’.
112 113 114 |
# File 'lib/bio/appl/hmmer/report.rb', line 112 def program @program end |
#query_info ⇒ Object (readonly)
A hash contains the query information. Valid keys are ‘query sequence’, ‘Accession’ and ‘Description’.
120 121 122 |
# File 'lib/bio/appl/hmmer/report.rb', line 120 def query_info @query_info end |
#statistical_detail ⇒ Object (readonly)
statistics by hmmsearch. Keys are ‘mu’, ‘lambda’, ‘chi-sq statistic’ and ‘P(chi-square)’.
135 136 137 |
# File 'lib/bio/appl/hmmer/report.rb', line 135 def statistical_detail @statistical_detail end |
#total_seq_searched ⇒ Object (readonly)
statistics by hmmsearch.
138 139 140 |
# File 'lib/bio/appl/hmmer/report.rb', line 138 def total_seq_searched @total_seq_searched end |
#whole_seq_top_hits ⇒ Object (readonly)
statistics by hmmsearch. Keys are ‘Total memory’, ‘Satisfying E cutoff’ and ‘Total hits’.
141 142 143 |
# File 'lib/bio/appl/hmmer/report.rb', line 141 def whole_seq_top_hits @whole_seq_top_hits end |
Instance Method Details
#each ⇒ Object Also known as: each_hit
Iterates each hit (Bio::HMMER::Report::Hit).
206 207 208 209 210 |
# File 'lib/bio/appl/hmmer/report.rb', line 206 def each @hits.each do |hit| yield hit end end |