]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/align.rb
finished refactoring s/has_key?/[]/
[biopieces.git] / code_ruby / lib / maasha / align.rb
index 2b63d91c3593eb93668e47e0f2ff8c0bd8824a24..c139fe8d89c30a773df458f23e730d2a73e992c4 100755 (executable)
@@ -102,7 +102,7 @@ class Align
 
     Open3.popen3("muscle", "-quiet") do |stdin, stdout, stderr|
       entries.each do |entry|
-        raise AlignError, "Duplicate sequence name: #{entry.seq_name}" if index.has_key? entry.seq_name
+        raise AlignError, "Duplicate sequence name: #{entry.seq_name}" if index[entry.seq_name]
 
         index[entry.seq_name] = entry.dup
 
@@ -262,7 +262,7 @@ class Align
     def na_add_entries
       @entries.each_with_index do |entry, i|
         @na_seq[true, i]  = NArray.to_na(entry.seq.downcase.tr(TR_NUC, TR_HEX), "byte")
-        @na_qual[true, i] = NArray.to_na(entry.qual, "byte") - SCORE_BASE if @has_qual
+        @na_qual[true, i] = NArray.to_na(entry.qual, "byte") - Seq::SCORE_BASE if @has_qual
       end
     end
 
@@ -270,14 +270,14 @@ class Align
     # NArrays.
     def consensus_calc
       if @has_qual
-        if @options.has_key? :quality_min
+        if @options[:quality_min]
           mask = mask_quality_min
 
           @na_seq  *= mask
           @na_qual *= mask
         end
 
-        if @options.has_key? :quality_mean
+        if @options[:quality_mean]
           mask = mask_quality_mean
 
           @na_seq  *= mask
@@ -285,21 +285,21 @@ class Align
         end
       end
 
-      if @options.has_key? :sequence_min
+      if @options[:sequence_min]
         mask = mask_sequence_min
 
         @na_seq  *= mask
         @na_qual *= mask if @has_qual
       end
 
-      if @options.has_key? :gap_max
+      if @options[:gap_max]
         mask = mask_gap_max
 
         @na_seq  *= mask
         @na_qual *= mask if @has_qual
       end
 
-      if @options.has_key? :residue_min
+      if @options[:residue_min]
         mask = mask_residue_min
 
         @na_seq  *= mask
@@ -375,7 +375,7 @@ class Align
 
     # Method to calculate a consensus quality from a Consensus object.
     def consensus_qual
-      (@na_qual.mean(1).round.to_type("byte") + SCORE_BASE).to_s
+      (@na_qual.mean(1).round.to_type("byte") + Seq::SCORE_BASE).to_s
     end
   end
 end