]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/sam.rb
finished refactoring s/has_key?/[]/
[biopieces.git] / code_ruby / lib / maasha / sam.rb
index 5ef7de5fbd99a134bff197070402c5fc7b2b5af8..074b999aa58589ea962356655c7f3262ab3b05a3 100644 (file)
@@ -79,7 +79,7 @@ class Sam < Filesys
       bp[:SCORES] = sam[:SEQ].convert_phred2illumina!.qual
     end
 
-    if sam.has_key? :NM and sam[:NM].to_i > 0
+    if sam[:NM] and sam[:NM].to_i > 0
       bp[:NM] = sam[:NM]
       bp[:MD] = sam[:MD]
       bp[:ALIGN] = self.align_descriptors(sam)
@@ -264,7 +264,7 @@ class Sam < Filesys
 
     @header[:SQ][:SN] = Hash.new unless @header[:SQ][:SN].is_a? Hash
 
-    if @header[:SQ][:SN].has_key? seq_name
+    if @header[:SQ][:SN][seq_name]
       raise SamError, "Non-unique sequence name: #{seq_name}"
     else
       @header[:SQ][:SN][seq_name] = hash
@@ -292,13 +292,13 @@ class Sam < Filesys
       end
     end
 
-    if hash.has_key? :FO
+    if hash[:FO]
       unless hash[:FO] =~ /^\*|[ACMGRSVTWYHKDBN]+$/
         raise SamError, "Bad flow order: #{hash[:FO]}"
       end
     end
 
-    if hash.has_key? :PL
+    if hash[:PL]
       unless hash[:PL] =~ /^(CAPILLARY|LS454|ILLUMINA|SOLID|HELICOS|IONTORRENT|PACBIO)$/
         raise SamError, "Bad platform: #{hash[:PL]}"
       end
@@ -306,7 +306,7 @@ class Sam < Filesys
 
     @header[:RG][:ID] = Hash.new unless @header[:RG][:ID].is_a? Hash
 
-    if @header[:RG][:ID].has_key? id
+    if @header[:RG][:ID][id]
       raise SamError, "Non-unique read group identifier: #{id}"
     else
       @header[:RG][:ID][id] = hash
@@ -336,7 +336,7 @@ class Sam < Filesys
 
     @header[:PG][:ID] = Hash.new unless @header[:PG][:ID].is_a? Hash
 
-    if @header[:PG][:ID].has_key? id
+    if @header[:PG][:ID][id]
       raise SamError, "Non-unique program record identifier: #{id}"
     else
       @header[:PG][:ID][id] = hash
@@ -401,7 +401,7 @@ class Sam < Filesys
     fields[11 .. -1].each do |field|
       tag, type, val = field.split(':')
 
-      raise SamError, "Non-unique optional tag: #{tag}" if entry.has_key? tag.to_sym
+      raise SamError, "Non-unique optional tag: #{tag}" if entry[tag.to_sym]
 
       # A [!-~] Printable character
 
@@ -439,7 +439,7 @@ class Sam < Filesys
     raise SamError, "Bad rname: #{rname}" unless rname =~ /^(\*|[!-()+-<>-~][!-~]*)$/
 
     unless @header.empty? or rname == '*'
-      unless @header[:SQ][:SN].has_key? rname.to_sym
+      unless @header[:SQ][:SN][rname.to_sym]
         raise SamError, "rname not found in header hash: #{rname}"
       end
     end
@@ -462,7 +462,7 @@ class Sam < Filesys
     raise SamError, "Bad rnext: #{rnext}" unless rnext =~ /^(\*|=|[!-()+-<>-~][!-~]*)$/
 
     unless @header.empty? or rnext == '*' or rnext == '='
-      unless @header[:SQ][:SN].has_key? rnext.to_sym
+      unless @header[:SQ][:SN][rnext.to_sym]
         raise SamError, "rnext not found in header hash: #{rnext}"
       end
     end