quorum 0.7.1 → 0.8.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 (61) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +5 -1
  3. data/Gemfile +4 -2
  4. data/Gemfile.lock +68 -47
  5. data/HISTORY.md +9 -0
  6. data/README.rdoc +1 -1
  7. data/app/assets/javascripts/quorum/quorum.js +4 -4
  8. data/app/controllers/quorum/application_controller.rb +1 -0
  9. data/app/controllers/quorum/jobs_controller.rb +65 -80
  10. data/app/models/quorum/blastn_job.rb +1 -1
  11. data/app/models/quorum/blastn_job_report.rb +4 -1
  12. data/app/models/quorum/blastp_job.rb +1 -1
  13. data/app/models/quorum/blastp_job_report.rb +4 -1
  14. data/app/models/quorum/blastx_job.rb +1 -1
  15. data/app/models/quorum/blastx_job_report.rb +4 -1
  16. data/app/models/quorum/job.rb +64 -56
  17. data/app/models/quorum/job_data.rb +22 -0
  18. data/app/models/quorum/job_fetch_data.rb +11 -0
  19. data/app/models/quorum/job_queue_observer.rb +11 -0
  20. data/app/models/quorum/job_queue_service.rb +66 -0
  21. data/app/models/quorum/job_report_searcher.rb +36 -0
  22. data/app/models/quorum/job_serializer.rb +96 -0
  23. data/app/models/quorum/tblastn_job.rb +1 -1
  24. data/app/models/quorum/tblastn_job_report.rb +4 -1
  25. data/app/views/quorum/jobs/show.html.erb +3 -0
  26. data/app/views/quorum/jobs/templates/_blast_detailed_report_template.html.erb +1 -1
  27. data/app/views/quorum/jobs/templates/_blast_template.html.erb +3 -1
  28. data/config/initializers/mime_types.rb +2 -0
  29. data/config/routes.rb +3 -3
  30. data/db/migrate/20120809155712_add_percent_identity_to_blast_reports.rb +8 -0
  31. data/db/migrate/20120921182416_add_mismatch_to_blast_reports.rb +8 -0
  32. data/lib/generators/templates/blast.rb +8 -1
  33. data/lib/quorum/engine.rb +2 -0
  34. data/lib/quorum/sequence.rb +35 -0
  35. data/lib/quorum/version.rb +1 -1
  36. data/lib/quorum.rb +3 -10
  37. data/lib/tasks/quorum_blastdb_build.rake +3 -1
  38. data/lib/workers/system.rb +3 -1
  39. data/quorum.gemspec +1 -0
  40. data/spec/dummy/config/environment.rb +18 -5
  41. data/spec/javascripts/helpers/jasmine-jquery.js +2 -2
  42. data/spec/javascripts/{jobs_spec.js → suites/jobs_spec.js} +0 -0
  43. data/spec/javascripts/{quorum_spec.js → suites/quorum_spec.js} +0 -0
  44. data/spec/javascripts/{string_spec.js → suites/string_spec.js} +0 -0
  45. data/spec/lib/tasks/travis.rake +9 -4
  46. data/spec/models/blastn_job_report_spec.rb +7 -3
  47. data/spec/models/blastp_job_report_spec.rb +8 -3
  48. data/spec/models/blastx_job_report_spec.rb +8 -3
  49. data/spec/models/job_data_spec.rb +21 -0
  50. data/spec/models/job_fetch_data_spec.rb +25 -0
  51. data/spec/models/job_queue_observer_spec.rb +18 -0
  52. data/spec/models/job_queue_service_spec.rb +49 -0
  53. data/spec/models/job_report_searcher_spec.rb +47 -0
  54. data/spec/models/job_serializer_spec.rb +60 -0
  55. data/spec/models/job_spec.rb +1 -16
  56. data/spec/models/tblastn_job_report_spec.rb +8 -3
  57. data/spec/quorum/quorum_sequence_spec.rb +2 -0
  58. data/spec/requests/jobs_spec.rb +16 -7
  59. data/spec/spec_helper.rb +2 -0
  60. metadata +38 -8
  61. data/spec/dummy/app/models/blast.rb +0 -2
