class Bio::Blast::WU::Report

Bio::Blast::WU::Report parses WU-BLAST default output and stores information in the data. It may contain a Bio::Blast::WU::Report::Iteration object. Because it inherits Bio::Blast::Default::Report, please also refer Bio::Blast::Default::Report.

Public Instance Methods

db() click to toggle source

Returns the name (filename or title) of the database.

# File lib/bio/appl/blast/wublast.rb, line 122
def db
  unless defined?(@db)
    if /Database *\: *(.*)/m =~ @f0database then
      a = $1.split(/^/)
      if a.size > 1 and /\ASearching\..+ done\s*\z/ =~ a[-1] then
        a.pop
      end
      if a.size > 1 and /\A +[\d\,]+ +sequences\; +[\d\,]+ total +letters\.?\s*\z/ =~ a[-1] then
        a.pop
      end
      @db = a.collect { |x| x.sub(/\s+\z/, '') }.join(' ')
    end
  end #unless
  @db
end
exit_code() click to toggle source

(WU-BLAST) Returns exit code for the execution. Returns an Integer or nil.

# File lib/bio/appl/blast/wublast.rb, line 79
def exit_code
  if defined? @exit_code then
    @exit_code
  else
    nil
  end
end
exit_code_message() click to toggle source

(WU-BLAST) Returns the message bundled with the exit code output. The message will be shown when WU-BLAST ignores a fatal error due to the command line option “-nonnegok”, “-novalidctxok”, or “-shortqueryok”.

Returns a String or nil.

# File lib/bio/appl/blast/wublast.rb, line 93
def exit_code_message
  if defined? @exit_code_message then
    @exit_code_message
  else
    nil
  end
end
expect() click to toggle source

Returns e-value threshold specified when BLAST was executed.

# File lib/bio/appl/blast/wublast.rb, line 50
def expect; parse_parameters; @parameters['E']; end
fatal_errors() click to toggle source

(WU-BLAST) Returns fatal error information. Returns nil or an array containing String.

# File lib/bio/appl/blast/wublast.rb, line 113
def fatal_errors
  if defined? @fatal_errors then
    @fatal_errors
  else
    nil
  end
end
notes() click to toggle source

(WU-BLAST) Returns “NOTE:” information. Returns nil or an array containing String.

# File lib/bio/appl/blast/wublast.rb, line 103
def notes
  if defined? @notes then
    @notes
  else
    nil
  end
end
notice() click to toggle source

Returns notice messages.

# File lib/bio/appl/blast/wublast.rb, line 62
def notice
  unless defined?(@notice)
    @notice = @f0notice.to_s.gsub(/\s+/, ' ').strip
  end #unless
  @notice
end
parameter_matrix() click to toggle source

Returns parameter matrix (???)

# File lib/bio/appl/blast/wublast.rb, line 44
def parameter_matrix
  parse_parameters
  @parameter_matrix
end
parameters() click to toggle source

Returns parameters (???)

# File lib/bio/appl/blast/wublast.rb, line 38
def parameters
  parse_parameters
  @parameters
end
query_record_number() click to toggle source

(WU-BLAST) Returns record number of the query. It may only be available for reports with multiple queries. Returns an Integer or nil.

# File lib/bio/appl/blast/wublast.rb, line 72
def query_record_number
  format0_parse_query
  @query_record_number
end
warnings() click to toggle source

Returns warning messages.

# File lib/bio/appl/blast/wublast.rb, line 53
def warnings
  unless defined?(@warnings)
    @warnings = @f0warnings
    iterations.each { |x| @warnings.concat(x.warnings) }
  end
  @warnings
end

Private Instance Methods

format0_parse_query() click to toggle source

Parses the query lines (begins with “Query = ”).

# File lib/bio/appl/blast/wublast.rb, line 140
def format0_parse_query
  unless defined?(@query_def)
    sc = StringScanner.new(@f0query)
    sc.skip(/\s*/)
    if sc.skip_until(/Query\= */) then
      q = []
      begin
        q << sc.scan(/.*/)
        sc.skip(/\s*^ ?/)
      end until !sc.rest or r = sc.skip(/ *\( *([\,\d]+) *letters *(\; *record *([\,\d]+) *)?\)\s*\z/)
      @query_len = sc[1].delete(',').to_i if r
      @query_record_number = sc[3].delete(',').to_i if r and sc[2]
      @query_def = q.join(' ')
    end
  end
end
format0_split_headers(data) click to toggle source

Splits headers.

# File lib/bio/appl/blast/wublast.rb, line 158
def format0_split_headers(data)
  @f0header = data.shift
  @f0references = []
  while r = data.first
    case r
    when /^Reference\: /
      @f0references.push data.shift
    when /^Copyright /
      @f0copyright = data.shift
    when /^Notice\: /
      @f0notice = data.shift
    when /^Query\= /
      break
    else
      break
    end
  end
  @f0query = data.shift
  @f0warnings ||= []
  while r = data.first
    case r
    when /^WARNING\: /
      @f0warnings << data.shift
    when /^NOTE\: /
      @notes ||= []
      @notes << data.shift
    else
      break #from the above "while"
    end
  end
  return if r = data.first and /\A(Parameters\:|EXIT CODE *\d+)/ =~ r
  if r = data.first and !(/^Database\: / =~ r)
    @f0translate_info = data.shift
  end
  @f0database = data.shift
end
format0_split_stat_params(data) click to toggle source

Splits statistics parameters.

# File lib/bio/appl/blast/wublast.rb, line 205
def format0_split_stat_params(data)
  @f0warnings ||= []
  while r = data.first and r =~ /^WARNING\: /
    @f0warnings << data.shift
  end
  @f0wu_params = []
  @f0wu_stats = []
  ary = @f0wu_params
  while r = data.shift 
    case r
    when /\AStatistics\:/
      ary = @f0wu_stats
    when /\AEXIT CODE *(\d+)\s*(.*)$/
      @exit_code = $1.to_i
      if $2 and !$2.empty? then
        @exit_code_message = r.sub(/\AEXIT CODE *(\d+)\s*/, '')
      end
      r = nil
    when /\AFATAL\: /
      @fatal_errors ||= []
      @fatal_errors.push r
      r = nil
    when /\AWARNING\: /
      @f0warnings ||= []
      @f0warnings << r
      r = nil
    end
    ary << r if r
  end
  @f0dbstat = F0dbstat.new(@f0wu_stats)
  itr = @iterations[0]
  x = @f0dbstat
  itr.instance_eval { @f0dbstat = x } if itr
end
parse_parameters() click to toggle source

Splits parameters.

# File lib/bio/appl/blast/wublast.rb, line 241
def parse_parameters
  unless defined?(@parse_parameters)
    @parameters = {}
    @parameter_matrix = []
    @f0wu_params.each do |x|
      if /^  Query/ =~ x then
        @parameter_matrix << x
      else
        x.split(/^/).each do |y|
          if /\A\s*(.+)\s*\=\s*(.*)\s*/ =~ y then
            @parameters[$1] = $2
          elsif /\AParameters\:/ =~ y then
            ; #ignore this
          elsif /\A\s*(.+)\s*$/ =~ y then
            @parameters[$1] = true
          end
        end
      end
    end
    if ev = @parameters['E'] then
      ev = '1' + ev if ev[0] == ?e
      @parameters['E'] = ev.to_f
    end
    @parse_parameters = true
  end
end