genevalidator 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +2 -0
  4. data/README.md +78 -30
  5. data/Rakefile +11 -8
  6. data/aux/app_template_footer.erb +1 -6
  7. data/aux/app_template_header.erb +12 -32
  8. data/aux/files/css/style.css +2 -8
  9. data/aux/files/js/plots.js +564 -576
  10. data/aux/files/js/script.js +10 -0
  11. data/aux/json_footer.erb +8 -0
  12. data/aux/json_header.erb +19 -0
  13. data/aux/json_query.erb +14 -0
  14. data/aux/template_footer.erb +9 -58
  15. data/aux/template_header.erb +18 -58
  16. data/aux/template_query.erb +8 -36
  17. data/bin/genevalidator +45 -32
  18. data/genevalidator.gemspec +11 -7
  19. data/lib/genevalidator.rb +75 -455
  20. data/lib/genevalidator/arg_validation.rb +78 -107
  21. data/lib/genevalidator/blast.rb +57 -60
  22. data/lib/genevalidator/clusterization.rb +15 -15
  23. data/lib/genevalidator/exceptions.rb +32 -5
  24. data/lib/genevalidator/get_raw_sequences.rb +70 -33
  25. data/lib/genevalidator/hsp.rb +1 -4
  26. data/lib/genevalidator/json_to_gv_results.rb +109 -0
  27. data/lib/genevalidator/output.rb +177 -185
  28. data/lib/genevalidator/pool.rb +2 -1
  29. data/lib/genevalidator/sequences.rb +3 -3
  30. data/lib/genevalidator/tabular_parser.rb +24 -18
  31. data/lib/genevalidator/validation.rb +279 -0
  32. data/lib/genevalidator/validation_alignment.rb +31 -47
  33. data/lib/genevalidator/validation_blast_reading_frame.rb +19 -18
  34. data/lib/genevalidator/validation_duplication.rb +23 -19
  35. data/lib/genevalidator/validation_gene_merge.rb +30 -65
  36. data/lib/genevalidator/validation_length_cluster.rb +14 -53
  37. data/lib/genevalidator/validation_length_rank.rb +10 -11
  38. data/lib/genevalidator/validation_open_reading_frame.rb +18 -19
  39. data/lib/genevalidator/validation_report.rb +2 -5
  40. data/lib/genevalidator/validation_test.rb +8 -4
  41. data/lib/genevalidator/version.rb +1 -1
  42. data/test/test_all_validations.rb +51 -66
  43. data/test/test_blast.rb +68 -51
  44. data/test/test_clusterization.rb +1 -1
  45. data/test/test_clusterization_2d.rb +19 -13
  46. data/test/test_extended_array_methods.rb +1 -1
  47. data/test/test_files/all_validations_mrna/mrna.blast_tab6 +1806 -0
  48. data/test/test_files/all_validations_mrna/mrna.blast_tab7 +1865 -0
  49. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml → mrna.blast_xml} +18642 -1
  50. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.index → mrna.blast_xml.index} +300 -0
  51. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta → mrna.fa} +0 -0
  52. data/test/test_files/all_validations_mrna/mrna.raw_seq +3970 -0
  53. data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.raw_seq.idx → mrna.raw_seq.idx} +901 -1
  54. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_tab → prot.blast_tab6} +416 -0
  55. data/test/test_files/all_validations_prot/prot.blast_tab7 +2400 -0
  56. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml → prot.blast_xml} +18299 -6723
  57. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.index → prot.blast_xml.index} +408 -0
  58. data/test/test_files/all_validations_prot/{all_validations_prot.fasta → prot.fa} +0 -0
  59. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq → prot.raw_seq} +2735 -0
  60. data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq.idx → prot.raw_seq.idx} +3032 -1808
  61. data/test/test_sequences.rb +46 -41
  62. data/test/test_validation_open_reading_frame.rb +318 -202
  63. data/test/test_validations.rb +48 -32
  64. metadata +76 -102
  65. data/doc/AliasDuplicationError.html +0 -134
  66. data/doc/AlignmentValidation.html +0 -1687
  67. data/doc/AlignmentValidationOutput.html +0 -659
  68. data/doc/Blast.html +0 -1905
  69. data/doc/BlastRFValidationOutput.html +0 -545
  70. data/doc/BlastReadingFrameValidation.html +0 -370
  71. data/doc/BlastUtils.html +0 -875
  72. data/doc/ClasspathError.html +0 -134
  73. data/doc/Cluster.html +0 -1316
  74. data/doc/DuplciationValidationOutput.html +0 -564
  75. data/doc/DuplicationValidation.html +0 -920
  76. data/doc/DuplicationValidationOutput.html +0 -564
  77. data/doc/FileNotFoundException.html +0 -134
  78. data/doc/GeneMergeValidation.html +0 -935
  79. data/doc/GeneMergeValidationOutput.html +0 -652
  80. data/doc/HierarchicalClusterization.html +0 -994
  81. data/doc/Hsp.html +0 -1485
  82. data/doc/InconsistentTabularFormat.html +0 -135
  83. data/doc/LengthClusterValidation.html +0 -982
  84. data/doc/LengthClusterValidationOutput.html +0 -515
  85. data/doc/LengthRankValidation.html +0 -496
  86. data/doc/LengthRankValidationOutput.html +0 -517
  87. data/doc/NoInternetError.html +0 -135
  88. data/doc/NoMafftInstallationError.html +0 -134
  89. data/doc/NoPIdentError.html +0 -134
  90. data/doc/NoValidationError.html +0 -134
  91. data/doc/NotEnoughHitsError.html +0 -135
  92. data/doc/ORFValidationOutput.html +0 -593
  93. data/doc/OpenReadingFrameValidation.html +0 -1107
  94. data/doc/OtherError.html +0 -123
  95. data/doc/Output.html +0 -1540
  96. data/doc/Pair.html +0 -309
  97. data/doc/PairCluster.html +0 -767
  98. data/doc/Plot.html +0 -837
  99. data/doc/QueryError.html +0 -134
  100. data/doc/ReportClassError.html +0 -135
  101. data/doc/Sequence.html +0 -1299
  102. data/doc/SequenceTypeError.html +0 -135
  103. data/doc/TabularEntry.html +0 -837
  104. data/doc/TabularParser.html +0 -1104
  105. data/doc/Validation.html +0 -2147
  106. data/doc/ValidationClassError.html +0 -134
  107. data/doc/ValidationOutput.html +0 -460
  108. data/doc/ValidationReport.html +0 -940
  109. data/doc/ValidationTest.html +0 -939
  110. data/doc/_index.html +0 -449
  111. data/doc/class_list.html +0 -54
  112. data/doc/css/common.css +0 -1
  113. data/doc/css/full_list.css +0 -57
  114. data/doc/css/style.css +0 -338
  115. data/doc/file.README.html +0 -151
  116. data/doc/file_list.html +0 -56
  117. data/doc/frames.html +0 -26
  118. data/doc/index.html +0 -151
  119. data/doc/js/app.js +0 -214
  120. data/doc/js/full_list.js +0 -178
  121. data/doc/js/jquery.js +0 -4
  122. data/doc/method_list.html +0 -1505
  123. data/doc/top-level-namespace.html +0 -112
  124. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab +0 -967
  125. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.index +0 -967
  126. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq +0 -4929
  127. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq.idx +0 -1006
  128. data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_xml.raw_seq +0 -2075
  129. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.index +0 -1864
  130. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq +0 -42411
  131. data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq.idx +0 -3751
