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, #bg_color, #conclusion, #description, #errors, #expected, #explanation, #header, #message, #plot_files, #running_time, #short_header, #validation_result

Instance Method Summary collapse

Constructor Details

#initialize(short_header, header, description, slope, unimodality, expected = :no) ⇒ GeneMergeValidationOutput

radians



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

def initialize(short_header, header, description, slope, unimodality,
               expected = :no)
  @short_header, @header, @description = short_header, header, 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.



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

def result
  @result
end

#slopeObject (readonly)

Returns the value of attribute slope.



8
9
10
# File 'lib/genevalidator/validation_gene_merge.rb', line 8

def slope
  @slope
end

#threshold_downObject (readonly)

Returns the value of attribute threshold_down.



9
10
11
# File 'lib/genevalidator/validation_gene_merge.rb', line 9

def threshold_down
  @threshold_down
end

#threshold_upObject (readonly)

Returns the value of attribute threshold_up.



10
11
12
# File 'lib/genevalidator/validation_gene_merge.rb', line 10

def threshold_up
  @threshold_up
end

#unimodalityObject (readonly)

Returns the value of attribute unimodality.



11
12
13
# File 'lib/genevalidator/validation_gene_merge.rb', line 11

def unimodality
  @unimodality
end

Instance Method Details

#colorObject



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

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

#concludeObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/genevalidator/validation_gene_merge.rb', line 50

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).'
    if @result == :yes
      t << ' This suggests the query contains sequence from two or more' \
           ' different genes.'
    else
      t << ' There is no evidence that the query contains sequence from' \
           ' multiple genes.'
    end
    t
  end
end

#explainObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/genevalidator/validation_gene_merge.rb', line 38

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


68
69
70
# File 'lib/genevalidator/validation_gene_merge.rb', line 68

def print
  (@slope.nan?) ? 'Inf' : "#{@slope}"
end

#validationObject



72
73
74
# File 'lib/genevalidator/validation_gene_merge.rb', line 72

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