Class: SequenceLogo::PPMLogo

Inherits:
Object
  • Object
show all
Defined in:
lib/sequence_logo/data_models/ppm_logo.rb

Overview

wrapper around PPM to make it possible to configure rendering in a flexible way

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ppm, options = {}) ⇒ PPMLogo

Returns a new instance of PPMLogo.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 8

def initialize(ppm, options = {})
  @ppm = ppm
  @words_count = options[:words_count]
  @icd_mode = options[:icd_mode]
  @enable_threshold_lines = options[:enable_threshold_lines]

  @ppm.words_count = @words_count  if @words_count
  unless ppm.words_count
    report "words count for PPM is undefined, assuming weblogo mode"
    @icd_mode = :weblogo
  end
end

Instance Attribute Details

#enable_threshold_linesObject (readonly)

Returns the value of attribute enable_threshold_lines.



6
7
8
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 6

def enable_threshold_lines
  @enable_threshold_lines
end

#icd_modeObject (readonly)

Returns the value of attribute icd_mode.



6
7
8
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 6

def icd_mode
  @icd_mode
end

#ppmObject (readonly)

Returns the value of attribute ppm.



6
7
8
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 6

def ppm
  @ppm
end

#words_countObject (readonly)

Returns the value of attribute words_count.



6
7
8
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 6

def words_count
  @words_count
end

Instance Method Details

#lengthObject



21
22
23
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 21

def length
  ppm.length
end

#logo_matrixObject



33
34
35
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 33

def logo_matrix
  ppm.(icd_mode)
end

#nameObject



25
26
27
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 25

def name
  ppm.name
end

#render(canvas_factory) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 37

def render(canvas_factory)
  canvas = LogoCanvas.new(canvas_factory)
  if icd_mode == :discrete
    canvas.background(Magick::HatchFill.new('white', 'white'))
    if enable_threshold_lines
      canvas.draw_threshold_line(ppm.get_line(ppm.icd2of4))
      canvas.draw_threshold_line(ppm.get_line(ppm.icdThc))
      canvas.draw_threshold_line(ppm.get_line(ppm.icdTlc))
    end
  else
    canvas.background(Magick::HatchFill.new('white', 'bisque'))
  end

  logo_matrix.each do |position|
    canvas.add_position_ordered( position_sorted_by_height(position) )
  end
  canvas.image
end

#revcompObject



29
30
31
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 29

def revcomp
  .new(ppm.revcomp, words_count: words_count, icd_mode: icd_mode, enable_threshold_lines: enable_threshold_lines)
end