Class: Bioroebe::Dotplot

Inherits:
Base
  • Object
show all
Defined in:
lib/bioroebe/dotplots/dotplot.rb

Overview

Bioroebe::Dotplot

Constant Summary collapse

DEFAULT_X_AXIS =
#

DEFAULT_X_AXIS

#
14
DEFAULT_Y_AXIS =
#

DEFAULT_Y_AXIS

#
9

Constants inherited from Base

Base::NAMESPACE

Constants included from ColoursForBase

ColoursForBase::ARRAY_HTML_COLOURS_IN_USE

Instance Method Summary collapse

Methods inherited from Base

#append_what_into, #can_base_pair?, #convert_global_env, #delete_file, #directory_to_the_codon_tables?, #is_on_roebe?, #is_palindrome?, #main_encoding?, #mkdir, #move_file, #mv, #no_file_exists_at, #no_newlines, #project_yaml_directory?, #rds, #register_sigint, #return_pwd, #return_the_first_line_of_this_file, #word_wrap, #write_what_into

Methods included from BaseModule

#absolute_path, #default_file_read, #file_readlines

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from ColoursForBase

#colourize_this_aminoacid_sequence_for_the_commandline, #colourize_this_nucleotide_sequence, #disable_colours, #ecomment, #efancy, #egold, #enable_colours, #eorange, #eparse, #erev, #red, #remove_trailing_escape_part, #return_colour_for_nucleotides, #rev, #sdir, #set_will_we_use_colours, #sfancy, #sfile, #simp, #swarn, #use_colours?, #use_colours_within_the_bioroebe_namespace?

Methods included from InferTheNamespaceModule

#infer_the_namespace, #namespace?

Constructor Details

#initialize(x_axis = nil, y_axis = nil, run_already = true) ⇒ Dotplot

#

initialize

First argument is x-axis

#


38
39
40
41
42
43
44
45
46
47
# File 'lib/bioroebe/dotplots/dotplot.rb', line 38

def initialize(
    x_axis      = nil,
    y_axis      = nil,
    run_already = true
  )
  reset
  set_x_axis(x_axis)
  set_y_axis(y_axis)
  run if run_already
end

Instance Method Details

#display_gridObject

#

display_grid

#


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/bioroebe/dotplots/dotplot.rb', line 122

def display_grid
  display_x_axis
  display_y_axis # Show the y coordinate.
  display_x_axis
  print ' ' * (3.0 * @x_axis)+'-> (x axis)'; e
  zipped = string1?.zip(string2?)
  zipped.each {|first, second|
    if first == second
      output_match
    else # else don't make a dot.
      increase_indent_level
    end
  }
  run2
end

#display_x_axisObject

#

display_x_axis

#


111
112
113
114
115
116
117
# File 'lib/bioroebe/dotplots/dotplot.rb', line 111

def display_x_axis
  print '    '
  @x_axis.times {|entry|
    entry += 1
    ee "#{entry}  "
  }; e
end

#display_y_axisObject

#

display_y_axis

#


101
102
103
104
105
106
# File 'lib/bioroebe/dotplots/dotplot.rb', line 101

def display_y_axis
  @y_axis.times {|entry|
    entry += 1
    e "#{entry}#{N}#{N}"
  }
end

#increase_indent_levelObject

#

increase_indent_level

#


160
161
162
# File 'lib/bioroebe/dotplots/dotplot.rb', line 160

def increase_indent_level
  @indent_level += 2
end

#output_matchObject

#

output_match

#


167
168
169
170
# File 'lib/bioroebe/dotplots/dotplot.rb', line 167

def output_match
  ee (' '*@indent_level)+'*'+N # Make a dot in this case.
  increase_indent_level
end

#resetObject

#

reset (reset tag)

#


52
53
54
55
56
57
58
# File 'lib/bioroebe/dotplots/dotplot.rb', line 52

def reset
  super()
  # ======================================================================= #
  # === @indent_level
  # ======================================================================= #
  @indent_level = 0
end

#runObject

#

run (run tag)

#


175
176
177
# File 'lib/bioroebe/dotplots/dotplot.rb', line 175

def run
  display_grid
end

#run2Object

#

run2

Try it again.

#


143
144
145
146
# File 'lib/bioroebe/dotplots/dotplot.rb', line 143

def run2
  # First, we can show the x-axis:
  show_x_axis
end

#set_x_axis(i = nil) ⇒ Object

#

set_x_axis

#


63
64
65
66
67
68
69
70
# File 'lib/bioroebe/dotplots/dotplot.rb', line 63

def set_x_axis(i = nil)
  i = DEFAULT_X_AXIS if i.nil?
  i = i.join.strip if i.is_a? Array
  @string1 = i
  i = i.size if i.is_a? String
  i = i.to_i
  @x_axis = i
end

#set_y_axis(i = nil) ⇒ Object

#

set_y_axis

#


75
76
77
78
79
80
81
82
# File 'lib/bioroebe/dotplots/dotplot.rb', line 75

def set_y_axis(i = nil)
  i = DEFAULT_Y_AXIS if i.nil?
  i = i.join.strip if i.is_a? Array
  @string2 = i
  i = i.size if i.is_a? String
  i = i.to_i
  @y_axis = i
end

#show_x_axisObject

#

show_x_axis

#


151
152
153
154
155
# File 'lib/bioroebe/dotplots/dotplot.rb', line 151

def show_x_axis
  string1?.each {|char|
    ee "#{char} "
  }
end

#string1?Boolean

#

string1?

#

Returns:

  • (Boolean)


94
95
96
# File 'lib/bioroebe/dotplots/dotplot.rb', line 94

def string1?
  @string1.chars
end

#string2?Boolean

#

string2?

#

Returns:

  • (Boolean)


87
88
89
# File 'lib/bioroebe/dotplots/dotplot.rb', line 87

def string2?
  @string2.chars
end