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, line 69
def initialize(data)
  # Split outputs containing multiple query sequences' results
  chunks = data.split(/^(\s*\d+\>\>\>.*)/, 3)
  if chunks.size >= 3 then
    if chunks[0].strip.empty? then
      qdef_line = chunks[1]
      data = chunks[1..2].join('')
      overruns = chunks[3..-1]
    elsif /^\>\>\>/ =~ chunks[0] then
      qdef_line = nil
      data = chunks.shift
      overruns = chunks
    else
      qdef_line = chunks[1]
      data = chunks[0..2].join('')
      overruns = chunks[3..-1]
    end
    @entry_overrun = overruns.join('')
    if qdef_line and
        /^ *\d+\>\>\>([^ ]+) .+ \- +(\d+) +(nt|aa)\s*$/ =~ qdef_line then
      @query_def = $1
      @query_len = $2.to_i
    end
  end

  # header lines - brief list of the hits
  if list_start = data.index("\nThe best scores are") then
    data = data[(list_start + 1)..-1]
    data.sub!(/(.*)\n\n>>>/m, '')
    @list = $1
  else
    if list_start = data.index(/\n!!\s+/) then
      data = data[list_start..-1]
      data.sub!(/\n!!\s+/, '')
      data.sub!(/.*/) { |x| @list = x; '' }
    else
      data = data.sub(/.*/) { |x| @list = x; '' }
    end
  end

  # body lines - fasta execution result
  program, *hits = data.split(/\n>>/)

  # trailing lines - log messages of the execution
  @log = hits.pop
  @log.sub!(/.*<\n/m, '')
  @log.strip!

  # parse results
  @program = Program.new(program)
  @hits = []

  hits.each do |x|
    @hits.push(Hit.new(x))
  end
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, line 149
def each
  @hits.each do |x|
    yield x
  end
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, line 167
def lap_over(length_min = 0)
  list = []
  @hits.each do |x|
    list.push(x) if x.overlap > length_min
  end
  return list
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, line 157
def threshold(evalue_max = 0.1)
  list = []
  @hits.each do |x|
    list.push(x) if x.evalue < evalue_max
  end
  return list
end