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
#
207 208 209 210 211 212 213 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 207 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.
201 202 203 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 201 def dims @dims end |
#nrows ⇒ Object (readonly)
Returns the value of attribute nrows.
202 203 204 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 202 def nrows @nrows end |
Instance Method Details
#[](i, j) ⇒ Object
#
Bioroebe::SmithWaterman[]
#
248 249 250 251 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 248 def [](i, j) raise IndexOverflow if ((i >= nrows) || (j >= ncols)) @m[i][j] end |
#[]=(i, j, k) ⇒ Object
#
Bioroebe::SmithWaterman[]=
#
256 257 258 259 260 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 256 def []=(i, j, k) raise IndexOverflow if ((i >= nrows) || (j >= ncols)) @m[i][j] = k end |
#alignment? ⇒ Boolean Also known as: alignment
#
alignment?
#
241 242 243 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 241 def alignment? @alignment end |
#inspect ⇒ Object
#
inspect
#
232 233 234 235 236 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 232 def inspect @m.inject('') { |str, row| str += row.map {|entry| sprintf('%5d', entry) }.join(' ')+"\n" } end |
#ncols? ⇒ Boolean Also known as: ncols
#
ncols?
#
218 219 220 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 218 def ncols? @ncols end |
#score? ⇒ Boolean Also known as: score
#
score?
#
225 226 227 |
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 225 def score? @score end |