Class: GeneValidator::LengthRankValidationOutput

Inherits:
ValidationReport show all
Defined in:
lib/genevalidator/validation_length_rank.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, msg, query_length, no_of_hits, median, mean, smallest_hit, largest_hit, extreme_hits, percentage) ⇒ LengthRankValidationOutput

Returns a new instance of LengthRankValidationOutput.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/genevalidator/validation_length_rank.rb', line 23

def initialize(short_header, header, description, msg, query_length,
               no_of_hits, median, mean, smallest_hit, largest_hit,
               extreme_hits, percentage)
  @short_header = short_header
  @header = header
  @description = description
  @msg          = msg
  @query_length = query_length
  @no_of_hits   = no_of_hits
  @median       = median
  @mean         = mean
  @smallest_hit = smallest_hit
  @largest_hit  = largest_hit
  @extreme_hits = extreme_hits
  @percentage   = percentage

  @result       = validation
  @expected     = :yes
  @approach     = 'If the query sequence is well conserved and similar' \
                  ' sequences (BLAST hits) are correct, we can expect' \
                  ' query and hit sequences to have similar lengths.'
  @explanation  = explain
  @conclusion   = conclude
end

Instance Attribute Details

#extreme_hitsObject (readonly)

Returns the value of attribute extreme_hits.



19
20
21
# File 'lib/genevalidator/validation_length_rank.rb', line 19

def extreme_hits
  @extreme_hits
end

#largest_hitObject (readonly)

Returns the value of attribute largest_hit.



18
19
20
# File 'lib/genevalidator/validation_length_rank.rb', line 18

def largest_hit
  @largest_hit
end

#meanObject (readonly)

Returns the value of attribute mean.



16
17
18
# File 'lib/genevalidator/validation_length_rank.rb', line 16

def mean
  @mean
end

#medianObject (readonly)

Returns the value of attribute median.



15
16
17
# File 'lib/genevalidator/validation_length_rank.rb', line 15

def median
  @median
end

#msgObject (readonly)

Returns the value of attribute msg.



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

def msg
  @msg
end

#no_of_hitsObject (readonly)

Returns the value of attribute no_of_hits.



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

def no_of_hits
  @no_of_hits
end

#percentageObject (readonly)

Returns the value of attribute percentage.



20
21
22
# File 'lib/genevalidator/validation_length_rank.rb', line 20

def percentage
  @percentage
end

#query_lengthObject (readonly)

Returns the value of attribute query_length.



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

def query_length
  @query_length
end

#resultObject (readonly)

Returns the value of attribute result.



21
22
23
# File 'lib/genevalidator/validation_length_rank.rb', line 21

def result
  @result
end

#smallest_hitObject (readonly)

Returns the value of attribute smallest_hit.



17
18
19
# File 'lib/genevalidator/validation_length_rank.rb', line 17

def smallest_hit
  @smallest_hit
end

Instance Method Details

#concludeObject



63
64
65
66
67
68
69
70
# File 'lib/genevalidator/validation_length_rank.rb', line 63

def conclude
  if @result == :yes
    'There is no reason to believe there is any problem with the length' \
    ' of the query sequence.'
  else
    "The sequence may be #{@msg.gsub(' ', ' ')}."
  end
end

#explainObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/genevalidator/validation_length_rank.rb', line 48

def explain
  diff = @query_length > @median ? 'longer' : 'shorter'
  exp1 = "The query sequence is  #{@query_length} amino-acids long. BLAST" \
         " identified #{@no_of_hits} hit sequences with lengths from" \
         " #{@smallest_hit} to #{@largest_hit} amino-acids (median:" \
         " #{@median}; mean: #{@mean})."
  exp2 = if @extreme_hits != 0
           " #{@extreme_hits} of these hit sequences (i.e." \
                  " #{@percentage}%) are #{diff} than the query sequence."
         else
           " All hit sequences are #{diff} than the query sequence."
         end
  exp1 + exp2
end


72
73
74
# File 'lib/genevalidator/validation_length_rank.rb', line 72

def print
  @msg.empty? ? "#{@percentage}%" : "#{@percentage}% (#{@msg})"
end

#validationObject



76
77
78
# File 'lib/genevalidator/validation_length_rank.rb', line 76

def validation
  @msg.empty? ? :yes : :no
end