Class: GeneValidator::BlastRFValidationOutput

Inherits:
ValidationReport show all
Defined in:
lib/genevalidator/validation_blast_reading_frame.rb

Overview

Class that stores the validation output information

Instance Attribute Summary collapse

Attributes inherited from ValidationReport

#approach, #conclusion, #description, #errors, #expected, #explanation, #header, #message, #plot_files, #run_time, #short_header, #validation_result

Instance Method Summary collapse

Methods inherited from ValidationReport

#color

Constructor Details

#initialize(short_header, header, description, frames, expected = :yes) ⇒ BlastRFValidationOutput

Returns a new instance of BlastRFValidationOutput.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 16

def initialize(short_header, header, description, frames,
               expected = :yes)
  @short_header = short_header
  @header = header
  @description = description
  @frames = frames
  @expected     = expected
  @result       = validation

  @msg          = ''
  @exp_msg      = ''
  @total_hsp    = 0
  @frames.each do |x, y|
    @msg << "#{y}&nbsp;HSPs&nbsp;align&nbsp;in&nbsp;frame&nbsp;#{x}; "
    @exp_msg << "#{y} HSPs align in frame #{x}; "
    @total_hsp += y.to_i
  end

  @approach     = 'We expect the query sequence to encode a single gene,' \
                  ' thus it should contain one main Open Reading Frame' \
                  ' (ORF). All BLAST hits are thus expected to align' \
                  ' within this ORF.'
  @explanation  = explain
  @conclusion   = conclude
end

Instance Attribute Details

#framesObject (readonly)

Returns the value of attribute frames.



11
12
13
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 11

def frames
  @frames
end

#msgObject (readonly)

Returns the value of attribute msg.



12
13
14
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 12

def msg
  @msg
end

#resultObject (readonly)

Returns the value of attribute result.



14
15
16
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 14

def result
  @result
end

#total_hspObject (readonly)

Returns the value of attribute total_hsp.



13
14
15
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 13

def total_hsp
  @total_hsp
end

Instance Method Details

#concludeObject



54
55
56
57
58
59
60
61
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 54

def conclude
  if @result == :yes # i.e. if there is only one ORF...
    'This is as expected.'
  else
    'The HSPs align in mulitple reading frames, this suggests there may' \
    ' be a frame shift in the query sequence.'
  end
end

#explainObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 42

def explain
  t = "BLAST identified #{@total_hsp} High-scoring Segment Pairs" \
         ' (HSPs)'
  if @result == :yes # i.e. if there is only one ORF...
    frame = @frames.keys[0].to_s
    t1    = "; all of these align in frame #{frame}."
  else
    t1 = ": #{@exp_msg.gsub(/; $/, '')}."
  end
  t + t1
end


63
64
65
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 63

def print
  @msg.gsub(/; $/, '')
end

#validationObject



67
68
69
70
71
72
73
74
75
76
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 67

def validation
  # chack if there are different reading frames
  count_p = 0
  count_n = 0
  frames.each do |x, _y|
    count_p += 1 if x > 0
    count_n += 1 if x < 0
  end
  count_p > 1 || count_n > 1 ? :no : :yes
end