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
# File 'lib/genevalidator/validation_gene_merge.rb', line 23

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.



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



81
82
83
# File 'lib/genevalidator/validation_gene_merge.rb', line 81

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

#concludeObject



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

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



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

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


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

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

#validationObject



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

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