class Bio::Fasta::Report

Summarized results of the fasta execution results.

Constants

FLATFILE_SPLITTER

Splitter for Bio::FlatFile

Attributes

entry_overrun[R]

piece of next entry. Bio::FlatFile uses it.

hits[R]

Returns an Array of Bio::Fasta::Report::Hit objects.

list[R]

Returns the ‘The best scores are’ lines as a String.

log[R]

Returns the trailing lines including library size, execution date, fasta function used, and fasta versions as a String.

program[R]

Returns a Bio::Fasta::Report::Program object.

query_def[R]

Query definition. For older reports, the value may be nil.

query_len[R]

Query sequence length. For older reports, the value may be nil.

Public Class Methods

new(data) click to toggle source
    # File lib/bio/appl/fasta/format10.rb
 69 def initialize(data)
 70   # Split outputs containing multiple query sequences' results
 71   chunks = data.split(/^(\s*\d+\>\>\>.*)/, 3)
 72   if chunks.size >= 3 then
 73     if chunks[0].strip.empty? then
 74       qdef_line = chunks[1]
 75       data = chunks[1..2].join('')
 76       overruns = chunks[3..-1]
 77     elsif /^\>\>\>/ =~ chunks[0] then
 78       qdef_line = nil
 79       data = chunks.shift
 80       overruns = chunks
 81     else
 82       qdef_line = chunks[1]
 83       data = chunks[0..2].join('')
 84       overruns = chunks[3..-1]
 85     end
 86     @entry_overrun = overruns.join('')
 87     if qdef_line and
 88         /^ *\d+\>\>\>([^ ]+) .+ \- +(\d+) +(nt|aa)\s*$/ =~ qdef_line then
 89       @query_def = $1
 90       @query_len = $2.to_i
 91     end
 92   end
 93 
 94   # header lines - brief list of the hits
 95   if list_start = data.index("\nThe best scores are") then
 96     data = data[(list_start + 1)..-1]
 97     data.sub!(/(.*?)\n\n>>>/m, '')
 98     @list = $1
 99     data.sub!(/>>><<<(.*)$/m, '')
100   else
101     if list_start = data.index(/\n!!\s+/) then
102       data = data[list_start..-1]
103       data.sub!(/\n!!\s+/, '')
104       data.sub!(/.*/) { |x| @list = x; '' }
105     else
106       data = data.sub(/.*/) { |x| @list = x; '' }
107     end
108   end
109 
110   # body lines - fasta execution result
111   program, *hits = data.split(/\n>>/)
112 
113   # trailing lines - log messages of the execution
114   @log = hits.pop
115   @log.sub!(/.*<\n/m, '')
116   @log.strip!
117 
118   # parse results
119   @program = Program.new(program)
120   @hits = []
121 
122   hits.each do |x|
123     @hits.push(Hit.new(x))
124   end
125 end

Public Instance Methods

each() { |x| ... } click to toggle source

Iterates on each Bio::Fasta::Report::Hit object.

    # File lib/bio/appl/fasta/format10.rb
150 def each
151   @hits.each do |x|
152     yield x
153   end
154 end
lap_over(length_min = 0) click to toggle source

Returns an Array of Bio::Fasta::Report::Hit objects having longer overlap length than ‘length_min’.

    # File lib/bio/appl/fasta/format10.rb
168 def lap_over(length_min = 0)
169   list = []
170   @hits.each do |x|
171     list.push(x) if x.overlap > length_min
172   end
173   return list
174 end
threshold(evalue_max = 0.1) click to toggle source

Returns an Array of Bio::Fasta::Report::Hit objects having better evalue than ‘evalue_max’.

    # File lib/bio/appl/fasta/format10.rb
158 def threshold(evalue_max = 0.1)
159   list = []
160   @hits.each do |x|
161     list.push(x) if x.evalue < evalue_max
162   end
163   return list
164 end