Class: Bioroebe::Matrix
- Inherits:
-
Object
- Object
- Bioroebe::Matrix
- Defined in:
- lib/bioroebe/string_matching/smith_waterman.rb
Overview
Matrix
Constant Summary collapse
- IndexOverflow =
#
IndexOverflow
#
Class.new(StandardError)
Instance Attribute Summary collapse
-
#dims ⇒ Object
readonly
Returns the value of attribute dims.
-
#nrows ⇒ Object
readonly
Returns the value of attribute nrows.
Instance Method Summary collapse
-
#[](i, j) ⇒ Object
# === Bioroebe::SmithWaterman[] ========================================================================= #.
-
#[]=(i, j, k) ⇒ Object
# === Bioroebe::SmithWaterman[]= ========================================================================= #.
-
#alignment? ⇒ Boolean
(also: #alignment)
# === alignment? ========================================================================= #.
-
#initialize(mm, nn) ⇒ Matrix
constructor
# === initialize ========================================================================= #.
-
#inspect ⇒ Object
# === inspect ========================================================================= #.
-
#ncols? ⇒ Boolean
(also: #ncols)
# === ncols? ========================================================================= #.
-
#score? ⇒ Boolean
(also: #score)
# === score? ========================================================================= #.
Constructor Details
#initialize(mm, nn) ⇒ Matrix
#
initialize
#
211 212 213 214 215 216 217 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 211 def initialize(mm, nn) @dims = [mm, nn] @nrows = mm @ncols = nn @m = Array.new(mm) (1..mm).each {|i| @m[i-1] = Array.new(nn, 0)} end |
Instance Attribute Details
#dims ⇒ Object (readonly)
Returns the value of attribute dims.
205 206 207 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 205 def dims @dims end |
#nrows ⇒ Object (readonly)
Returns the value of attribute nrows.
206 207 208 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 206 def nrows @nrows end |
Instance Method Details
#[](i, j) ⇒ Object
#
Bioroebe::SmithWaterman[]
#
252 253 254 255 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 252 def [](i, j) raise IndexOverflow if ((i >= nrows) || (j >= ncols)) @m[i][j] end |
#[]=(i, j, k) ⇒ Object
#
Bioroebe::SmithWaterman[]=
#
260 261 262 263 264 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 260 def []=(i, j, k) raise IndexOverflow if ((i >= nrows) || (j >= ncols)) @m[i][j] = k end |
#alignment? ⇒ Boolean Also known as: alignment
#
alignment?
#
245 246 247 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 245 def alignment? @alignment end |
#inspect ⇒ Object
#
inspect
#
236 237 238 239 240 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 236 def inspect @m.inject('') { |str, row| str += row.map {|entry| sprintf('%5d', entry) }.join(' ')+"\n" } end |
#ncols? ⇒ Boolean Also known as: ncols
#
ncols?
#
222 223 224 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 222 def ncols? @ncols end |
#score? ⇒ Boolean Also known as: score
#
score?
#
229 230 231 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 229 def score? @score end |