Class: GeneValidator::GeneMergeValidationOutput

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

Overview

Class that stores the validation output information

Constant Summary collapse

UPPER_THRESHOLD =

These thresholds are emperically chosen.

1.2
LOWER_THRESHOLD =

radians

0.4

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, slope, unimodality, expected = :no) ⇒ GeneMergeValidationOutput

radians



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_gene_merge.rb', line 23

def initialize(short_header, header, description, slope, unimodality,
               expected = :no)
  @short_header = short_header
  @header = header
  @description = description
  @slope          = slope.round(1)
  @slope          = @slope.abs if @slope == -0.0
  @unimodality    = unimodality
  @threshold_down = LOWER_THRESHOLD
  @threshold_up   = UPPER_THRESHOLD
  @result         = validation
  @expected       = expected
  @plot_files     = []
  @approach       = 'We expect the query sequence to encode a single' \
                    ' protein-coding gene. Here, we analyse the' \
                    ' High-scoring Segment Pairs (HSPs) identified by' \
                    ' BLAST to determine whether the query includes' \
                    ' sequence from two or more genes.'
  @explanation    = explain
  @conclusion     = conclude
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#slopeObject (readonly)

Returns the value of attribute slope.



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

def slope
  @slope
end

#threshold_downObject (readonly)

Returns the value of attribute threshold_down.



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

def threshold_down
  @threshold_down
end

#threshold_upObject (readonly)

Returns the value of attribute threshold_up.



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

def threshold_up
  @threshold_up
end

#unimodalityObject (readonly)

Returns the value of attribute unimodality.



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

def unimodality
  @unimodality
end

Instance Method Details

#colorObject



83
84
85
# File 'lib/genevalidator/validation_gene_merge.rb', line 83

def color
  validation == :no ? 'success' : 'danger'
end

#concludeObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/genevalidator/validation_gene_merge.rb', line 57

def conclude
  if @unimodality
    'This suggest that the query sequence represents a single gene.'
  else
    diff = @result == :yes ? ' within' : ' outside'
    t = "This slope is #{diff} our empirically calculated thresholds" \
        ' (0.4 and 1.2).'
    t << if @result == :yes
           ' This suggests the query contains sequence from two or more' \
                ' different genes.'
         else
           ' There is no evidence that the query contains sequence from' \
                ' multiple genes.'
         end
    t
  end
end

#explainObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/genevalidator/validation_gene_merge.rb', line 45

def explain
  if @unimodality
    'The start coordinates and the end coordinates of HSPs are unimodally' \
    ' distributed.'
  else
    'The distribution of start and/or end-coordinates of HSPs are' \
    ' multi-modal. To detect potential problems we performed a linear'\
    ' regression (with coordinates weighted inversely proportionally to '\
    " hit strength). The resulting slope is #{@slope}."
  end
end


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

def print
  @slope.nan? ? 'Inf' : @slope.to_s
end

#validationObject



79
80
81
# File 'lib/genevalidator/validation_gene_merge.rb', line 79

def validation
  @slope > threshold_down && @slope < threshold_up ? :yes : :no
end