Class: GeneValidator::LengthClusterValidationOutput

Inherits:
ValidationReport show all
Defined in:
lib/genevalidator/validation_length_cluster.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, query_length, limits, expected = :yes) ⇒ LengthClusterValidationOutput

Returns a new instance of LengthClusterValidationOutput.



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

def initialize(short_header, header, description, query_length, limits,
               expected = :yes)
  @short_header = short_header
  @header = header
  @description = description
  @limits       = limits
  @query_length = query_length
  @expected     = expected
  @result       = validation
  @plot_files   = []
  @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.' \
                  ' Here, we cluster the lengths of hit sequences and' \
                  ' compare the length of our query sequence to the most' \
                  ' dense cluster of hit lengths. '
  @explanation  = explain
  @conclusion   = conclude
end

Instance Attribute Details

#limitsObject (readonly)

Returns the value of attribute limits.



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

def limits
  @limits
end

#query_lengthObject (readonly)

Returns the value of attribute query_length.



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

def query_length
  @query_length
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

Instance Method Details

#concludeObject



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

def conclude
  if @result == :yes # i.e. if inside the main cluster
    'There is no reason to believe there is any problem with the length' \
    ' of the query sequence.'
  else
    size_diff = @query_length > @limits[1] ? 'long' : 'short'
    "This suggests that the query sequence may be too #{size_diff}."
  end
end

#explainObject



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

def explain
  diff = @result == :yes ? 'inside' : 'outside'
  'The most dense length-cluster of BLAST hits includes' \
  " sequences that are from #{@limits[0]} to #{@limits[1]} amino-acids" \
  " long. The query sequence is #{@query_length} amino-acids long and" \
  " is thus #{diff} the most dense length-cluster of BLAST hits."
end


54
55
56
# File 'lib/genevalidator/validation_length_cluster.rb', line 54

def print
  "#{@query_length} #{@limits.to_s.gsub(' ', ' ')}"
end

#validationObject



58
59
60
61
62
63
64
65
# File 'lib/genevalidator/validation_length_cluster.rb', line 58

def validation
  return if @limits.nil?
  if @query_length >= @limits[0] && @query_length <= @limits[1]
    :yes
  else
    :no
  end
end