]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed analyze_vals issue
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 25 Oct 2013 10:29:33 +0000 (10:29 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 25 Oct 2013 10:29:33 +0000 (10:29 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2251 74ccb610-7750-0410-82ae-013aeee3265d

bp_scripts/QA_Illumina_report.rb

index 6e0ba0a4c10c9ec695daf0c81dd1fb0c5f591c6c..cc6269f1d79280aaf06ba76a20a40d6af204bffb 100755 (executable)
@@ -23,13 +23,28 @@ require 'tmpdir'
 require 'base64'
 require 'erb'
 
+class Numeric
+  def commify
+    self.to_s.gsub(/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/, '\1,')
+  end
+end
+
 def parse_analysis(file)
   data = {}
 
   File.open(file, 'r') do |ios|
     ios.each do |line|
-      key, val = line.chomp.split(' ')
-      data[key] = val.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
+      key, val = line.chomp.split(': ')
+        begin Integer(val)
+          val = val.to_i.commify
+        rescue
+          begin Float(val)
+            val = val.to_f.commify
+          rescue
+          end
+        end
+
+      data[key] = val
     end
   end