@@ -1,154 +1,135 @@
1
- require 'genevalidator/version'
2
- require 'fileutils'
3
1
  require 'erb'
4
- require 'yaml'
5
- require 'thread'
2
+ require 'fileutils'
3
+ require 'forwardable'
4
+ require 'json'
5
+
6
+ require 'genevalidator/version'
7
+
6
8
  module GeneValidator
7
9
  class Output
8
- attr_accessor :prediction_len
10
+ extend Forwardable
11
+ def_delegators GeneValidator, :opt, :config, :mutex, :mutex_html,
12
+ :mutex_json
9
13
  attr_accessor :prediction_def
10
14
  attr_accessor :nr_hits
11
15
 
12
16
  # list of +ValidationReport+ objects
13
17
  attr_accessor :validations
14
18
 
15
- attr_accessor :filename
16
- attr_accessor :html_path
17
- attr_accessor :yaml_path
18
19
  attr_accessor :idx
19
- attr_accessor :start_idx
20
20
 
21
21
  attr_accessor :overall_score
22
22
  attr_accessor :fails
23
23
  attr_accessor :successes
24
24
 
25
- attr_accessor :mutex
26
- attr_accessor :mutex_yaml
27
- attr_accessor :mutex_html
28
-
29
25
  ##
30
26
  # Initilizes the object
