From: martinahansen Date: Fri, 25 Oct 2013 10:29:33 +0000 (+0000) Subject: fixed analyze_vals issue X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=59c0c522f4a4452b0951f33794dc797c4bcaecfe fixed analyze_vals issue git-svn-id: http://biopieces.googlecode.com/svn/trunk@2251 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_scripts/QA_Illumina_report.rb b/bp_scripts/QA_Illumina_report.rb index 6e0ba0a..cc6269f 100755 --- a/bp_scripts/QA_Illumina_report.rb +++ b/bp_scripts/QA_Illumina_report.rb @@ -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