Class | Bio::HMMER::Report |
In: |
lib/bio/appl/hmmer/report.rb
|
Parent: | Object |
A parser class for a search report by hmmsearch or hmmpfam program in the HMMER package.
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
DELIMITER | = | RS = "\n//\n" | Delimiter of each entry for Bio::FlatFile support. |
domain_top_hits | [R] | statistics by hmmsearch. Keys are ‘Total memory’, ‘Satisfying E cutoff’ and ‘Total hits’. |
histogram | [R] | statistics by hmmsearch. |
hits | [R] | |
hsps | [R] | 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. |
parameter | [R] | A hash contains parameters used. Valid keys are ‘HMM file’ and ‘Sequence file’. |
program | [R] | A Hash contains program information used. Valid keys are ‘name’, ‘version’, ‘copyright’ and ‘license’. |
query_info | [R] | A hash contains the query information. Valid keys are ‘query sequence’, ‘Accession’ and ‘Description’. |
statistical_detail | [R] | statistics by hmmsearch. Keys are ‘mu’, ‘lambda’, ‘chi-sq statistic’ and ‘P(chi-square)’. |
total_seq_searched | [R] | statistics by hmmsearch. |
whole_seq_top_hits | [R] | statistics by hmmsearch. Keys are ‘Total memory’, ‘Satisfying E cutoff’ and ‘Total hits’. |
Parses a HMMER search report (by hmmpfam or hmmsearch program) and reutrns a Bio::HMMER::Report object.
hmmpfam_report = Bio::HMMER::Report.new(File.read("hmmpfam.out")) hmmsearch_report = Bio::HMMER::Report.new(File.read("hmmsearch.out"))
# File lib/bio/appl/hmmer/report.rb, line 156 156: def initialize(data) 157: 158: # The input data is divided into six data fields, i.e. header, 159: # query infomation, hits, HSPs, alignments and search statistics. 160: # However, header and statistics data don't necessarily exist. 161: subdata, is_hmmsearch = get_subdata(data) 162: 163: # if header exists, parse it 164: if subdata["header"] 165: @program, @parameter = parse_header_data(subdata["header"]) 166: else 167: @program, @parameter = [{}, {}] 168: end 169: 170: @query_info = parse_query_info(subdata["query"]) 171: @hits = parse_hit_data(subdata["hit"]) 172: @hsps = parse_hsp_data(subdata["hsp"], is_hmmsearch) 173: 174: if @hsps != [] 175: # split alignment subdata into an array of alignments 176: aln_ary = subdata["alignment"].split(/^\S+.*?\n/).slice(1..-1) 177: 178: # append alignment information to corresponding Hsp 179: aln_ary.each_with_index do |aln, i| 180: @hsps[i].set_alignment(aln) 181: end 182: end 183: 184: # assign each Hsp object to its parent Hit 185: hits_hash = {} 186: @hits.each do |hit| 187: hits_hash[hit.accession] = hit 188: end 189: @hsps.each do |hsp| 190: if hits_hash.has_key?(hsp.accession) 191: hits_hash[hsp.accession].append_hsp(hsp) 192: end 193: end 194: 195: # parse statistics (for hmmsearch) 196: if is_hmmsearch 197: @histogram, @statistical_detail, @total_seq_searched, \ 198: @whole_seq_top_hits, @domain_top_hits = \ 199: parse_stat_data(subdata["statistics"]) 200: end 201: 202: end
Iterates each hit (Bio::HMMER::Report::Hit).
# File lib/bio/appl/hmmer/report.rb, line 206 206: def each 207: @hits.each do |hit| 208: yield hit 209: end 210: end