31
27
  # Params:
32
- # +mutex+: +Mutex+ for exclusive access to the console
33
- # +mutex_yaml+: +Mutex+ for exclusive access to the YAML file
34
- # +mutex_html+: +Mutex+ for exclusive access to the HTML file
35
- # +filename+: name of the fasta input file
36
- # +html_path+: path of the html folder
37
- # +yaml_path+: path where the yaml output wil be saved
38
- # +idx+: idnex of the current query
39
- # +start_idx+: number of the sequence from the file to start with
40
- def initialize(mutex, mutex_yaml, mutex_html, filename, html_path,
41
- yaml_path, idx = 0, start_idx = 0)
42
- @prediction_len = 0
43
- @prediction_def = 'no_definition'
44
- @nr_hits = 0
45
-
46
- @filename = filename
47
- @html_path = html_path
48
- @yaml_path = yaml_path
49
- @idx = idx
50
- @start_idx = start_idx
51
-
52
- @mutex = mutex
53
- @mutex_yaml = mutex_yaml
54
- @mutex_html = mutex_html
55
- end
28
+ # +current_idx+: index of the current query
29
+ def initialize(current_idx, no_of_hits, definition)
30
+ @opt = opt
31
+ @config = config
32
+ @config[:run_no] += 1
56
33
 
57
- def print_output_console
58
- if @idx == @start_idx
59
- header = sprintf('%3s|%s|%20s|%5s', 'No', 'Score', 'Identifier',
60
- 'No_Hits')
61
- validations.map do |v|
62
- header << "|#{v.short_header}"
63
- end
64
- puts header
65
- end
34
+ @prediction_def = definition
35
+ @nr_hits = no_of_hits
36
+ @idx = current_idx
66
37
 
67
- short_def = @prediction_def.scan(/([^ ]+)/)[0][0]
68
- validation_outputs = validations.map(&:print)
69
-
70
- output = sprintf('%3s|%d|%20s|%5s|', @idx, @overall_score,
71
- short_def, @nr_hits)
72
- validation_outputs.each do |item|
73
- output << item
74
- output << '|'
75
- end
38
+ @app_html = File.join(@config[:html_path], 'files/table.html')
39
+ end
76
40
 
77
- @mutex.synchronize do
78
- puts output.gsub('&nbsp;', ' ')
41
+ def print_output_console
42
+ mutex.synchronize do
43
+ print_console_header unless @config[:console_header_printed]
44
+ short_def = @prediction_def.scan(/([^ ]+)/)[0][0]
45
+ print format("%3s\t%5s\t%20s\t%7s\t", @idx, @overall_score, short_def,
46
+ @nr_hits)
47
+ puts validations.map(&:print).join("\t").gsub('&nbsp;', ' ')
79
48
  end
80
49
  end
81
50
 
