quorum 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/.gitignore +3 -5
  2. data/.travis.yml +0 -2
  3. data/Gemfile.lock +2 -2
  4. data/HISTORY.md +12 -0
  5. data/Rakefile +13 -48
  6. data/app/models/quorum/blastn_job.rb +15 -22
  7. data/app/models/quorum/blastp_job.rb +15 -22
  8. data/app/models/quorum/blastx_job.rb +15 -22
  9. data/app/models/quorum/tblastn_job.rb +15 -22
  10. data/app/views/quorum/jobs/form/_blastn_form.html.erb +4 -4
  11. data/app/views/quorum/jobs/form/_blastp_form.html.erb +4 -4
  12. data/app/views/quorum/jobs/form/_blastx_form.html.erb +4 -4
  13. data/app/views/quorum/jobs/form/_tblastn_form.html.erb +4 -4
  14. data/app/views/quorum/jobs/templates/_blast_detailed_report_template.html.erb +6 -17
  15. data/db/migrate/20120918205556_rename_max_score_column.rb +15 -0
  16. data/lib/generators/templates/blast.rb +37 -31
  17. data/lib/quorum/version.rb +1 -1
  18. data/spec/config/quorum_settings.yml +55 -0
  19. data/spec/javascripts/fixtures/quorum_search_form.html +8 -8
  20. data/spec/javascripts/jobs_spec.js +8 -8
  21. data/spec/lib/tasks/travis.rake +120 -0
  22. data/spec/models/blastn_job_spec.rb +41 -22
  23. data/spec/models/blastp_job_spec.rb +41 -22
  24. data/spec/models/blastx_job_spec.rb +41 -22
  25. data/spec/models/job_spec.rb +1 -1
  26. data/spec/models/tblastn_job_spec.rb +41 -22
  27. data/spec/requests/jobs_spec.rb +8 -8
  28. data/spec/templates/blast_db_spec.rb +1 -1
  29. data/spec/templates/blast_spec.rb +1 -1
  30. metadata +7 -32
  31. data/spec/dummy/config/initializers/quorum_initializer.rb +0 -36
  32. data/spec/dummy/config/locales/quorum.en.yml +0 -8
  33. data/spec/dummy/config/quorum_settings.yml +0 -141
  34. data/spec/dummy/db/schema.rb +0 -213
  35. data/spec/dummy/quorum/bin/fetch +0 -115
  36. data/spec/dummy/quorum/bin/search +0 -141
  37. data/spec/dummy/quorum/blastdb/test/contigs.fa +0 -15
  38. data/spec/dummy/quorum/blastdb/test/peptides.fa +0 -4
  39. data/spec/dummy/quorum/blastdb/test.nhd +0 -2
  40. data/spec/dummy/quorum/blastdb/test.nhi +0 -0
  41. data/spec/dummy/quorum/blastdb/test.nhr +0 -0
  42. data/spec/dummy/quorum/blastdb/test.nin +0 -0
  43. data/spec/dummy/quorum/blastdb/test.nog +0 -0
  44. data/spec/dummy/quorum/blastdb/test.nsd +0 -2
  45. data/spec/dummy/quorum/blastdb/test.nsi +0 -0
  46. data/spec/dummy/quorum/blastdb/test.nsq +0 -0
  47. data/spec/dummy/quorum/blastdb/test.phd +0 -2
  48. data/spec/dummy/quorum/blastdb/test.phi +0 -0
  49. data/spec/dummy/quorum/blastdb/test.phr +0 -0
  50. data/spec/dummy/quorum/blastdb/test.pin +0 -0
  51. data/spec/dummy/quorum/blastdb/test.pog +0 -0
  52. data/spec/dummy/quorum/blastdb/test.psd +0 -2
  53. data/spec/dummy/quorum/blastdb/test.psi +0 -0
  54. data/spec/dummy/quorum/blastdb/test.psq +0 -0
  55. data/spec/dummy/quorum/lib/fetch_tools/blast_db.rb +0 -106
  56. data/spec/dummy/quorum/lib/logger.rb +0 -43
  57. data/spec/dummy/quorum/lib/search_tools/blast.rb +0 -452
  58. data/spec/dummy/quorum/lib/trollop.rb +0 -781
@@ -105,7 +105,7 @@ module Quorum
105
105
 
106
106
  @filter = @job.method(@job_association).call.filter
107
107
  @expectation = @job.method(@job_association).call.expectation