@@ -3,8 +3,6 @@ module Quorum
3
3
 
4
4
  include Quorum::Sequence
5
5
 
6
- after_save :queue_workers
7
-
8
6
  has_one :blastn_job, :dependent => :destroy
9
7
  has_many :blastn_job_reports, :through => :blastn_job,
10
8
  :dependent => :destroy
@@ -34,33 +32,72 @@ module Quorum
34
32
  validate :filter_input_sequences, :algorithm_selected, :sequence_size
35
33
 
36
34
  #
37
- # Fetch Blast hit_id, hit_display_id, queue Resque worker and
38
- # return worker's meta_id.
35
+ # Return search results (Resque worker results).
39
36
  #
40
- def fetch_quorum_blast_sequence(algo, algo_id)
41
- job = "#{algo}_job".to_sym
42
- job_reports = "#{algo}_job_reports".to_sym
43
-
44
- blast_dbs = self.method(job).call.blast_dbs
45
-
46
- job_report = self.method(job_reports).call.where(
47
- "quorum_#{algo}_job_reports.id = ?", algo_id
48
- ).first
49
-
50
- hit_id = job_report.hit_id
51
- hit_display_id = job_report.hit_display_id
52
-
53
- cmd = Workers::System.create_blast_fetch_command(
54
- blast_dbs, hit_id, hit_display_id, algo
55
- )
37
+ def self.search(params)
38
+ data = JobData.new
39
+
40
+ # Allow for multiple algos and search params.
41
+ # Ex: /quorum/jobs/:id/search?algo=blastn,blastp
42
+ if params[:algo]
43
+ params[:algo].split(",").each do |a|
44
+ if Quorum::SUPPORTED_ALGORITHMS.include?(a)
45
+ enqueued = "#{a}_job".to_sym
46
+ report = "#{a}_job_reports".to_sym
47
+ begin
48
+ job = Job.find(params[:id])
49
+ rescue ActiveRecord::RecordNotFound => e
50
+ logger.error e.message
51
+ else
52
+ if job.try(enqueued).present?
53
+ if job.try(report).present?
54
+ data.results << job.try(report).search(a, params).default_order
55
+ else
56
+ data = JobData.new
57
+ end
58
+ else
59
+ data.not_enqueued
60
+ end
61
+ end
62
+ end
63
+ end
64
+ else
65
+ data.no_results
66
+ end
56
67
 
57
- data = Workers::System.enqueue(
58
- cmd, Quorum.blast_remote,
59
- Quorum.blast_ssh_host, Quorum.blast_ssh_user,
60
- Quorum.blast_ssh_options, true
61
- )
68
+ data.results
69
+ end
62
70
 
63
- Workers::System.get_meta(data.meta_id)
71
+ #
72
+ # Fetch Blast hit_id, hit_display_id, queue Resque worker and
73
+ # return worker's meta_id.
74
+ #
75
+ def self.set_blast_hit_sequence_lookup_values(params)
76
+ fetch_data = JobFetchData.new
77
+ algo = params[:algo]
78
+ algo_id = params[:algo_id]
79
+
80
+ if Quorum::SUPPORTED_ALGORITHMS.include?(algo)
81
+ fetch_data.algo = algo
82
+ begin
83
+ job = Job.find(params[:id])
84
+ rescue ActiveRecord::RecordNotFound => e
85
+ logger.error e.message
86
+ else
87
+ algo_job = "#{algo}_job".to_sym
88
+ algo_job_reports = "#{algo}_job_reports".to_sym
89
+
90
+ fetch_data.blast_dbs = job.try(algo_job).blast_dbs
91
+
92
+ job_report = job.try(algo_job_reports).where(
93
+ "quorum_#{algo}_job_reports.id = ?", algo_id
94
+ ).first
95
+
96
+ fetch_data.hit_id = job_report.hit_id
97
+ fetch_data.hit_display_id = job_report.hit_display_id
98
+ end
99
+ end
100
+ fetch_data
64
101
  end
