Class: GeneValidator::DuplicationValidationOutput

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

Overview

Class that stores the validation output information

Instance Attribute Summary collapse

Attributes inherited from ValidationReport

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

Instance Method Summary collapse

Constructor Details

#initialize(short_header, header, description, pvalue, averages, threshold = 0.05, expected = :yes) ⇒ DuplicationValidationOutput

Returns a new instance of DuplicationValidationOutput.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/genevalidator/validation_duplication.rb', line 13

def initialize(short_header, header, description, pvalue, averages,
               threshold = 0.05, expected = :yes)
  @short_header, @header, @description = short_header, header, description
  @pvalue      = pvalue
  @threshold   = threshold
  @result      = validation
  @expected    = expected
  @average     = averages.mean
  @approach    = 'We expect each BLAST hit to match each region of the' \
                 ' query at most once. Here, we calculate the' \
                 ' distribution of hit coverage against the query' \
                 ' sequence and use the Wilcoxon test to determine if it' \
                 ' is higher than 1.'
  @explanation = explain
  @conclusion  = conclude
end

Instance Attribute Details

#averageObject (readonly)

Returns the value of attribute average.



9
10
11
# File 'lib/genevalidator/validation_duplication.rb', line 9

def average
  @average
end

#pvalueObject (readonly)

Returns the value of attribute pvalue.



8
9
10
# File 'lib/genevalidator/validation_duplication.rb', line 8

def pvalue
  @pvalue
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



10
11
12
# File 'lib/genevalidator/validation_duplication.rb', line 10

def threshold
  @threshold
end

Instance Method Details

#colorObject



53
54
55
# File 'lib/genevalidator/validation_duplication.rb', line 53

def color
  (validation == :yes) ? 'success' : 'danger'
end

#concludeObject



35
36
37
38
39
40
41
42
43
# File 'lib/genevalidator/validation_duplication.rb', line 35

def conclude
  if @result == :yes
    'This suggests that the query sequence contains no erroneous' \
    ' duplications.'
  else
    'The null hypothesis is rejected - thus a region of the query' \
    ' sequence is likely repeated more than once.'
  end
end

#explainObject



30
31
32
33
# File 'lib/genevalidator/validation_duplication.rb', line 30

def explain
  "The Wilcoxon test produced a p-value of #{prettify_evalue(@pvalue)}" \
  "#{(@result == :no) ? " (average = #{@average.round(2)})." : '.'}"
end


45
46
47
# File 'lib/genevalidator/validation_duplication.rb', line 45

def print
  "#{@pvalue.round(2)}"
end

#validationObject



49
50
51
# File 'lib/genevalidator/validation_duplication.rb', line 49

def validation
  (@pvalue > @threshold) ? :yes : :no
end