From: martinahansen Date: Wed, 7 Mar 2012 09:26:10 +0000 (+0000) Subject: fixed overflow bug in align.rb X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a272c05de1cfb5de58beb7fa6ed1c76f348f8268;p=biopieces.git fixed overflow bug in align.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1764 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/lib/maasha/align.rb b/code_ruby/lib/maasha/align.rb index 3405c8b..2619fb5 100755 --- a/code_ruby/lib/maasha/align.rb +++ b/code_ruby/lib/maasha/align.rb @@ -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