108
- @max_score = @job.method(@job_association).call.max_score
108
+ @max_target_seqs = @job.method(@job_association).call.max_target_seqs
109
109
  @min_score = @job.method(@job_association).call.min_bit_score
110
110
  @gapped_alignments = @job.method(@job_association).call.gapped_alignments
111
111
  @gap_opening_penalty = @job.method(@job_association).call.gap_opening_penalty
@@ -136,15 +136,17 @@ module Quorum
136
136
  "-outfmt 5 " <<
137
137
  "-num_threads #{@threads} " <<
138
138
  "-evalue #{@expectation} " <<
139
- "-max_target_seqs #{@max_score} " <<
139
+ "-max_target_seqs #{@max_target_seqs} " <<
140
140
  "-out #{@out} "
141
141
  if @gapped_alignments
142
- blastn << "-gapopen #{@gap_opening_penalty} "
143
- blastn << "-gapextend #{@gap_extension_penalty} "
142
+ if @gap_opening_penalty && @gap_extension_penalty
143
+ blastn << "-gapopen #{@gap_opening_penalty} "
144
+ blastn << "-gapextend #{@gap_extension_penalty} "
145
+ end
144
146
  else
145
147
  blastn << "-ungapped "
146
148
  end
147
- blastn << "-dust yes " if @filter
149
+ blastn << "-dust #{@filter ? 'yes' : 'no'} "
148
150
  blastn
149
151
  end
150
152
 
@@ -158,15 +160,17 @@ module Quorum
158
160
  "-outfmt 5 " <<
159
161
  "-num_threads #{@threads} " <<
160
162
  "-evalue #{@expectation} " <<
161
- "-max_target_seqs #{@max_score} " <<
163
+ "-max_target_seqs #{@max_target_seqs} " <<
162
164
  "-out #{@out} "
163
165
  if @gapped_alignments
164
- blastx << "-gapopen #{@gap_opening_penalty} "
165
- blastx << "-gapextend #{@gap_extension_penalty} "
166
+ if @gap_opening_penalty && @gap_extension_penalty
167
+ blastx << "-gapopen #{@gap_opening_penalty} "
168
+ blastx << "-gapextend #{@gap_extension_penalty} "
169
+ end
166
170
  else
167
171
  blastx << "-ungapped "
168
172
  end
169
- blastx << "-seg yes " if @filter
173
+ blastx << "-seg #{@filter ? 'yes' : 'no'} "
170
174
  blastx
171
175
  end
172
176
 
@@ -180,17 +184,19 @@ module Quorum
180
184
  "-outfmt 5 " <<
181
185
  "-num_threads #{@threads} " <<
182
186
  "-evalue #{@expectation} " <<
183
- "-max_target_seqs #{@max_score} " <<
187
+ "-max_target_seqs #{@max_target_seqs} " <<
184
188
  "-out #{@out} "
185
189
  if @gapped_alignments
186
- tblastn << "-gapopen #{@gap_opening_penalty} "
187
- tblastn << "-gapextend #{@gap_extension_penalty} "
190
+ if @gap_opening_penalty && @gap_extension_penalty
191
+ tblastn << "-gapopen #{@gap_opening_penalty} "
192
+ tblastn << "-gapextend #{@gap_extension_penalty} "
193
+ end
188
194
  tblastn << "-comp_based_stats D "
189
195
  else
190
196
  tblastn << "-ungapped "
191
197
  tblastn << "-comp_based_stats F "
192
198
  end
193
- tblastn << "-seg yes " if @filter
199
+ tblastn << "-seg #{@filter ? 'yes' : 'no'} "
194
200
  tblastn
195
201
  end
196
202
 
@@ -204,17 +210,19 @@ module Quorum
204
210
  "-outfmt 5 " <<
205
211
  "-num_threads #{@threads} " <<
206
212
  "-evalue #{@expectation} " <<
207
- "-max_target_seqs #{@max_score} " <<
213
+ "-max_target_seqs #{@max_target_seqs} " <<
208
214
  "-out #{@out} "
209
215
  if @gapped_alignments
210
- blastp << "-gapopen #{@gap_opening_penalty} "
211
- blastp << "-gapextend #{@gap_extension_penalty} "
216
+ if @gap_opening_penalty && @gap_extension_penalty
217
+ blastp << "-gapopen #{@gap_opening_penalty} "
218
+ blastp << "-gapextend #{@gap_extension_penalty} "
219
+ end
212
220
  blastp << "-comp_based_stats D "
213
221
  else