82
- def print_output_file_yaml
83
- file_yaml = "#{@yaml_path}/#{@filename}.yaml"
84
- report = validations
85
- if @idx == @start_idx
86
- @mutex_yaml.synchronize do
87
- File.open(file_yaml, 'w') do |f|
88
- YAML.dump({ @prediction_def.scan(/([^ ]+)/)[0][0] => report }, f)
89
- end
90
- end
91
- else
92
- @mutex_yaml.synchronize do
93
- hash = {} # YAML.load_file(file_yaml)
94
- hash[@prediction_def.scan(/([^ ]+)/)[0][0]] = report
95
- File.open(file_yaml, 'a') do |f|
96
- new_report = hash.to_yaml
97
- f.write(new_report[4..new_report.length - 1])
98
- end
99
- end
100
- end
51
+ def print_console_header
52
+ @config[:console_header_printed] = true
53
+ print format("%3s\t%5s\t%20s\t%7s\t", 'No', 'Score', 'Identifier', 'No_Hits')
54
+ puts validations.map(&:short_header).join("\t")
101
55
  end
102
56
 
103
57
  def generate_html
104
- if @fails == 0
105
- bg_icon = 'success'
106
- else
107
- bg_icon = 'danger'
58
+ mutex_html.synchronize do
59
+ output_html = output_filename
60
+ query_erb = File.join(@config[:aux], 'template_query.erb')
61
+ template_file = File.open(query_erb, 'r').read
62
+ erb = ERB.new(template_file, 0, '>')
63
+ File.open(output_html, 'a') { |f| f.write(erb.result(binding)) }
64
+ File.open(@app_html, 'a') { |f| f.write(erb.result(binding)) }
108
65
  end
66
+ end
109
67
 
110
- index_file = "#{@html_path}/results.html"
111
- table_file = "#{@html_path}/files/table.html"
112
-
113
- aux_dir = File.join(File.dirname(File.expand_path(__FILE__)), '../../aux')
68
+ def output_filename
69
+ i = (@config[:run_no].to_f / @config[:output_max]).ceil
70
+ output_html = File.join(@config[:html_path], "results#{i}.html")
71
+ write_html_header(output_html)
72
+ output_html
73
+ end
114
74
 
115
- # if it's the first time I write in the html file
116
- if @idx == @start_idx
117
- @mutex_html.synchronize do
118
- template_header = File.join(aux_dir, 'template_header.erb')
119
- template_file = File.open(template_header, 'r').read
120
- erb = ERB.new(template_file, 0, '>')
75
+ def write_html_header(output_html)
76
+ head_erb = File.join(@config[:aux], 'template_header.erb')
77
+ head_table_erb = File.join(@config[:aux], 'app_template_header.erb')
78
+ set_up_html(head_erb, output_html) unless File.exist?(output_html)
79
+ set_up_html(head_table_erb, @app_html) unless File.exist?(@app_html)
80
+ end
121
81
 
122
- # Creating a Separate output file for the web app
123
- app_template_header = File.join(aux_dir, 'app_template_header.erb')
124
- table_template_file = File.open(app_template_header, 'r').read
125
- erb_table = ERB.new(table_template_file, 0, '>')
82
+ def set_up_html(erb_file, output_file)
83
+ return if File.exist?(output_file)
84
+ template_contents = File.open(erb_file, 'r').read
85
+ erb = ERB.new(template_contents, 0, '>')
86
+ File.open(output_file, 'w+') { |f| f.write(erb.result(binding)) }
87
+ end
126
88
 
127
- File.open(index_file, 'w+') do |file|
128
- file.write(erb.result(binding))
129
- end
89
+ def generate_json
90
+ mutex_json.synchronize do
91
+ row = { idx: @idx, overall_score: @overall_score,
92
+ definition: @prediction_def, no_hits: @nr_hits }
93
+ row = create_validation_hashes(row)
94
+ write_row_json(row)
95
+ @config[:json_output] << row
96
+ end
97
+ end
130
98
 
