needleman_wunsch_aligner 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e5a077fb1aa978f0c1b594a746fe4a5e025b21d
4
- data.tar.gz: fec7feb9ca6547fb4026ed33fc538964a509941f
3
+ metadata.gz: 5b038fdcd831fb5de1e7d749633c39c15220d0ae
4
+ data.tar.gz: f2d023f45f941cc6e04b9bd6954f882d00b32968
5
5
  SHA512:
6
- metadata.gz: 153c29214d4c90573521eb4ba5733d0441962f014d38a05b24857cbc12d8509446878140900f2ad6df3348fd923146d13a3902bd9e11b3fe8230c0a2eca63492
7
- data.tar.gz: 490fae39b38730a20b139e8a50fda22d64ed02cc0a62f0ea878ddf3dbde7d696b5875fbd4b75f70909566ded2a77abc6d5ddc47ec9933be78d644c4449bdb034
6
+ metadata.gz: cd404a2146c193de74202b83706c6d205ecfa3fcf2dc79b648b068ca283fb7ba67e79db593fbbd6b89114449cf396a8ddd8883a8375597664ed2225eae135746
7
+ data.tar.gz: 9c42647c54ce3d85908cfed82d4fdac5cc73afd5ceeb6346679a8a55025e7b9fb8f8c2d9968fedf4034f7348a2a00bf70ea741592605c7f70312aa12058f13ca
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.0.2
2
+
3
+ * Memoized computation of optimal alignment for better performance.
4
+
1
5
  ### 1.0.1
2
6
 
3
7
  * Added travis CI integration.
@@ -20,8 +20,10 @@ class NeedlemanWunschAligner
20
20
 
21
21
  # Returns two arrays that represent the optimal alignment.
22
22
  def get_optimal_alignment
23
- construct_score_matrix_and_traceback_matrix
24
- compute_optimal_alignment
23
+ @get_optimal_alignment ||= (
24
+ construct_score_matrix_and_traceback_matrix
25
+ compute_optimal_alignment
26
+ )
25
27
  end
26
28
 
27
29
  # This is a basic implementation of the scoring algorithm. See
@@ -67,7 +69,7 @@ class NeedlemanWunschAligner
67
69
  # @param col_width [Integer, optional], defaults to 3
68
70
  # @return [String]
69
71
  def inspect_matrix(which_matrix, col_width = 3)
70
- get_optimal_alignment if @score_matrix.nil?
72
+ get_optimal_alignment # make sure we have computed the matrices
71
73
  the_matrix = case which_matrix
72
74
  when :traceback
73
75
  @traceback_matrix
@@ -140,21 +142,22 @@ protected
140
142
  left = Array.new
141
143
  top = Array.new
142
144
  while row > 0 or col > 0
143
- if @traceback_matrix[row][col] == '⬉'
145
+ case @traceback_matrix[row][col]
146
+ when '⬉'
144
147
  left.push(@left_seq[row-1])
145
148
  top.push(@top_seq[col-1])
146
149
  row -= 1
147
150
  col -= 1
148
- elsif @traceback_matrix[row][col] == '←'
151
+ when '←'
149
152
  left.push(gap_indicator)
150
153
  top.push @top_seq[col-1]
151
154
  col -= 1
152
- elsif @traceback_matrix[row][col] == '↑'
155
+ when '↑'
153
156
  left.push @left_seq[row-1]
154
157
  top.push(gap_indicator)
155
158
  row -= 1
156
159
  else
157
- puts "something strange happened" # this shouldn't happen
160
+ raise "Handle this"
158
161
  end
159
162
  end
160
163
  [left.reverse, top.reverse]
@@ -1,3 +1,3 @@
1
1
  class NeedlemanWunschAligner
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: needleman_wunsch_aligner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Hund