214
222
  blastp << "-ungapped "
215
223
  blastp << "-comp_based_stats F "
216
224
  end
217
- blastp << "-seg yes " if @filter
225
+ blastp << "-seg #{@filter ? 'yes' : 'no'} "
218
226
  blastp
219
227
  end
220
228
 
@@ -277,20 +285,18 @@ module Quorum
277
285
  # Set the attribute results to true for downstream processes.
278
286
  #
279
287
  def save_hsp_results
280
- if @data[:bit_score] && (@data[:bit_score].to_i > @min_score.to_i)
281
- @data[:results] = true
282
- @data["#{@algorithm}_job_id".to_sym] = @job.method(@job_association).call.job_id
283
-
284
- job_report = @job.method(@job_report_association).call.build(@data)
285
-
286
- unless job_report.save!
287
- @logger.log(
288
- "ActiveRecord",
289
- "Unable to save #{@algorithm} results to database.",
290
- 1,
291
- @tmp_files
292
- )
293
- end
288
+ @data[:results] = true
289
+ @data["#{@algorithm}_job_id".to_sym] = @job.method(@job_association).call.job_id
290
+
291
+ job_report = @job.method(@job_report_association).call.build(@data)
292
+
293
+ unless job_report.save!
294
+ @logger.log(
295
+ "ActiveRecord",
296
+ "Unable to save #{@algorithm} results to database.",
297
+ 1,
298
+ @tmp_files
299
+ )
294
300
  end
295
301
  end
296
302
 
@@ -1,3 +1,3 @@
1
1
  module Quorum
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -0,0 +1,55 @@
1
+ development:
2
+ blast:
3
+ remote: false
4
+ ssh_host:
5
+ ssh_user:
6
+ ssh_options:
7
+ bin: "%{RAILS_ROOT}/quorum/bin"
8
+ log_dir: "%{RAILS_ROOT}/quorum/log"
9
+ tmp_dir: "%{RAILS_ROOT}/quorum/tmp"
10
+ blast_db: "%{RAILS_ROOT}/quorum/blastdb"
11
+ blastn:
12
+ "tmp": test
13
+ blastx:
14
+ "tmp": test
15
+ tblastn:
16
+ "tmp": test
17
+ blastp:
18
+ "tmp": test
19
+ blast_threads: 4
20
+
21
+ test:
22
+ blast:
23
+ remote: false
24
+ ssh_host:
25
+ ssh_user:
26
+ ssh_options:
27
+ bin: "%{RAILS_ROOT}/quorum/bin"
28
+ log_dir: "%{RAILS_ROOT}/quorum/log"
29
+ tmp_dir: "%{RAILS_ROOT}/quorum/tmp"
30
+ blast_db: "%{RAILS_ROOT}/quorum/blastdb"
31
+ blastn:
32
+ "tmp": test
33
+ blastx:
34
+ "tmp": test
35
+ tblastn:
36
+ "tmp": test
37
+ blastp:
38
+ "tmp": test
39
+ blast_threads:
40
+
41
+ production:
42
+ blast:
43
+ remote: true
44
+ ssh_host:
45
+ ssh_user:
46
+ ssh_options:
47
+ bin:
48
+ log_dir:
49
+ tmp_dir:
50
+ blast_db:
51
+ blastn:
52
+ blastx:
53
+ tblastn:
54
+ blastp:
55
+ blast_threads:
@@ -82,10 +82,10 @@
82
82
  </tr>
83
83
  <tr>
84
84
  <td>
85
- <label for="job_blastn_job_attributes_max_score">Max score</label>
85
+ <label for="job_blastn_job_attributes_max_target_seqs">Max score</label>
86
86
  </td>
87
87
  <td>
88
- <input class="auto-hint" id="job_blastn_job_attributes_max_score" name="job[blastn_job_attributes][max_score]" size="15" title="25" type="text" />
88
+ <input class="auto-hint" id="job_blastn_job_attributes_max_target_seqs" name="job[blastn_job_attributes][max_target_seqs]" size="15" title="25" type="text" />
89
89
  </td>
90
90
  <td>
91
91
  <label for="job_blastn_job_attributes_gapped_alignments">Gapped alignments</label>
@@ -192,10 +192,10 @@
192
192
  </tr>
193
193
  <tr>
194
194
  <td>
195
- <label for="job_blastx_job_attributes_max_score">Max score</label>
195
+ <label for="job_blastx_job_attributes_max_target_seqs">Max score</label>
196
196
  </td>