131
- File.open(table_file, 'w+') do |file|
132
- file.write(erb_table.result(binding))
133
- end
99
+ def create_validation_hashes(row)
100
+ row[:validations] = {}
101
+ @validations.each do |item|
102
+ val = { header: item.header, description: item.description,
103
+ status: item.color, print: item.print.gsub('&nbsp;', ' ') }
104
+ if item.color != 'warning'
105
+ explain = { approach: item.approach, explanation: item.explanation,
106
+ conclusion: item.conclusion }
107
+ val.merge!(explain)
134
108
  end
109
+ val[:graphs] = create_graphs_hash(item) unless item.plot_files.nil?
110
+ row[:validations][item.short_header] = val
135
111
  end
112
+ row
113
+ end
136
114
 
137
- toggle = "toggle#{@idx}"
138
-
139
- @mutex_yaml.synchronize do
140
- template_query = File.join(aux_dir, 'template_query.erb')
141
- template_file = File.open(template_query, 'r').read
142
- erb = ERB.new(template_file, 0, '>')
115
+ def create_graphs_hash(item)
116
+ graphs = []
117
+ item.plot_files.each do |g|
118
+ graphs << { data: g.data, type: g.type, title: g.title,
119
+ footer: g.footer, xtitle: g.xtitle,
120
+ ytitle: g.ytitle, aux1: g.aux1, aux2: g.aux2 }
121
+ end
122
+ graphs
123
+ end
143
124
 
144
- File.open(index_file, 'a') do |file|
145
- file.write(erb.result(binding))
146
- end
125
+ def write_row_json(row)
126
+ row_json = File.join(@config[:plot_dir],
127
+ "#{@config[:filename]}_#{@idx}.json")
128
+ File.open(row_json, 'w') { |f| f.write(row.to_json) }
129
+ end
147
130
 
148
- File.open(table_file, 'a') do |file|
149
- file.write(erb.result(binding))
150
- end
151
- end
131
+ def self.write_json_file(array, json_file)
132
+ File.open(json_file, 'w') { |f| f.write(array.to_json) }
152
133
  end
153
134
 
154
135
  ##
@@ -158,65 +139,66 @@ module GeneValidator
158
139
  # +all_query_outputs+: array with +ValidationTest+ objects
159
140
  # +html_path+: path of the html folder
160
141
  # +filemane+: name of the fasta input file
