class GeneValidator::DuplicationValidationOutput

Class that stores the validation output information

Attributes

average[R]
pvalue[R]
result[R]
threshold[R]

Public Class Methods

new(short_header, header, description, pvalue, averages, threshold = 0.05, expected = :yes) click to toggle source
# File lib/genevalidator/validation_duplication.rb, line 20
def initialize(short_header, header, description, pvalue, averages,
               threshold = 0.05, expected = :yes)
  @short_header = short_header
  @header = header
  @description = 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

Public Instance Methods

color() click to toggle source
# File lib/genevalidator/validation_duplication.rb, line 62
def color
  validation == :yes ? 'success' : 'danger'
end
conclude() click to toggle source
# File lib/genevalidator/validation_duplication.rb, line 44
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
explain() click to toggle source
# File lib/genevalidator/validation_duplication.rb, line 39
def explain
  "The Wilcoxon test produced a p-value of #{prettify_evalue(@pvalue)}" \
  "#{@result == :no ? " (average = #{@average.round(2)})." : '.'}"
end
print() click to toggle source
validation() click to toggle source
# File lib/genevalidator/validation_duplication.rb, line 58
def validation
  @pvalue > @threshold ? :yes : :no
end

Private Instance Methods

prettify_evalue(evalue) click to toggle source

Copied from SequenceServer Formats evalue (a float expressed in scientific notation) to “a x b^c”.

# File lib/genevalidator/validation_duplication.rb, line 70
def prettify_evalue(evalue)
  evalue.to_s.sub(/(\d*\.\d*)e?([+-]\d*)?/) do
    s = format('%.3f', Regexp.last_match[1])
    s << " x 10<sup>#{Regexp.last_match[2]}</sup>" if Regexp.last_match[2]
    s
  end
end