197
197
  <td>
198
- <input class="auto-hint" id="job_blastx_job_attributes_max_score" name="job[blastx_job_attributes][max_score]" size="15" title="25" type="text" />
198
+ <input class="auto-hint" id="job_blastx_job_attributes_max_target_seqs" name="job[blastx_job_attributes][max_target_seqs]" size="15" title="25" type="text" />
199
199
  </td>
200
200
  <td>
201
201
  <label for="job_blastx_job_attributes_gapped_alignments">Gapped alignments</label>
@@ -304,10 +304,10 @@
304
304
  </tr>
305
305
  <tr>
306
306
  <td>
307
- <label for="job_tblastn_job_attributes_max_score">Max score</label>
307
+ <label for="job_tblastn_job_attributes_max_target_seqs">Max score</label>
308
308
  </td>
309
309
  <td>
310
- <input class="auto-hint" id="job_tblastn_job_attributes_max_score" name="job[tblastn_job_attributes][max_score]" size="15" title="25" type="text" />
310
+ <input class="auto-hint" id="job_tblastn_job_attributes_max_target_seqs" name="job[tblastn_job_attributes][max_target_seqs]" size="15" title="25" type="text" />
311
311
  </td>
312
312
  <td>
313
313
  <label for="job_tblastn_job_attributes_gapped_alignments">Gapped alignments</label>
@@ -414,10 +414,10 @@
414
414
  </tr>
415
415
  <tr>
416
416
  <td>
417
- <label for="job_blastp_job_attributes_max_score">Max score</label>
417
+ <label for="job_blastp_job_attributes_max_target_seqs">Max score</label>
418
418
  </td>
419
419
  <td>
420
- <input class="auto-hint" id="job_blastp_job_attributes_max_score" name="job[blastp_job_attributes][max_score]" size="15" title="25" type="text" />
420
+ <input class="auto-hint" id="job_blastp_job_attributes_max_target_seqs" name="job[blastp_job_attributes][max_target_seqs]" size="15" title="25" type="text" />
421
421
  </td>
422
422
  <td>
423
423
  <label for="job_blastp_job_attributes_gapped_alignments">Gapped alignments</label>