161
- # def self.print_footer(all_query_outputs, html_path, filename)
162
- def self.print_footer(no_queries, scores, good_predictions, bad_predictions,
163
- nee, no_mafft, no_internet, map_errors, running_times,
164
- html_path, filename)
165
- # compute the statistics
166
- # overall_evaluation = overall_evaluation(all_query_outputs, filename)
167
- overall_evaluation = overall_evaluation(no_queries, good_predictions,
168
- bad_predictions, nee, no_mafft,
169
- no_internet, map_errors,
170
- running_times)
171
-
172
- less = overall_evaluation[0]
173
- less = less.gsub("\n", '<br>').gsub("'", %q(\\\'))
142
+ def self.print_footer(overview, config)
143
+ overall_evaluation = overview(overview)
174
144
 
175
- # print to console
176
- evaluation = ''
177
- overall_evaluation.each { |e| evaluation << "\n#{e}" }
178
- puts evaluation
179
- puts ''
180
-
181
- # print to html
182
- # make the historgram with the resulted scores
183
- statistics_filename = "#{html_path}/files/json/#{filename}_statistics.json"
184
- f = File.open(statistics_filename, 'w')
185
-
186
- f.write(
187
- [scores.group_by { |a| a }.map { |k, vs| { 'key' => k,
188
- 'value' => vs.length,
189
- 'main' => false } }].to_json)
190
- f.close
191
-
192
- plot_statistics = Plot.new("files/json/#{filename}_statistics.json",
193
- :simplebars,
194
- 'Overall evaluation',
195
- '',
196
- 'validation score',
197
- 'number of queries',
198
- 10)
199
-
200
- evaluation = evaluation.gsub("\n", '<br>').gsub("'", %q(\\\'))
201
-
202
- index_file = "#{html_path}/results.html"
203
- table_file = "#{html_path}/files/table.html"
204
- aux_dir = File.join(File.dirname(File.expand_path(__FILE__)), '../../aux')
205
-
206
- template_footer = File.join(aux_dir, 'template_footer.erb')
207
- app_template_footer = File.join(aux_dir, 'app_template_footer.erb')
208
-
209
- template_file = File.open(template_footer, 'r').read
210
- erb = ERB.new(template_file, 0, '>')
211
- File.open(index_file, 'a+') do |file|
212
- file.write(erb.result(binding))
145
+ create_plot_json(overview[:scores], config[:plot_dir])
146
+
147
+ less = overall_evaluation[0].gsub("\n", '<br>').gsub("'", %q(\\\'))
148
+
149
+ eval = print_summary_to_console(overall_evaluation, config[:summary])
150
+ evaluation = eval.gsub("\n", '<br>').gsub("'", %q(\\\'))
151
+
152
+ footer_erb = File.join(config[:aux], 'template_footer.erb')
153
+
154
+ no_of_results_files = (config[:run_no].to_f / config[:output_max]).ceil
155
+ template_file = File.open(footer_erb, 'r').read
156
+ erb = ERB.new(template_file, 0, '>')
157
+
158
+ output_files = []
159
+ (1..no_of_results_files).each { |i| output_files << "results#{i}.html" }
160
+
161
+ (1..no_of_results_files).each do |i|
162
+ results_html = File.join(config[:html_path], "results#{i}.html")
163
+ File.open(results_html, 'a+') { |f| f.write(erb.result(binding)) }
213
164
  end
214
165
 
215
- table_footer_template = File.open(app_template_footer, 'r').read
216
- table_erb = ERB.new(table_footer_template, 0, '>')
217
- File.open(table_file, 'a+') do |file|
218
- file.write(table_erb.result(binding))
166
+ turn_off_sorting(config[:html_path]) if no_of_results_files > 1
167
+
168
+ # write footer for the app
169
+ app_footer_erb = File.join(config[:aux], 'app_template_footer.erb')
170
+ table_html = File.join(config[:html_path], 'files/table.html')
171
+ table_footer_template = File.open(app_footer_erb, 'r').read
172
+ table_erb = ERB.new(table_footer_template, 0, '>')
173
+ File.open(table_html, 'a+') { |f| f.write(table_erb.result(binding)) }
174
+ end
175
+
176
+ def self.turn_off_sorting(html_path)
177
+ script_file = File.join(html_path, 'files/js/script.js')
178
+ temp_file = File.join(html_path, 'files/js/script.temp.js')
179
+ File.open(temp_file, 'w') do |out_file|
180
+ out_file.puts File.readlines(script_file)[30..-1].join
219
181
  end
182
+ FileUtils.mv(temp_file, script_file)
183
+ end
184
+
185
+ def self.print_summary_to_console(overall_evaluation, summary)
186
+ # print to console
187
+ eval = ''
188
+ overall_evaluation.each { |e| eval << "\n#{e}" }
189
+ $stderr.puts eval if summary
190
+ $stderr.puts ''
191
+ eval
192
+ end
193
+
194
+ # make the historgram with the resulted scores
195
+ def self.create_plot_json(scores, plot_dir)
196
+ plot_file = File.join(plot_dir, 'overview.json')
197
+ data = [scores.group_by { |a| a }.map { |k, vs| { 'key' => k, 'value' => vs.length, 'main' => false } }]
198
+ hash = { data: data, type: :simplebars, title: 'Overall Evaluation',
199
+ footer: '', xtitle: 'Validation Score',
200
+ ytitle: 'Number of Queries', aux1: 10, aux2: '' }
201
+ File.open(plot_file, 'w') { |f| f.write hash.to_json }
220
202
  end
221
203
 
222
204
  ##
@@ -225,45 +207,55 @@ module GeneValidator
225
207
  # +all_query_outputs+: Array of +ValidationTest+ objects
226
208
  # Output
227
209
  # Array of Strigs with the reports
228
- def self.overall_evaluation(no_queries, good_scores, bad_scores,
229
- no_evidence, no_mafft, no_internet, map_errors,
230
- running_times)
231
- good_pred = (good_scores == 1) ? 'One' : "#{good_scores} are"
232
- bad_pred = (bad_scores == 1) ? 'One' : "#{bad_scores} are"
210
+ def self.overview(o)
211
+ eval = general_overview(o)
212
+ error_eval = errors_overview(o)
213
+ time_eval = time_overview(o)
214
+
215
+ overall_evaluation = [eval, error_eval, time_eval]
216
+ overall_evaluation.select { |e| e != '' }
217
+ end
218
+
219
+ def self.general_overview(o)
220
+ good_pred = (o[:good_scores] == 1) ? 'One' : "#{o[:good_scores]} are"
221
+ bad_pred = (o[:bad_scores] == 1) ? 'One' : "#{o[:bad_scores]} are"
233
222
 
234
223
  eval = "Overall Query Score Evaluation:\n" \
235
- "#{no_queries} predictions were validated, from which there" \
224
+ "#{o[:no_queries]} predictions were validated, from which there" \
236
225
  " were:\n" \
237
226
  "#{good_pred} good prediction(s),\n" \
238
227
  "#{bad_pred} possibly weak prediction(s).\n"
239
228
 
240
- if no_evidence != 0
241
- eval << "#{no_evidence} could not be evaluated due to the lack of" \
229
+ if o[:nee] != 0 # nee = no evidence
230
+ eval << "#{o[:nee]} could not be evaluated due to the lack of" \
242
231
  ' evidence.'
243
232
  end
233
+ eval
234
+ end
244
235
 
236
+ def self.errors_overview(o)
245
237
  # errors per validation
246
238
  error_eval = ''
247
- map_errors.each do |k, v|
239
+ o[:map_errors].each do |k, v|
248
240
  error_eval << "\nWe couldn't run #{k} Validation for #{v} queries"
249
241
  end
250
-
251
- if no_mafft >= (no_queries - no_evidence)
242
+ if o[:no_mafft] >= (o[:no_queries] - o[:nee])
252
243
  error_eval << "\nWe couldn't run MAFFT multiple alignment"
253
244
  end
254
- if no_internet >= (no_queries - no_evidence)
245
+ if o[:no_internet] >= (o[:no_queries] - o[:nee])
255
246
  error_eval << "\nWe couldn't make use of your internet connection"
256
247
  end
248
+ error_eval
249
+ end
257
250
 
251
+ def self.time_overview(o)
258
252
  time_eval = ''
259
- running_times.each do |key, value|
260
- average_time = value.x / (value.y + 0.0)
253
+ o[:run_time].each do |key, value|
254
+ average_time = value.x / (value.y).to_f
261
255
  time_eval << "\nAverage running time for #{key} Validation:" \
262
256
  " #{average_time.round(3)}s per validation"
263
257
  end
264
-
265
- overall_evaluation = [eval, error_eval, time_eval]
266
- overall_evaluation.select { |e| e != '' }
258
+ time_eval
267
259
  end
268
260
  end
269
261
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  # From http://burgestrand.se/code/ruby-thread-pool/
2
3
  #
3
4
  # Copyright © 2012, Kim Burgestrand kim@burgestrand.se
@@ -57,7 +58,7 @@ if $0 == __FILE__
57
58
  20.times do |i|
58
59
  p.schedule do
59
60
  sleep rand(4) + 2
60
- puts "Job #{i} finished by thread #{Thread.current[:id]}"
61
+ $stderr.puts "Job #{i} finished by thread #{Thread.current[:id]}"
61
62
  end
62
63
  end
63
64
  at_exit { p.shutdown }