From: martinahansen Date: Thu, 8 Dec 2011 15:00:41 +0000 (+0000) Subject: added check for duplicate keys in replace_vals X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4118cd032c69453c2142559d8bb4c1b8d5b10fc4;p=biopieces.git added check for duplicate keys in replace_vals git-svn-id: http://biopieces.googlecode.com/svn/trunk@1700 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/replace_vals b/bp_bin/replace_vals index 356a633..3290010 100755 --- a/bp_bin/replace_vals +++ b/bp_bin/replace_vals @@ -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