Class: GeneValidator::AlignmentValidationOutput

Inherits:
ValidationReport show all
Defined in:
lib/genevalidator/validation_alignment.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, gaps = 0, extra_seq = 0, consensus = 1, threshold = 20, expected = :yes) ⇒ AlignmentValidationOutput

Returns a new instance of AlignmentValidationOutput.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/genevalidator/validation_alignment.rb', line 19

def initialize(short_header, header, description, gaps = 0, extra_seq = 0,
               consensus = 1, threshold = 20, expected = :yes)

  @short_header = short_header
  @header = header
  @description = description
  @gaps         = (gaps * 100).round.to_s + '%'
  @extra_seq    = (extra_seq * 100).round.to_s + '%'
  @consensus    = (consensus * 100).round.to_s + '%'
  @threshold    = threshold
  @result       = validation
  @expected     = expected
  @plot_files   = []
  @approach     = 'We expect the query sequence to be similar to the top' \
                  ' ten BLAST hits. Here, we create a statistical' \
                  ' consensus model of those top hits and compare the' \
                  ' query to this model.'
  @explanation  = "The query sequence includes #{@consensus} amino-acid" \
                  ' residues present in the consensus model.' \
                  " #{@extra_seq} of residues in the query sequence are" \
                  ' absent from the consensus profile. ' \
                  " #{@gaps} of residues in the consensus profile are" \
                  ' absent from the query sequence.'
  @conclusion   = conclude
end

Instance Attribute Details

#consensusObject (readonly)

Returns the value of attribute consensus.



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

def consensus
  @consensus
end

#extra_seqObject (readonly)

Returns the value of attribute extra_seq.



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

def extra_seq
  @extra_seq
end

#gapsObject (readonly)

Returns the value of attribute gaps.



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

def gaps
  @gaps
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



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

def threshold
  @threshold
end

Instance Method Details

#concludeObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/genevalidator/validation_alignment.rb', line 45

def conclude
  if @result == :yes
    'There is no evidence based on the top 10 BLAST hits to suggest any' \
    ' problems with the query sequence.'
  else
    t = 'These results suggest that there may be some problems with' \
        ' the query sequence.'
    t1 = ''
    t2 = ''
    t3 = '' # Create empty string variables
    if (1 - consensus.to_i) > @threshold
      t1 = ' There is low conservation of residues between the' \
           ' statistical profile and the query sequence (the cut-off' \
           ' is 80%).'
    end
    if extra_seq.to_i > @threshold
      t2 = " The query sequence has a high percentage (#{@extra_seq})" \
           ' of extra residues absent from the statistical profile' \
           ' (the cut-off is 20%).'
    end
    if gaps.to_i > @threshold
      t3 = " The query sequence has a high percentage (#{@gaps}) of" \
           ' missing residues when compared to the statistical profile' \
           ' (the cut-off is 20%).'
    end
    t + t1 + t2 + t3
  end
end


74
75
76
77
# File 'lib/genevalidator/validation_alignment.rb', line 74

def print
  "#{@consensus} conserved; #{@extra_seq} extra;" \
  " #{@gaps} missing."
end

#validationObject



79
80
81
82
83
84
85
86
# File 'lib/genevalidator/validation_alignment.rb', line 79

def validation
  if gaps.to_i < @threshold && extra_seq.to_i < @threshold &&
     (1 - consensus.to_i) < @threshold
    :yes
  else
    :no
  end
end