genevalidator 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +2 -0
- data/README.md +78 -30
- data/Rakefile +11 -8
- data/aux/app_template_footer.erb +1 -6
- data/aux/app_template_header.erb +12 -32
- data/aux/files/css/style.css +2 -8
- data/aux/files/js/plots.js +564 -576
- data/aux/files/js/script.js +10 -0
- data/aux/json_footer.erb +8 -0
- data/aux/json_header.erb +19 -0
- data/aux/json_query.erb +14 -0
- data/aux/template_footer.erb +9 -58
- data/aux/template_header.erb +18 -58
- data/aux/template_query.erb +8 -36
- data/bin/genevalidator +45 -32
- data/genevalidator.gemspec +11 -7
- data/lib/genevalidator.rb +75 -455
- data/lib/genevalidator/arg_validation.rb +78 -107
- data/lib/genevalidator/blast.rb +57 -60
- data/lib/genevalidator/clusterization.rb +15 -15
- data/lib/genevalidator/exceptions.rb +32 -5
- data/lib/genevalidator/get_raw_sequences.rb +70 -33
- data/lib/genevalidator/hsp.rb +1 -4
- data/lib/genevalidator/json_to_gv_results.rb +109 -0
- data/lib/genevalidator/output.rb +177 -185
- data/lib/genevalidator/pool.rb +2 -1
- data/lib/genevalidator/sequences.rb +3 -3
- data/lib/genevalidator/tabular_parser.rb +24 -18
- data/lib/genevalidator/validation.rb +279 -0
- data/lib/genevalidator/validation_alignment.rb +31 -47
- data/lib/genevalidator/validation_blast_reading_frame.rb +19 -18
- data/lib/genevalidator/validation_duplication.rb +23 -19
- data/lib/genevalidator/validation_gene_merge.rb +30 -65
- data/lib/genevalidator/validation_length_cluster.rb +14 -53
- data/lib/genevalidator/validation_length_rank.rb +10 -11
- data/lib/genevalidator/validation_open_reading_frame.rb +18 -19
- data/lib/genevalidator/validation_report.rb +2 -5
- data/lib/genevalidator/validation_test.rb +8 -4
- data/lib/genevalidator/version.rb +1 -1
- data/test/test_all_validations.rb +51 -66
- data/test/test_blast.rb +68 -51
- data/test/test_clusterization.rb +1 -1
- data/test/test_clusterization_2d.rb +19 -13
- data/test/test_extended_array_methods.rb +1 -1
- data/test/test_files/all_validations_mrna/mrna.blast_tab6 +1806 -0
- data/test/test_files/all_validations_mrna/mrna.blast_tab7 +1865 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml → mrna.blast_xml} +18642 -1
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.index → mrna.blast_xml.index} +300 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta → mrna.fa} +0 -0
- data/test/test_files/all_validations_mrna/mrna.raw_seq +3970 -0
- data/test/test_files/all_validations_mrna/{all_validations_mrna.fasta.blast_xml.raw_seq.idx → mrna.raw_seq.idx} +901 -1
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_tab → prot.blast_tab6} +416 -0
- data/test/test_files/all_validations_prot/prot.blast_tab7 +2400 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml → prot.blast_xml} +18299 -6723
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.index → prot.blast_xml.index} +408 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta → prot.fa} +0 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq → prot.raw_seq} +2735 -0
- data/test/test_files/all_validations_prot/{all_validations_prot.fasta.blast_xml.raw_seq.idx → prot.raw_seq.idx} +3032 -1808
- data/test/test_sequences.rb +46 -41
- data/test/test_validation_open_reading_frame.rb +318 -202
- data/test/test_validations.rb +48 -32
- metadata +76 -102
- data/doc/AliasDuplicationError.html +0 -134
- data/doc/AlignmentValidation.html +0 -1687
- data/doc/AlignmentValidationOutput.html +0 -659
- data/doc/Blast.html +0 -1905
- data/doc/BlastRFValidationOutput.html +0 -545
- data/doc/BlastReadingFrameValidation.html +0 -370
- data/doc/BlastUtils.html +0 -875
- data/doc/ClasspathError.html +0 -134
- data/doc/Cluster.html +0 -1316
- data/doc/DuplciationValidationOutput.html +0 -564
- data/doc/DuplicationValidation.html +0 -920
- data/doc/DuplicationValidationOutput.html +0 -564
- data/doc/FileNotFoundException.html +0 -134
- data/doc/GeneMergeValidation.html +0 -935
- data/doc/GeneMergeValidationOutput.html +0 -652
- data/doc/HierarchicalClusterization.html +0 -994
- data/doc/Hsp.html +0 -1485
- data/doc/InconsistentTabularFormat.html +0 -135
- data/doc/LengthClusterValidation.html +0 -982
- data/doc/LengthClusterValidationOutput.html +0 -515
- data/doc/LengthRankValidation.html +0 -496
- data/doc/LengthRankValidationOutput.html +0 -517
- data/doc/NoInternetError.html +0 -135
- data/doc/NoMafftInstallationError.html +0 -134
- data/doc/NoPIdentError.html +0 -134
- data/doc/NoValidationError.html +0 -134
- data/doc/NotEnoughHitsError.html +0 -135
- data/doc/ORFValidationOutput.html +0 -593
- data/doc/OpenReadingFrameValidation.html +0 -1107
- data/doc/OtherError.html +0 -123
- data/doc/Output.html +0 -1540
- data/doc/Pair.html +0 -309
- data/doc/PairCluster.html +0 -767
- data/doc/Plot.html +0 -837
- data/doc/QueryError.html +0 -134
- data/doc/ReportClassError.html +0 -135
- data/doc/Sequence.html +0 -1299
- data/doc/SequenceTypeError.html +0 -135
- data/doc/TabularEntry.html +0 -837
- data/doc/TabularParser.html +0 -1104
- data/doc/Validation.html +0 -2147
- data/doc/ValidationClassError.html +0 -134
- data/doc/ValidationOutput.html +0 -460
- data/doc/ValidationReport.html +0 -940
- data/doc/ValidationTest.html +0 -939
- data/doc/_index.html +0 -449
- data/doc/class_list.html +0 -54
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -338
- data/doc/file.README.html +0 -151
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -26
- data/doc/index.html +0 -151
- data/doc/js/app.js +0 -214
- data/doc/js/full_list.js +0 -178
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1505
- data/doc/top-level-namespace.html +0 -112
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab +0 -967
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.index +0 -967
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq +0 -4929
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_tab.raw_seq.idx +0 -1006
- data/test/test_files/all_validations_mrna/all_validations_mrna.fasta.blast_xml.raw_seq +0 -2075
- data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.index +0 -1864
- data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq +0 -42411
- data/test/test_files/all_validations_prot/all_validations_prot.fasta.blast_tab.raw_seq.idx +0 -3751
data/lib/genevalidator/output.rb
CHANGED
@@ -1,154 +1,135 @@
|
|
1
|
-
require 'genevalidator/version'
|
2
|
-
require 'fileutils'
|
3
1
|
require 'erb'
|
4
|
-
require '
|
5
|
-
require '
|
2
|
+
require 'fileutils'
|
3
|
+
require 'forwardable'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'genevalidator/version'
|
7
|
+
|
6
8
|
module GeneValidator
|
7
9
|
class Output
|
8
|
-
|
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
|
-
# +
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
68
|
-
|
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
|
-
|
78
|
-
|
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(' ', ' ')
|
79
48
|
end
|
80
49
|
end
|
81
50
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
132
|
-
|
133
|
-
|
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(' ', ' ') }
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
149
|
-
|
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
|
-
|
162
|
-
|
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
|
-
|
176
|
-
|
177
|
-
overall_evaluation.
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
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.
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
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
|
241
|
-
eval << "#{
|
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 -
|
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
|
-
|
260
|
-
average_time = value.x / (value.y
|
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
|
data/lib/genevalidator/pool.rb
CHANGED
@@ -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 }
|