Class: Bio::Fasta::Report

Inherits:
Object show all
Defined in:
lib/bio/appl/fasta/format10.rb

Overview

Summarized results of the fasta execution results.

Defined Under Namespace

Classes: Hit, Program

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Report

Returns a new instance of Report.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bio/appl/fasta/format10.rb', line 18

def initialize(data)
  # header lines - brief list of the hits
  if data.sub!(/.*\nThe best scores are/m, '')
    data.sub!(/(.*)\n\n>>>/m, '')
    @list = "The best scores are" + $1
  else
    data.sub!(/.*\n!!\s+/m, '')
    data.sub!(/.*/) { |x| @list = x; '' }
  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

Instance Attribute Details

#hitsObject (readonly)

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



56
57
58
# File 'lib/bio/appl/fasta/format10.rb', line 56

def hits
  @hits
end

#listObject (readonly)

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



46
47
48
# File 'lib/bio/appl/fasta/format10.rb', line 46

def list
  @list
end

#logObject (readonly)

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



50
51
52
# File 'lib/bio/appl/fasta/format10.rb', line 50

def log
  @log
end

#programObject (readonly)

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



53
54
55
# File 'lib/bio/appl/fasta/format10.rb', line 53

def program
  @program
end

Instance Method Details

#eachObject

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



59
60
61
62
63
# File 'lib/bio/appl/fasta/format10.rb', line 59

def each
  @hits.each do |x|
    yield x
  end
end

#lap_over(length_min = 0) ⇒ Object

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



77
78
79
80
81
82
83
# File 'lib/bio/appl/fasta/format10.rb', line 77

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) ⇒ Object

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



67
68
69
70
71
72
73
# File 'lib/bio/appl/fasta/format10.rb', line 67

def threshold(evalue_max = 0.1)
  list = []
  @hits.each do |x|
    list.push(x) if x.evalue < evalue_max
  end
  return list
end