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, #conclusion, #description, #errors, #expected, #explanation, #header, #message, #plot_files, #run_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.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/genevalidator/validation_duplication.rb', line 19

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.



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

def average
  @average
end

#pvalueObject (readonly)

Returns the value of attribute pvalue.



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

def pvalue
  @pvalue
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



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

def threshold
  @threshold
end

Instance Method Details

#colorObject



59
60
61
# File 'lib/genevalidator/validation_duplication.rb', line 59

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

#concludeObject



41
42
43
44
45
46
47
48
49
# File 'lib/genevalidator/validation_duplication.rb', line 41

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



36
37
38
39
# File 'lib/genevalidator/validation_duplication.rb', line 36

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


51
52
53
# File 'lib/genevalidator/validation_duplication.rb', line 51

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

#validationObject



55
56
57
# File 'lib/genevalidator/validation_duplication.rb', line 55

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