Class: Bioroebe::Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/bioroebe/string_matching/smith_waterman.rb

Overview

Matrix

Constant Summary collapse

IndexOverflow =
#

IndexOverflow

#
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dimsObject (readonly)

Returns the value of attribute dims.



205
206
207
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 205

def dims
  @dims
end

#nrowsObject (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[]

#

Raises:



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[]=

#

Raises:



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?

#

Returns:

  • (Boolean)


245
246
247
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 245

def alignment?
  @alignment
end

#inspectObject

#

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?

#

Returns:

  • (Boolean)


222
223
224
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 222

def ncols?
  @ncols
end

#score?Boolean Also known as: score

#

score?

#

Returns:

  • (Boolean)


229
230
231
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 229

def score?
  @score
end