]> git.donarmstrong.com Git - biopieces.git/commitdiff
added check for duplicate keys in replace_vals
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 8 Dec 2011 15:00:41 +0000 (15:00 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 8 Dec 2011 15:00:41 +0000 (15:00 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1700 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/replace_vals

index 356a6335a15fbade75213b71775abb5cdbec8af3..3290010768567150b2a30e47d9f409bcefef2c14 100755 (executable)
@@ -57,7 +57,12 @@ if options[:file]
     ios.each_line do |line|
       unless line[0] == '#'
         fields = line.chomp.split(delimiter)
-        replace_hash[fields[options[:search_col] - 1]] = fields[options[:replace_col] - 1]
+        k      = fields[options[:search_col] - 1]
+        v      = fields[options[:replace_col] - 1]
+
+        raise RunTimeError "duplicate key: #{k} found in file" if replace_hash.has_key? k
+
+        replace_hash[k] = v
       end
     end
   end