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

#

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

#dimsObject (readonly)

Returns the value of attribute dims.


201
202
203
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 201

def dims
  @dims
end

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

#

Raises:


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

#

Raises:


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?

#

Returns:

  • (Boolean)

241
242
243
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 241

def alignment?
  @alignment
end

#inspectObject

#

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?

#

Returns:

  • (Boolean)

218
219
220
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 218

def ncols?
  @ncols
end

#score?Boolean Also known as: score

#

score?

#

Returns:

  • (Boolean)

225
226
227
# File 'lib/bioroebe/string_matching/smith_waterman.rb', line 225

def score?
  @score
end