Skip to content

Instantly share code, notes, and snippets.

@rjpbonnal
Created March 24, 2011 19:48
Show Gist options
  • Save rjpbonnal/885723 to your computer and use it in GitHub Desktop.
Save rjpbonnal/885723 to your computer and use it in GitHub Desktop.
Esempio per il riassunto dei dati da sequenziamento
require 'yaml'
stats=YAML::load_stream(File.open("CD4_Th1_forward.stats"))
ary_stats=stats.documents
sum=0
ary_stats.each do |record|
sum += record[:stats] [: reads_total]
end
#in sum troverai il risultato
#----------
summary= Hash.new
reserved_keywords = [:reads_total, :reads_passed, :reads_rejected, :bases_passed_total, :bases_rejected_total, :bases_passed_with_b_quality, :bases_rejected_with_b_quality, :bases_passed_with_n, :bases_rejected_with_n]
reserved_keywords.each do |reserved_keyword|
summary[reserved_keyword]=0
end
ary_stats.each do |record|
summary.keys.each do |reserved_keyword|
summary[reserved_keyword]+=record[:stats][reserved_keyword]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment