Class: SequenceLogo::PPMLogo
- Inherits:
-
Object
- Object
- SequenceLogo::PPMLogo
- 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
-
#enable_threshold_lines ⇒ Object
readonly
Returns the value of attribute enable_threshold_lines.
-
#icd_mode ⇒ Object
readonly
Returns the value of attribute icd_mode.
-
#ppm ⇒ Object
readonly
Returns the value of attribute ppm.
Instance Method Summary collapse
-
#initialize(ppm, options = {}) ⇒ PPMLogo
constructor
A new instance of PPMLogo.
- #length ⇒ Object
- #logo_matrix ⇒ Object
- #name ⇒ Object
- #render(canvas_factory) ⇒ Object
- #revcomp ⇒ Object
Constructor Details
#initialize(ppm, options = {}) ⇒ PPMLogo
Returns a new instance of PPMLogo.
8 9 10 11 12 |
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 8 def initialize(ppm, = {}) @ppm = ppm @icd_mode = [:icd_mode] @enable_threshold_lines = [:enable_threshold_lines] end |
Instance Attribute Details
#enable_threshold_lines ⇒ Object (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_mode ⇒ Object (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 |
#ppm ⇒ Object (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 |
Instance Method Details
#length ⇒ Object
14 15 16 |
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 14 def length ppm.length end |
#logo_matrix ⇒ Object
26 27 28 |
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 26 def logo_matrix ppm.get_logo(icd_mode) end |
#name ⇒ Object
18 19 20 |
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 18 def name ppm.name end |
#render(canvas_factory) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sequence_logo/data_models/ppm_logo.rb', line 30 def render(canvas_factory) canvas = LogoCanvas.new(canvas_factory) canvas.background(canvas_factory.background_fill) word_count = ppm.each_position.map{|pos| pos.inject(0.0, &:+) }.max if icd_mode == :discrete && enable_threshold_lines canvas.draw_threshold_line( scale(icd2of4(word_count), relative_to: icd4of4(word_count)) ) canvas.draw_threshold_line( scale(icdThc(word_count), relative_to: icd4of4(word_count)) ) canvas.draw_threshold_line( scale(icdTlc(word_count), relative_to: icd4of4(word_count)) ) end logo_matrix.each do |position| canvas.add_position_ordered( position_sorted_by_height(position) ) end canvas.image end |