]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed missing field problem in analyze_vals
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 19 Dec 2013 12:35:36 +0000 (12:35 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 19 Dec 2013 12:35:36 +0000 (12:35 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2282 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/analyze_vals

index 951f321f808e7b4e907d11d791e29c37cb1d64c2..40dd0e0239737e08b16eb75d815f6445a8ed7a72 100755 (executable)
@@ -76,22 +76,24 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       key = key.to_sym
       value = record[key]
 
-      stats[key][:sum]   ||= 0
-      stats[key][:count] ||= 0
-
-      if num = to_number(value)
-        stats[key][:min]   = min(stats[key][:min], num)
-        stats[key][:max]   = max(stats[key][:max], num)
-        stats[key][:type]  = :numeric
-        stats[key][:sum]  += num
-      else
-        stats[key][:min]   = min(stats[key][:min], value.length)
-        stats[key][:max]   = max(stats[key][:max], value.length)
-        stats[key][:type]  = :alphabetic
-        stats[key][:sum]  += value.length
+      if value
+        stats[key][:sum]   ||= 0
+        stats[key][:count] ||= 0
+
+        if num = to_number(value)
+          stats[key][:min]   = min(stats[key][:min], num)
+          stats[key][:max]   = max(stats[key][:max], num)
+          stats[key][:type]  = :numeric
+          stats[key][:sum]  += num
+        else
+          stats[key][:min]   = min(stats[key][:min], value.length)
+          stats[key][:max]   = max(stats[key][:max], value.length)
+          stats[key][:type]  = :alphabetic
+          stats[key][:sum]  += value.length
+        end
+
+        stats[key][:count] += 1
       end
-
-      stats[key][:count] += 1
     end
 
     output.puts record unless options[:no_stream]