Class: Quorum::JobsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Quorum::JobsController
- Defined in:
- app/controllers/quorum/jobs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#get_quorum_blast_hit_sequence ⇒ Object
Find hit sequence, queue worker and return worker meta_id for lookup.
-
#get_quorum_search_results ⇒ Object
Returns Resque worker results.
- #index ⇒ Object
- #new ⇒ Object
-
#send_quorum_blast_hit_sequence ⇒ Object
Send Blast hit sequence as attached file or render error message as text.
- #show ⇒ Object
Methods included from Helpers
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/quorum/jobs_controller.rb', line 19 def create if params[:job][:sequence_file] file = params[:job][:sequence_file].read params[:job].delete(:sequence_file) end @job = Job.new(params[:job]) if file @job.sequence = "" @job.sequence << file end unless @job.save @job.build_blastn_job if @job.blastn_job.nil? @job.build_blastx_job if @job.blastx_job.nil? @job.build_tblastn_job if @job.tblastn_job.nil? @job.build_blastp_job if @job.blastp_job.nil? render :action => "new" return end redirect_to job_path(@job.id) end |
#get_quorum_blast_hit_sequence ⇒ Object
Find hit sequence, queue worker and return worker meta_id for lookup.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/controllers/quorum/jobs_controller.rb', line 88 def get_quorum_blast_hit_sequence if Quorum::BLAST_ALGORITHMS.include?(params[:algo]) begin job = Job.find(params[:id]) rescue ActiveRecord::RecordNotFound => e logger.error e. else data = job.fetch_quorum_blast_sequence( params[:algo], params[:algo_id] ) json = [{ :meta_id => data. }] end end respond_with json || [] end |
#get_quorum_search_results ⇒ Object
Returns Resque worker results.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/quorum/jobs_controller.rb', line 55 def get_quorum_search_results json = [{ :results => false }].to_json if Quorum::BLAST_ALGORITHMS.include?(params[:algo]) queued = "#{params[:algo]}_job".to_sym report = "#{params[:algo]}_job_reports".to_sym begin job = Job.find(params[:id]) rescue ActiveRecord::RecordNotFound => e json else if job.method(queued).call.present? if job.method(report).call.present? if params[:query] json = job.method(report).call.by_query(params[:query]).default_order else json = job.method(report).call.default_order end else json = [] end end end end respond_with json end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/quorum/jobs_controller.rb', line 7 def index redirect_to :action => "new" end |
#new ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/controllers/quorum/jobs_controller.rb', line 11 def new @job = Job.new @job.build_blastn_job @job.build_blastx_job @job.build_tblastn_job @job.build_blastp_job end |
#send_quorum_blast_hit_sequence ⇒ Object
Send Blast hit sequence as attached file or render error message as text.
See lib/generators/templates/blast_db.rb for more info.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/controllers/quorum/jobs_controller.rb', line 111 def send_quorum_blast_hit_sequence data = Workers::System.(params[:meta_id]) if data.succeeded? if data.result.downcase.include?("error") render :text => data.result return else send_data data.result, :filename => "#{params[:meta_id]}.fa", :type => "text/plain", :disposition => "attachment" return end end render :text => "" end |
#show ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/quorum/jobs_controller.rb', line 43 def show begin @jobs = Job.find(params[:id]) rescue ActiveRecord::RecordNotFound => e (:notice, :data_not_found) redirect_to :action => "new" end end |