@@ -67,17 +67,17 @@ describe("Quorum Search Form", function() {
67
67
  $('#job_blastp_job_attributes_min_bit_score').attr('title')
68
68
  );
69
69
 
70
- expect($('#job_blastn_job_attributes_max_score')).toHaveValue(
71
- $('#job_blastn_job_attributes_max_score').attr('title')
70
+ expect($('#job_blastn_job_attributes_max_target_seqs')).toHaveValue(
71
+ $('#job_blastn_job_attributes_max_target_seqs').attr('title')
72
72
  );
73
- expect($('#job_blastx_job_attributes_max_score')).toHaveValue(
74
- $('#job_blastx_job_attributes_max_score').attr('title')
73
+ expect($('#job_blastx_job_attributes_max_target_seqs')).toHaveValue(
74
+ $('#job_blastx_job_attributes_max_target_seqs').attr('title')
75
75
  );
76
- expect($('#job_tblastn_job_attributes_max_score')).toHaveValue(
77
- $('#job_tblastn_job_attributes_max_score').attr('title')
76
+ expect($('#job_tblastn_job_attributes_max_target_seqs')).toHaveValue(
77
+ $('#job_tblastn_job_attributes_max_target_seqs').attr('title')
78
78
  );
79
- expect($('#job_blastp_job_attributes_max_score')).toHaveValue(
80
- $('#job_blastp_job_attributes_max_score').attr('title')
79
+ expect($('#job_blastp_job_attributes_max_target_seqs')).toHaveValue(
80
+ $('#job_blastp_job_attributes_max_target_seqs').attr('title')
81
81
  );
82
82
  });
83
83
 
@@ -0,0 +1,120 @@
1
+ # Travis Tasks
2
+ namespace :travis do
3
+ # Install
4
+ task :install do
5
+ Rake::Task["travis:create_db_config"].execute
6
+ Rake::Task["travis:quorum_install"].execute
7
+ Rake::Task["travis:copy_quorum_settings"].execute
8
+ Rake::Task["travis:create_dummy_tmp"].execute
9
+ end
10
+
11
+ # Remove
12
+ task :remove do
13
+ Rake::Task["travis:remove_db_config"].execute
14
+ Rake::Task["travis:remove_quorum"].execute
15
+ end
16
+
17
+ # Specs
18
+ task :spec do
19
+ Rake::Task["travis:install"].execute
20
+ ["rake spec", "rake app:jasmine:ci JASMINE_PORT=53331"].each do |cmd|
21
+ puts "Starting to run #{cmd}..."
22
+ system("export DISPLAY=:99.0 && bundle exec #{cmd}")
23
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
24
+ end
25
+ Rake::Task["travis:remove"].execute
26
+ end
27
+
28
+ # Install quorum, run migrations and prepare database.
29
+ task :quorum_install => :environment do
30
+ puts "Installing Quorum..."
31
+
32
+ app_dir = Dir.getwd
33
+ Dir.chdir(File.expand_path("../../../dummy", __FILE__))
34
+
35
+ blastdb_dir = File.expand_path("../../../../../data/tmp", __FILE__)
36
+
37
+ cmds = [
38
+ "rails g quorum:install",
39
+ "rails g quorum:views",
40
+ "rails g quorum:styles",
41
+ "rails g quorum:images",
42
+ "rake quorum:install:migrations",
43
+ "rake db:migrate",
44
+ "rake db:test:prepare",
45
+ "rake quorum:blastdb:build DIR=#{blastdb_dir}"
46
+ ]
47
+ cmds.each do |cmd|
48
+ system("bundle exec #{cmd}")
49
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
50
+ end
51
+
52
+ Dir.chdir(app_dir)
53
+ end
54
+
55
+ # Copy quorum_settings.yml for specs.
56
+ task :copy_quorum_settings do
57
+ settings = File.expand_path("../../../config/quorum_settings.yml", __FILE__)
58
+ config = File.expand_path("../../../dummy/config/quorum_settings.yml", __FILE__)
59
+ FileUtils.copy_file(settings, config)
60
+ end
61
+
62
+ # Remove quorum.
63
+ task :remove_quorum do
64
+ dummy = File.expand_path("../../../dummy", __FILE__)
65
+ if File.exists?(File.join(dummy, "quorum"))
66
+ FileUtils.rm_rf File.join(dummy, "quorum")
67
+ end
68
+ if File.exists?(File.join(dummy, "app", "assets", "images", "quorum"))
69
+ FileUtils.rm_rf File.join(dummy, "app", "assets", "images", "quorum")
70
+ end
71
+ if File.exists?(File.join(dummy, "app", "assets", "stylesheets", "quorum"))
72
+ FileUtils.rm_rf File.join(dummy, "app", "assets", "stylesheets", "quorum")
73
+ end
74
+ if File.exists?(File.join(dummy, "app", "views", "layouts", "quorum"))
75
+ FileUtils.rm_rf File.join(dummy, "app", "views", "layouts", "quorum")
76
+ end
77
+ if File.exists?(File.join(dummy, "app", "views", "quorum"))
78
+ FileUtils.rm_rf File.join(dummy, "app", "views", "quorum")
79
+ end
80
+ if File.exists?(File.join(dummy, "quorum"))
81
+ FileUtils.rm_rf File.join(dummy, "quorum")
82
+ end
83
+ if File.exists?(File.join(dummy, "config", "quorum_settings.yml"))
84
+ FileUtils.rm File.join(dummy, "config", "quorum_settings.yml")
85
+ end
86
+ if File.exists?(File.join(dummy, "config", "initializers", "quorum_initializer.rb"))
87
+ FileUtils.rm File.join(dummy, "config", "initializers", "quorum_initializer.rb")
88
+ end
89
+ if File.exists?(File.join(dummy, "config", "locales", "quorum.en.yml"))
90
+ FileUtils.rm File.join(dummy, "config", "locales", "quorum.en.yml")
91
+ end
92
+ end
93
+
94
+ # Create spec/dummy/config/database.yml for Travis.
95
+ task :create_db_config do
96
+ config = File.expand_path("../../../dummy/config", __FILE__)
97
+ File.open(File.join(config, "database.yml"), "w+") do |file|
98
+ file.puts "\ntest:\n adapter: mysql2\n encoding: utf8\n" <<
99
+ " reconnect: false\n database: quorum_test\n" <<
100
+ " pool: 5\n username: root\n password:\n" <<
101
+ " host: localhost\n"
102
+ end
103
+ end
104
+
105
+ # Remove spec/dummy/config/database.yml after Travis.
106
+ task :remove_db_config do
107
+ config = File.expand_path("../../../dummy/config", __FILE__)
108
+ if File.exists?(File.join(config, "database.yml"))
109
+ FileUtils.rm File.join(config, "database.yml")
110
+ end
111
+ end
112
+
113
+ # Create tmp directory for dummy app.
114
+ task :create_dummy_tmp do
115
+ FileUtils.mkdir_p File.expand_path("../../../dummy", __FILE__) +
116
+ "/tmp/" + "pids"
117
+ FileUtils.mkdir_p File.expand_path("../../../dummy", __FILE__) +
118
+ "/tmp/" + "cache"
119
+ end
120
+ end
@@ -6,12 +6,12 @@ describe Quorum::BlastnJob do
6
6
  @blastn_job = Quorum::BlastnJob.new()
7
7
  end
8
8
 
9
- it "fails validation with poorly formatted expectation (using error_on)" do
9
+ it "fails validation with poorly formatted expectation" do
10
10
  @blastn_job.expectation = "this is bad"
11
11
  @blastn_job.should have(1).error_on(:expectation)
12
12
  end
13
13
 
14
- it "passes validation with valid expectation values (using error_on)" do
14
+ it "passes validation with valid expectation values" do
15
15
  @blastn_job.expectation = 12
16
16
  @blastn_job.should have(0).errors_on(:expectation)
17
17
  @blastn_job.expectation = 12.1201
@@ -22,49 +22,49 @@ describe Quorum::BlastnJob do
22
22
  @blastn_job.should have(0).errors_on(:expectation)
23
23
  end
24
24
 
25
- it "fails validation with poorly formatted max_score (using error_on)" do
26
- @blastn_job.max_score = 12.34
27
- @blastn_job.should have(1).error_on(:max_score)
28
- @blastn_job.max_score = "not a number"
29
- @blastn_job.should have(1).error_on(:max_score)
25
+ it "fails validation with poorly formatted max_target_seqs" do
26
+ @blastn_job.max_target_seqs = 12.34
27
+ @blastn_job.should have(1).error_on(:max_target_seqs)
28
+ @blastn_job.max_target_seqs = "not a number"
29
+ @blastn_job.should have(1).error_on(:max_target_seqs)
30
30
  end
31
31
 
32
- it "passed validation with valid max_score (using error_on)" do
33
- @blastn_job.max_score = 1235
34
- @blastn_job.should have(0).errors_on(:max_score)
32
+ it "passed validation with valid max_target_seqs" do
33
+ @blastn_job.max_target_seqs = 1235
34
+ @blastn_job.should have(0).errors_on(:max_target_seqs)
35
35
  end
36
36
 
37
- it "fails validation with poorly formatted gap_opening_penalty (using error_on)" do
37
+ it "fails validation with poorly formatted gap_opening_penalty" do
38
38
  @blastn_job.gap_opening_penalty = "not a number"
39
39
  @blastn_job.should have(1).error_on(:gap_opening_penalty)
40
40
  @blastn_job.gap_opening_penalty = 100.10
41
41
  @blastn_job.should have(1).error_on(:gap_opening_penalty)
42
42
  end
43
43
 
44
- it "passed validation with valid gap_opening_penalty (using error_on)" do
45
- @blastn_job.max_score = 13
44
+ it "passed validation with valid gap_opening_penalty" do
45
+ @blastn_job.max_target_seqs = 13
46
46
  @blastn_job.should have(0).errors_on(:gap_opening_penalty)
47
47
  end
48
48
 
49
- it "fails validation with poorly formatted gap_extension_penalty (using error_on)" do
49
+ it "fails validation with poorly formatted gap_extension_penalty" do
50
50
  @blastn_job.gap_extension_penalty = "who are you?"
51
51
  @blastn_job.should have(1).error_on(:gap_extension_penalty)
52
52
  @blastn_job.gap_extension_penalty = 0.3
53
53
  @blastn_job.should have(1).error_on(:gap_extension_penalty)
54
54
  end
55
55
 
56
- it "passed validation with valid gap_extension_penalty (using error_on)" do
57
- @blastn_job.max_score = 456
56
+ it "passed validation with valid gap_extension_penalty" do
57
+ @blastn_job.max_target_seqs = 456
58
58
  @blastn_job.should have(0).errors_on(:gap_extension_penalty)
59
59
  end
60
60
 
61
- it "fails validation without selecting gap_opening_extension with gapped_alignment (using error_on)" do
61
+ it "passes validation without selecting gap_opening_extension with gapped_alignment" do
62
62
  @blastn_job.gapped_alignments = true
63
63
  @blastn_job.gap_opening_extension = ""
64
- @blastn_job.should have(1).error_on(:gap_opening_extension)
64
+ @blastn_job.should have(0).error_on(:gap_opening_extension)
65
65
  end
66
66
 
67
- it "fails validation without selecting gap_opening_extension with gapped_alignment (using error_on)" do
67
+ it "fails validation without selecting gap_opening_extension with gapped_alignment" do
68
68
  @blastn_job.gapped_alignments = true
69
69
  @blastn_job.gap_opening_extension = "11, 2"
70
70
  @blastn_job.should have(0).errors_on(:gap_opening_extension)
@@ -100,6 +100,25 @@ describe Quorum::BlastnJob do
100
100
  )
101
101
  end
102
102
 
103
+ it "passes validation if not enqueued and blast_dbs is empty" do
104
+ @blastn_job.queue = false
105
+ @blastn_job.blast_dbs = []
106
+ @blastn_job.should have(0).errors_on(:blast_dbs)
107
+ end
108
+
109
+ it "fails validation if blast_dbs is empty" do
110
+ @blastn_job.queue = true
111
+ @blastn_job.blast_dbs = []
112
+ @blastn_job.should have(1).errors_on(:blast_dbs)
113
+ end
114
+
115
+ # Test for removal of multiple select hidden field value.
116
+ it "fails validation if blast_dbs contains an empty string" do
117
+ @blastn_job.queue = true
118
+ @blastn_job.blast_dbs = ["", "", ""]
119
+ @blastn_job.should have(1).errors_on(:blast_dbs)
120
+ end
121
+
103
122
  it "joins blast_dbs on semicolon after save" do
104
123
  @blastn_job.blast_dbs = ["test_1", "test_2"]
105
124
  @blastn_job.save
@@ -109,10 +128,10 @@ describe Quorum::BlastnJob do
109
128
  it "sets optional params to default values if empty after save" do
110
129
  @blastn_job.save
111
130
  @blastn_job.expectation.should eq("5e-20")
112
- @blastn_job.max_score.should eq(25)
131
+ @blastn_job.max_target_seqs.should eq(25)
113
132
  @blastn_job.min_bit_score.should eq(0)
114
- @blastn_job.gap_opening_penalty.should eq(0)
115
- @blastn_job.gap_extension_penalty.should eq(0)
133
+ @blastn_job.gap_opening_penalty.should be_nil
134
+ @blastn_job.gap_extension_penalty.should be_nil
116
135
  end
117
136
 
118
137
  end
@@ -6,12 +6,12 @@ describe Quorum::BlastpJob do
6
6
  @blastp_job = Quorum::BlastpJob.new()
7
7
  end
8
8
 
9
- it "fails validation with poorly formatted expectation (using error_on)" do
9
+ it "fails validation with poorly formatted expectation" do
10
10
  @blastp_job.expectation = "this is bad"
11
11
  @blastp_job.should have(1).error_on(:expectation)
12
12
  end
13
13
 
14
- it "passes validation with valid expectation values (using error_on)" do
14
+ it "passes validation with valid expectation values" do
15
15
  @blastp_job.expectation = 12
16
16
  @blastp_job.should have(0).errors_on(:expectation)
17
17
  @blastp_job.expectation = 12.1201
@@ -22,49 +22,49 @@ describe Quorum::BlastpJob do
22
22
  @blastp_job.should have(0).errors_on(:expectation)
23
23
  end
24
24
 
25
- it "fails validation with poorly formatted max_score (using error_on)" do
26
- @blastp_job.max_score = 12.34
27
- @blastp_job.should have(1).error_on(:max_score)
28
- @blastp_job.max_score = "not a number"
29
- @blastp_job.should have(1).error_on(:max_score)
25
+ it "fails validation with poorly formatted max_target_seqs" do
26
+ @blastp_job.max_target_seqs = 12.34
27
+ @blastp_job.should have(1).error_on(:max_target_seqs)
28
+ @blastp_job.max_target_seqs = "not a number"
29
+ @blastp_job.should have(1).error_on(:max_target_seqs)
30
30
  end
31
31
 
32
- it "passed validation with valid max_score (using error_on)" do
33
- @blastp_job.max_score = 1235
34
- @blastp_job.should have(0).errors_on(:max_score)
32
+ it "passed validation with valid max_target_seqs" do
33
+ @blastp_job.max_target_seqs = 1235
34
+ @blastp_job.should have(0).errors_on(:max_target_seqs)
35
35
  end
36
36
 
37
- it "fails validation with poorly formatted gap_opening_penalty (using error_on)" do
37
+ it "fails validation with poorly formatted gap_opening_penalty" do
38
38
  @blastp_job.gap_opening_penalty = "not a number"
39
39
  @blastp_job.should have(1).error_on(:gap_opening_penalty)
40
40
  @blastp_job.gap_opening_penalty = 100.10
41
41
  @blastp_job.should have(1).error_on(:gap_opening_penalty)
42
42
  end
43
43
 
44
- it "passed validation with valid gap_opening_penalty (using error_on)" do
45
- @blastp_job.max_score = 13
44
+ it "passed validation with valid gap_opening_penalty" do
45
+ @blastp_job.max_target_seqs = 13
46
46
  @blastp_job.should have(0).errors_on(:gap_opening_penalty)
47
47
  end
48
48
 
49
- it "fails validation with poorly formatted gap_extension_penalty (using error_on)" do
49
+ it "fails validation with poorly formatted gap_extension_penalty" do
50
50
  @blastp_job.gap_extension_penalty = "who are you?"
51
51
  @blastp_job.should have(1).error_on(:gap_extension_penalty)
52
52
  @blastp_job.gap_extension_penalty = 0.3
53
53
  @blastp_job.should have(1).error_on(:gap_extension_penalty)
54
54
  end
55
55
 
56
- it "passed validation with valid gap_extension_penalty (using error_on)" do
57
- @blastp_job.max_score = 456
56
+ it "passed validation with valid gap_extension_penalty" do
57
+ @blastp_job.max_target_seqs = 456
58
58
  @blastp_job.should have(0).errors_on(:gap_extension_penalty)
59
59
  end
60
60
 
61
- it "fails validation without selecting gap_opening_extension with gapped_alignment (using error_on)" do
61
+ it " sssesvalidation without selecting gap_opening_extension with gapped_alignment" do
62
62
  @blastp_job.gapped_alignments = true
63
63
  @blastp_job.gap_opening_extension = ""
64
- @blastp_job.should have(1).error_on(:gap_opening_extension)
64
+ @blastp_job.should have(0).error_on(:gap_opening_extension)
65
65
  end
66
66
 
67
- it "fails validation without selecting gap_opening_extension with gapped_alignment (using error_on)" do
67
+ it "fails validation without selecting gap_opening_extension with gapped_alignment" do
68
68
  @blastp_job.gapped_alignments = true
69
69
  @blastp_job.gap_opening_extension = "11, 2"
70
70
  @blastp_job.should have(0).errors_on(:gap_opening_extension)
@@ -100,6 +100,25 @@ describe Quorum::BlastpJob do
100
100
  )
101
101
  end
102
102
 
103
+ it "passes validation if not enqueued and blast_dbs is empty" do
104
+ @blastp_job.queue = false
105
+ @blastp_job.blast_dbs = []
106
+ @blastp_job.should have(0).errors_on(:blast_dbs)
107
+ end
108
+
109
+ it "fails validation if blast_dbs is empty" do
110
+ @blastp_job.queue = true
111
+ @blastp_job.blast_dbs = []
112
+ @blastp_job.should have(1).errors_on(:blast_dbs)
113
+ end
114
+
115
+ # Test for removal of multiple select hidden field value.
116
+ it "fails validation if blast_dbs contains an empty string" do
117
+ @blastp_job.queue = true
118
+ @blastp_job.blast_dbs = ["", "", ""]
119
+ @blastp_job.should have(1).errors_on(:blast_dbs)
120
+ end
121
+
103
122
  it "joins blast_dbs on semicolon after save" do
104
123
  @blastp_job.blast_dbs = ["test_1", "test_2"]
105
124
  @blastp_job.save
@@ -109,10 +128,10 @@ describe Quorum::BlastpJob do
109
128
  it "sets optional params to default values if empty after save" do
110
129
  @blastp_job.save
111
130
  @blastp_job.expectation.should eq("5e-20")
112
- @blastp_job.max_score.should eq(25)
131
+ @blastp_job.max_target_seqs.should eq(25)
113
132
  @blastp_job.min_bit_score.should eq(0)
114
- @blastp_job.gap_opening_penalty.should eq(0)
115
- @blastp_job.gap_extension_penalty.should eq(0)
133
+ @blastp_job.gap_opening_penalty.should be_nil
134
+ @blastp_job.gap_extension_penalty.should be_nil
116
135
  end
117
136
 
118
137
  end