65
102
 
66
103
  #
@@ -84,7 +121,7 @@ module Quorum
84
121
  # Ensure the sequences are in plain text.
85
122
  begin
86
123
  ActiveSupport::Multibyte::Unicode.u_unpack(self.sequence)
87
- rescue ActiveSupport::Multibyte::EncodingError => e
124
+ rescue Exception => e
88
125
  logger.error e.message
89
126
  errors.add(
90
127
  :sequence,
@@ -164,34 +201,5 @@ module Quorum
164
201
  end
165
202
  end
166
203
 
167
- #
168
- # Queue Resque workers.
169
- #
170
- def queue_workers
171
- jobs = []
172
- if self.blastn_job && self.blastn_job.queue
173
- jobs << Workers::System.create_search_command("blastn", self.id)
174
- end
175
- if self.blastx_job && self.blastx_job.queue
176
- jobs << Workers::System.create_search_command("blastx", self.id)
177
- end
178
- if self.tblastn_job && self.tblastn_job.queue
179
- jobs << Workers::System.create_search_command("tblastn", self.id)
180
- end
181
- if self.blastp_job && self.blastp_job.queue
182
- jobs << Workers::System.create_search_command("blastp", self.id)
183
- end
184
-
185
- unless jobs.blank?
186
- jobs.each do |j|
187
- Workers::System.enqueue(
188
- j, Quorum.blast_remote,
189
- Quorum.blast_ssh_host, Quorum.blast_ssh_user,
190
- Quorum.blast_ssh_options
191
- )
192
- end
193
- end
194
- end
195
-
196
204
  end
197
205
  end
@@ -0,0 +1,22 @@
1
+ module Quorum
2
+ class JobData
3
+
4
+ def initialize
5
+ @data = []
6
+ end
7
+
8
+ def results
9
+ @data
10
+ end
11
+
12
+ def no_results
13
+ @data = [{ results: false }]
14
+ end
15
+
16
+ def not_enqueued
17
+ no_results
18
+ @data = [{ enqueued: false }.merge(@data[0])]
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ module Quorum
2
+ class JobFetchData
3
+
4
+ include ActiveModel::Validations
5
+
6
+ attr_accessor :algo, :blast_dbs, :hit_id, :hit_display_id
7
+
8
+ validates_presence_of :algo, :blast_dbs, :hit_id, :hit_display_id
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Quorum
2
+ class JobQueueObserver < ActiveRecord::Observer
3
+
4
+ observe Quorum::Job
5
+
6
+ def after_create(job)
7
+ Quorum::JobQueueService.queue_search_workers(job)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,66 @@
1
+ module Quorum
2
+ class JobQueueService
3
+
4
+ #
5
+ # Queue search workers.
6
+ #
7
+ def self.queue_search_workers(job)
8
+ blast_jobs = []
9
+ if job.blastn_job && job.blastn_job.queue
10
+ blast_jobs << Workers::System.create_search_command("blastn", job.id)
11
+ end
12
+ if job.blastx_job && job.blastx_job.queue
13
+ blast_jobs << Workers::System.create_search_command("blastx", job.id)
14
+ end
15
+ if job.tblastn_job && job.tblastn_job.queue
16
+ blast_jobs << Workers::System.create_search_command("tblastn", job.id)
17
+ end
18
+ if job.blastp_job && job.blastp_job.queue
19
+ blast_jobs << Workers::System.create_search_command("blastp", job.id)
20
+ end
21
+
22
+ unless blast_jobs.blank?
23
+ blast_jobs.each do |b|
24
+ Workers::System.enqueue(
25
+ b,
26
+ Quorum.blast_remote,
27
+ Quorum.blast_ssh_host,
28
+ Quorum.blast_ssh_user,
29
+ Quorum.blast_ssh_options
30
+ )
31
+ end
32
+ end
33
+ end
34
+
35
+ #
36
+ # Queue fetch worker to send blast hit sequence. Return job meta_id for
37
+ # for data access.
38
+ #
39
+ # See JobsController#send_blast_hit_sequence for more info.
40
+ #
41
+ def self.queue_fetch_worker(fetch_data)
42
+ unless fetch_data.valid?
43
+ return nil
44
+ end
45
+
46
+ cmd = Workers::System.create_blast_fetch_command(
47
+ fetch_data.blast_dbs,
48
+ fetch_data.hit_id,
49
+ fetch_data.hit_display_id,
50
+ fetch_data.algo
51
+ )
52
+
53
+ data = Workers::System.enqueue(
54
+ cmd,
55
+ Quorum.blast_remote,
56
+ Quorum.blast_ssh_host,
57
+ Quorum.blast_ssh_user,
58
+ Quorum.blast_ssh_options,
59
+ true
60
+ )
61
+
62
+ [{ meta_id: data.meta_id }]
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ module Quorum
2
+ module JobReportSearcher
3
+
4
+ #
5
+ # Simple search interface on query, id and job id for job reports.
6
+ #
7
+ def search(algo, params)
8
+ algo.downcase!
9
+ klass = "quorum/#{algo}_job_report".camelize.constantize
10
+ if params[:"#{algo}_id"].present? && params[:query].present?
11
+ klass.where(
12
+ "quorum_#{algo}_job_reports.id IN (?) AND query = ? " <<
13
+ "AND #{algo}_job_id = ?",
14
+ params[:"#{algo}_id"].split(","),
15
+ params[:query],
16
+ params[:id]
17
+ )
18
+ elsif params[:"#{algo}_id"].present?
19
+ klass.where(
20
+ "quorum_#{algo}_job_reports.id IN (?) AND #{algo}_job_id = ? ",
21
+ params[:"#{algo}_id"].split(","),
22
+ params[:id]
23
+ )
24
+ elsif params[:query].present?
25
+ klass.where(
26
+ "query = ? AND #{algo}_job_id = ?",
27
+ params[:query],
28
+ params[:id]
29
+ )
30
+ else
31
+ klass.where("#{algo}_job_id = ?", params[:id])
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,96 @@
1
+ module Quorum
2
+ module JobSerializer
3
+
4
+ #
5
+ # Convert jobs to json. Uses Rails default.
6
+ #
7
+ def self.as_json(job)
8
+ if job.respond_to?(:errors) && job.errors.present?
9
+ { errors: job.errors.full_messages }
10
+ else
11
+ job.as_json(root: false)
12
+ end
13
+ end
14
+
15
+ #
16
+ # Convert jobs to tab delimited output.
17
+ #
18
+ def self.as_txt(job)
19
+ txt = ""
20
+ values = [
21
+ "query",
22
+ "hit_display_id",
23
+ "pct_identity",
24
+ "align_len",
25
+ "mismatch",
26
+ "gaps",
27
+ "query_from",
28
+ "query_to",
29
+ "hit_from",
30
+ "hit_to",
31
+ "evalue",
32
+ "bit_score"
33
+ ]
34
+
35
+ job.each do |j|
36
+ txt << j.attributes.values_at(*values).join("\t") << "\n"
37
+ end
38
+ txt
39
+ end
40
+
41
+ #
42
+ # Convert jobs to GFF.
43
+ #
44
+ def self.as_gff(job)
45
+ pragma = "##gff-version 3\n"
46
+ source = "."
47
+ type = "match"
48
+ phase = "."
49
+ txt = ""
50
+ job.each do |j|
51
+ if j.results
52
+ # Add sequence-region.
53
+ unless pragma.include?(j.hit_display_id)
54
+ pragma << "##sequence-region #{j.hit_display_id} 1 #{j.hit_len}\n"
55
+ end
56
+
57
+ start, stop = j.hit_from, j.hit_to
58
+
59
+ # Set the strand based on the original start, stop.
60
+ start > stop ? strand = "-" : strand = "+"
61
+ # Format the start, stop for GFF.
62
+ start, stop = format_hit_start_stop(start, stop)
63
+
64
+ values = [
65
+ j.hit_display_id,
66
+ source,
67
+ type,
68
+ start,
69
+ stop,
70
+ j.evalue,
71
+ strand,
72
+ phase
73
+ ]
74
+
75
+ txt << values.join("\t") << "\tTarget=#{j.query} " <<
76
+ "#{j.query_from} #{j.query_to};Name=#{j.query};" <<
77
+ "identity=#{j.pct_identity};rawscore=#{j.score};" <<
78
+ "significance=#{j.evalue}\n"
79
+ end
80
+ end
81
+ txt.insert(0, pragma)
82
+ end
83
+
84
+ #
85
+ # Start must be <= to stop.
86
+ #
87
+ def self.format_hit_start_stop(start, stop)
88
+ tmp_start, tmp_stop = start, stop
89
+ if start > stop
90
+ tmp_start, tmp_stop = stop, start
91
+ end
92
+ return tmp_start, tmp_stop
93
+ end
94
+
95
+ end
96
+ end
@@ -17,7 +17,7 @@ module Quorum
17
17
  :blast_dbs
18
18
 
19
19
  validates_format_of :expectation,
20
- :with => /^[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
20
+ :with => /\A[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\z/,
21
21
  :message => " - Valid formats (12, 32.05, 43e-123)",
22
22
  :allow_blank => true
23
23
  validates_numericality_of :max_target_seqs,
@@ -1,7 +1,10 @@
1
1
  module Quorum
2
2
  class TblastnJobReport < ActiveRecord::Base
3
+
4
+ extend Quorum::JobReportSearcher
5
+
3
6
  belongs_to :tblastn_job
4
7
  scope :default_order, order("query ASC, bit_score DESC")
5
- scope :by_query, lambda { |query| where("query = ?", query) }
8
+
6
9
  end
7
10
  end
@@ -79,6 +79,9 @@
79
79
  // // awesome logic
80
80
  // };
81
81
  //
82
+ // See https://github.com/ncgr/lis_sequence_search for a complete example
83
+ // using d3.js (http://d3js.org/).
84
+ //
82
85
  QUORUM.pollResults();
83
86
  });
84
87
  </script>
@@ -29,7 +29,7 @@
29
29
  </tr>
30
30
  </table>
31
31
  <p class="small">
32
- <a id="download_sequence_{{= v.id }}"
32
+ <a class="download_sequence" id="download_sequence_{{= v.id }}"
33
33
  onclick="QUORUM.downloadSequence({{= v.id }}, '{{= algo }}', this)">
34
34
  Download Sequence
35
35
  </a>
@@ -1,6 +1,8 @@
1
1
  <%# Blast Results Template %>
2
2
  <script type="text/template" id="blast_template">
3
- {{ if (data[0].results === false) { }}
3
+ {{ if (data[0].enqueued === false) { }}
4
+ <p><strong>Not enqueued.</strong></p>
5
+ {{ } else if (data[0].results === false) { }}
4
6
  <p><strong>Your search returned 0 hits.</strong></p>
5
7
  {{ } else { }}
6
8
  <table class="results">
@@ -0,0 +1,2 @@
1
+ Mime::Type.register "text/plain", :gff
2
+ Mime::Type.register "text/plain", :txt
data/config/routes.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  Quorum::Engine.routes.draw do
2
2
  resources :jobs, :only => [:index, :show, :new, :create] do
3
3
  member do
4
- get :get_quorum_search_results
5
- get :get_quorum_blast_hit_sequence
6
- get :send_quorum_blast_hit_sequence
4
+ get :search, :defaults => { :format => 'json' }
5
+ get :get_blast_hit_sequence, :defaults => { :format => 'json' }
6
+ get :send_blast_hit_sequence
7
7
  end
8
8
  end
9
9
 
@@ -0,0 +1,8 @@
1
+ class AddPercentIdentityToBlastReports < ActiveRecord::Migration
2
+ def change
3
+ add_column :quorum_blastn_job_reports, :pct_identity, :float
4
+ add_column :quorum_blastx_job_reports, :pct_identity, :float
5
+ add_column :quorum_tblastn_job_reports, :pct_identity, :float
6
+ add_column :quorum_blastp_job_reports, :pct_identity, :float
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class AddMismatchToBlastReports < ActiveRecord::Migration
2
+ def change
3
+ add_column :quorum_blastn_job_reports, :mismatch, :integer
4
+ add_column :quorum_blastx_job_reports, :mismatch, :integer
5
+ add_column :quorum_tblastn_job_reports, :mismatch, :integer
6
+ add_column :quorum_blastp_job_reports, :mismatch, :integer
7
+ end
8
+ end
@@ -364,12 +364,19 @@ module Quorum
364
364
  @data[:hseq] = hsp.hseq
365
365
  @data[:midline] = hsp.midline
366
366
 
367
+ # Calculate percent identity
368
+ @data[:pct_identity] = (
369
+ @data[:identity].to_f / @data[:align_len].to_f
370
+ ) * 100
371
+
372
+ # Calculate mismatch
373
+ @data[:mismatch] = @data[:align_len] - @data[:identity]
374
+
367
375
  if @data[:bit_score] &&
368
376
  (@data[:bit_score].to_i > @min_score.to_i)
369
377
  @results = true
370
378
  save_hsp_results
371
379
  end
372
-
373
380
  end
374
381
  end
375
382
  end
data/lib/quorum/engine.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Quorum
2
2
  class Engine < Rails::Engine
3
3
  isolate_namespace Quorum
4
+
5
+ config.active_record.observers = "Quorum::JobQueueObserver"
4
6
  end
5
7
  end
@@ -86,5 +86,40 @@ module Quorum
86
86
  type
87
87
  end
88
88
 
89
+
90
+ #
91
+ # Send sequence data to the browser.
92
+ #
93
+ module SendSequence
94
+
95
+ def sequence(data)
96
+ @data = data
97
+ if @data.respond_to?(:succeeded?) && @data.succeeded?
98
+ if self.has_error?
99
+ return self.render_error
100
+ else
101
+ return send_data @data.result,
102
+ :filename => @data.meta_id,
103
+ :type => "text/plain",
104
+ :disposition => "attachment"
105
+ end
106
+ end
107
+ self.render_empty
108
+ end
109
+
110
+ def has_error?
111
+ @data.result.downcase.include?("error")
112
+ end
113
+
114
+ def render_error
115
+ render :text => @data.result
116
+ end
117
+
118
+ def render_empty
119
+ render :text => ""
120
+ end
121
+
122
+ end
123
+
89
124
  end
90
125
  end
@@ -1,3 +1,3 @@
1
1
  module Quorum
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/quorum.rb CHANGED
@@ -11,16 +11,15 @@ require "workers/system"
11
11
  module Quorum
12
12
 
13
13
  ## Supported Algorithms ##
14
- BLAST_ALGORITHMS = ["blastn", "blastx", "blastp", "tblastn"].freeze
14
+ BLAST_ALGORITHMS = ["blastn", "blastx", "blastp", "tblastn"].freeze
15
+ SUPPORTED_ALGORITHMS = [BLAST_ALGORITHMS]
16
+ SUPPORTED_ALGORITHMS.flatten!
15
17
 
16
18
  mattr_accessor :max_sequence_size, :blast_remote, :blast_ssh_host,
17
19
  :blast_ssh_user, :blast_ssh_options, :blast_bin,
18
20
  :blast_log_dir, :blast_tmp_dir, :blast_db, :tblastn,
19
21
  :blastp, :blastn, :blastx, :blast_threads
20
22
 
21
- ## Deprecated ##
22
- mattr_accessor :blast_script
23
-
24
23
  class << self
25
24
 
26
25
  ## General ##
@@ -97,12 +96,6 @@ module Quorum
97
96
  @@blast_threads || 1
98
97
  end
99
98
 
100
- ## Blast Deprecated ##
101
-
102
- def blast_script
103
- nil
104
- end
105
-
106
99
  end
107
100
 
108
101
  end
@@ -40,7 +40,9 @@ namespace :quorum do
40
40
  args[:nucl_file] = "NULL" if args[:type] == "prot"
41
41
  args[:prot_file] = "NULL" if args[:type] == "nucl"
42
42
 
43
- puts "Building your Blast database(s). This may take a while..."
43
+ unless args[:empty]
44
+ puts "Building your Blast database(s). This may take a while..."
45
+ end
44
46
 
45
47
  build = Quorum::BuildBlastDB.new(args)
46
48
  build.build_blast_db_data
@@ -94,8 +94,10 @@ module Workers
94
94
  def self.create_search_command(algo, id)
95
95
  # System command
96
96
  cmd = ""
97
+ return cmd unless Quorum::SUPPORTED_ALGORITHMS.include?(algo)
97
98
 
98
- if Quorum::BLAST_ALGORITHMS.include?(algo)
99
+ case
100
+ when Quorum::BLAST_ALGORITHMS.include?(algo)
99
101
  search = File.join(Quorum.blast_bin, "search")
100
102
  cmd << "#{search} -l #{Quorum.blast_log_dir} " <<
101
103
  "-m #{Quorum.blast_tmp_dir} -b #{Quorum.blast_db} " <<
data/quorum.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency "bio-blastxmlparser", "~> 1.1.0"
24
24
 
25
25
  s.add_development_dependency "mysql2", "~> 0.3.11"
26
+ s.add_development_dependency "pg", "~> 0.14.1"
26
27
  s.add_development_dependency "rspec-rails", "~> 2.11"
27
28
  s.add_development_dependency "resque_spec", "~> 0.12"
28
29
  s.add_development_dependency "capybara", "~> 1.1"
@@ -4,17 +4,30 @@ require File.expand_path('../application', __FILE__)
4
4
  # Initialize the rails application
5
5
  Dummy::Application.initialize!
6
6
 
7
- ## Explicitly remove AR transactions during tests ##
7
+ ## Explicitly remove MySQL AR transactions during tests ##
8
8
  if Rails.env.test?
9
9
  # Force the loading of AR stuff
10
10
  ActiveRecord::Base.connection.execute('SELECT 1')
11
11
 
12
- # Remove transactions
13
- ActiveRecord::ConnectionAdapters::Mysql2Adapter.class_eval do
14
- def begin_db_transaction
12
+ if ENV['DB'] == 'mysql'
13
+ # Remove transactions
14
+ ActiveRecord::ConnectionAdapters::Mysql2Adapter.class_eval do
15
+ def begin_db_transaction
16
+ end
17
+
18
+ def commit_db_transaction
19
+ end
15
20
  end
21
+ end
22
+
23
+ if ENV['DB'] == 'postgresql'
24
+ # Remove transactions
25
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
26
+ def begin_db_transaction
27
+ end
16
28
 
17
- def commit_db_transaction
29
+ def commit_db_transaction
30
+ end
18
31
  end
19
32
  end
20
33
  end