]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed overflow bug in align.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 7 Mar 2012 09:26:10 +0000 (09:26 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 7 Mar 2012 09:26:10 +0000 (09:26 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1764 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/align.rb

index 3405c8b97a09da87dcba0cdfbcfd5019e7ce3c82..2619fb56fa1386229f1c74281f2aac70393abe61 100755 (executable)
@@ -272,7 +272,7 @@ class Align
     # Columns with less than sequence_min are 0'ed, otherwise set to 1.
     def mask_sequence_min
       mask  = NArray.byte(@cols, @rows) + 1
-      mask *= ((@na_seq > 0).sum(1) >= @options[:sequence_min])
+      mask *= ((@na_seq > 0).to_type("int").sum(1) >= @options[:sequence_min])
       mask
     end
 
@@ -282,12 +282,12 @@ class Align
     # Positions with residues above the residue_min are indicated with 1.
     def mask_residue_min
       cons_min = @options[:residue_min]
-      factor   = 1 / @na_seq.ne(0).sum(1).to_type("float")
+      factor   = 1 / @na_seq.ne(0).to_type("float").sum(1)
 
-      mask_A = @na_seq & BIT_A > 0
-      mask_T = @na_seq & BIT_T > 0
-      mask_C = @na_seq & BIT_C > 0
-      mask_G = @na_seq & BIT_G > 0
+      mask_A = (@na_seq & BIT_A > 0).to_type("int")
+      mask_T = (@na_seq & BIT_T > 0).to_type("int")
+      mask_C = (@na_seq & BIT_C > 0).to_type("int")
+      mask_G = (@na_seq & BIT_G > 0).to_type("int")
 
       mask_A = (mask_A * mask_A.sum(1)) * factor >= cons_min
       mask_T = (mask_T * mask_T.sum(1)) * factor >= cons_min
@@ -301,7 +301,7 @@ class Align
     # Columns with more gaps are 0'ed, others are set to 1.
     def mask_gap_max
       mask  = NArray.byte(@cols, @rows) + 1
-      mask *= @na_seq.ne(0).sum(1).to_type("float") / @rows > @options[:gap_max]
+      mask *= @na_seq.ne(0).to_type("float").sum(1) / @rows > @options[:gap_max]
 
       mask
     end