Class: BigSimon::Pipeline
- Inherits:
-
Object
- Object
- BigSimon::Pipeline
- Defined in:
- lib/big_simon/pipeline.rb
Class Method Summary collapse
- .collate_host_results(results_table, programs) ⇒ Object
- .map_taxa(collated_results_table, virus_name_map, host_name_map) ⇒ Object
Class Method Details
.collate_host_results(results_table, programs) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/big_simon/pipeline.rb', line 32 def self.collate_host_results results_table, programs Rya::AbortIf.assert results_table.count == programs.count virus_host_scores = {} all_viruses = results_table.reduce(Set.new) { |acc, ht| acc + ht.keys } all_viruses.each do |virus| virus_host_scores[virus] = {} end results_table.each_with_index do |ht, idx| program = programs[idx] ht.each do |virus, host_scores| host_scores.each do |ht| host = ht[:host] score = ht[:score] scaled_score = ht[:scaled_score] unless virus_host_scores[virus].has_key? host virus_host_scores[virus][host] = { scores: {}, scaled_scores: {}} end virus_host_scores[virus][host][:scores][program] = score virus_host_scores[virus][host][:scaled_scores][program] = scaled_score end end end virus_host_scores end |
.map_taxa(collated_results_table, virus_name_map, host_name_map) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/big_simon/pipeline.rb', line 4 def self.map_taxa collated_results_table, virus_name_map, host_name_map new_results_table = {} collated_results_table.each do |virus_name, host_table| if virus_name_map.include? virus_name new_virus_name = virus_name_map[virus_name] else new_virus_name = virus_name end new_results_table[new_virus_name] = {} host_table.each do |host_name, score_table| if host_name_map.include? host_name new_host_name = host_name_map[host_name] else new_host_name = host_name end new_results_table[new_virus_name][new_host_name] = score_table end end new_results_table end |